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

Method decodeFunctionData

src.ts/abi/interface.ts:857–868  ·  view source on GitHub ↗

* Decodes the %%data%% from a transaction ``tx.data`` for * the function specified (see [[getFunction]] for valid values * for %%fragment%%). * * Most developers should prefer the [[parseTransaction]] method * instead, which will automatically detect the fragment.

(fragment: FunctionFragment | string, data: BytesLike)

Source from the content-addressed store, hash-verified

855 * instead, which will automatically detect the fragment.
856 */
857 decodeFunctionData(fragment: FunctionFragment | string, data: BytesLike): Result {
858 if (typeof(fragment) === "string") {
859 const f = this.getFunction(fragment);
860 assertArgument(f, "unknown function", "fragment", fragment);
861 fragment = f;
862 }
863
864 assertArgument(dataSlice(data, 0, 4) === fragment.selector,
865 `data signature does not match function ${ fragment.name }.`, "data", data);
866
867 return this._decodeParams(fragment.inputs, dataSlice(data, 4));
868 }
869
870 /**
871 * Encodes the ``tx.data`` for a transaction that calls the function

Callers 1

test-abi.tsFile · 0.45

Calls 4

getFunctionMethod · 0.95
_decodeParamsMethod · 0.95
assertArgumentFunction · 0.90
dataSliceFunction · 0.90

Tested by

no test coverage detected