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