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

Method decodeFunctionResult

lib.esm/abi/interface.js:755–776  ·  view source on GitHub ↗

* Decodes the result %%data%% (e.g. from an ``eth_call``) for the * specified function (see [[getFunction]] for valid values for * %%key%%). * * Most developers should prefer the [[parseCallResult]] method instead, * which will automatically detect a ``CALL_EXCEPTION``

(fragment, data)

Source from the content-addressed store, hash-verified

753 * corresponding error.
754 */
755 decodeFunctionResult(fragment, data) {
756 if (typeof (fragment) === "string") {
757 const f = this.getFunction(fragment);
758 assertArgument(f, "unknown function", "fragment", fragment);
759 fragment = f;
760 }
761 let message = "invalid length for result data";
762 const bytes = getBytesCopy(data);
763 if ((bytes.length % 32) === 0) {
764 try {
765 return this.#abiCoder.decode(fragment.outputs, bytes);
766 }
767 catch (error) {
768 message = "could not decode result data";
769 }
770 }
771 // Call returned data with no error, but the data is junk
772 assert(false, message, "BAD_DATA", {
773 value: hexlify(bytes),
774 info: { method: fragment.name, signature: fragment.format() }
775 });
776 }
777 makeError(_data, tx) {
778 const data = getBytes(_data, "data");
779 const error = AbiCoder.getBuiltinCallException("call", tx, data);

Callers 3

#fetchMethod · 0.45
staticCallResultFunction · 0.45
test-abi.jsFile · 0.45

Calls 7

getFunctionMethod · 0.95
assertArgumentFunction · 0.90
getBytesCopyFunction · 0.90
assertFunction · 0.90
hexlifyFunction · 0.90
decodeMethod · 0.45
formatMethod · 0.45

Tested by

no test coverage detected