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

Method decodeFunctionResult

lib.commonjs/abi/interface.js:763–784  ·  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

761 * corresponding error.
762 */
763 decodeFunctionResult(fragment, data) {
764 if (typeof (fragment) === "string") {
765 const f = this.getFunction(fragment);
766 (0, index_js_3.assertArgument)(f, "unknown function", "fragment", fragment);
767 fragment = f;
768 }
769 let message = "invalid length for result data";
770 const bytes = (0, index_js_3.getBytesCopy)(data);
771 if ((bytes.length % 32) === 0) {
772 try {
773 return this.#abiCoder.decode(fragment.outputs, bytes);
774 }
775 catch (error) {
776 message = "could not decode result data";
777 }
778 }
779 // Call returned data with no error, but the data is junk
780 (0, index_js_3.assert)(false, message, "BAD_DATA", {
781 value: (0, index_js_3.hexlify)(bytes),
782 info: { method: fragment.name, signature: fragment.format() }
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);

Callers 3

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

Calls 3

getFunctionMethod · 0.95
decodeMethod · 0.45
formatMethod · 0.45

Tested by

no test coverage detected