MCPcopy Create free account
hub / github.com/PageLeay/celestial-runtime / makeError

Method makeError

lib.commonjs/abi/interface.js:785–817  ·  view source on GitHub ↗
(_data, tx)

Source from the content-addressed store, hash-verified

783 });
784 }
785 makeError(_data, tx) {
786 const data = (0, index_js_3.getBytes)(_data, "data");
787 const error = abi_coder_js_1.AbiCoder.getBuiltinCallException("call", tx, data);
788 // Not a built-in error; try finding a custom error
789 const customPrefix = "execution reverted (unknown custom error)";
790 if (error.message.startsWith(customPrefix)) {
791 const selector = (0, index_js_3.hexlify)(data.slice(0, 4));
792 const ef = this.getError(selector);
793 if (ef) {
794 try {
795 const args = this.#abiCoder.decode(ef.inputs, data.slice(4));
796 error.revert = {
797 name: ef.name, signature: ef.format(), args
798 };
799 error.reason = error.revert.signature;
800 error.message = `execution reverted: ${error.reason}`;
801 }
802 catch (e) {
803 error.message = `execution reverted (coult not decode custom error)`;
804 }
805 }
806 }
807 // Add the invocation, if available
808 const parsed = this.parseTransaction(tx);
809 if (parsed) {
810 error.invocation = {
811 method: parsed.name,
812 signature: parsed.signature,
813 args: parsed.args
814 };
815 }
816 return error;
817 }
818 /**
819 * Encodes the result data (e.g. from an ``eth_call``) for the
820 * specified function (see [[getFunction]] for valid values

Callers 2

staticCallFunction · 0.45
staticCallResultFunction · 0.45

Calls 6

getErrorMethod · 0.95
parseTransactionMethod · 0.95
sliceMethod · 0.45
decodeMethod · 0.45
formatMethod · 0.45

Tested by

no test coverage detected