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

Method makeError

lib.esm/abi/interface.js:777–809  ·  view source on GitHub ↗
(_data, tx)

Source from the content-addressed store, hash-verified

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

Callers 2

staticCallFunction · 0.45
staticCallResultFunction · 0.45

Calls 8

getErrorMethod · 0.95
parseTransactionMethod · 0.95
getBytesFunction · 0.90
hexlifyFunction · 0.90
sliceMethod · 0.45
decodeMethod · 0.45
formatMethod · 0.45

Tested by

no test coverage detected