MCPcopy Create free account
hub / github.com/ccxt/ccxt / decodeFunctionResult

Method decodeFunctionResult

js/src/static_dependencies/ethers/interface.js:666–687  ·  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

664 * corresponding error.
665 */
666 decodeFunctionResult(fragment, data) {
667 if (typeof (fragment) === "string") {
668 const f = this.getFunction(fragment);
669 assertArgument(f, "unknown function", "fragment", fragment);
670 fragment = f;
671 }
672 let message = "invalid length for result data";
673 const bytes = getBytesCopy(data);
674 if ((bytes.length % 32) === 0) {
675 try {
676 return this.#abiCoder.decode(fragment.outputs, bytes);
677 }
678 catch (error) {
679 message = "could not decode result data";
680 }
681 }
682 // Call returned data with no error, but the data is junk
683 assert(false, message, "BAD_DATA", {
684 value: hexlify(bytes),
685 info: { method: fragment.name, signature: fragment.format() }
686 });
687 }
688 /**
689 * Encodes the result data (e.g. from an ``eth_call``) for the
690 * specified function (see [[getFunction]] for valid values

Callers

nothing calls this directly

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