* 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, data)
| 719 | * instead, which will automatically detect the fragment. |
| 720 | */ |
| 721 | decodeFunctionData(fragment, data) { |
| 722 | if (typeof (fragment) === "string") { |
| 723 | const f = this.getFunction(fragment); |
| 724 | assertArgument(f, "unknown function", "fragment", fragment); |
| 725 | fragment = f; |
| 726 | } |
| 727 | assertArgument(dataSlice(data, 0, 4) === fragment.selector, `data signature does not match function ${fragment.name}.`, "data", data); |
| 728 | return this._decodeParams(fragment.inputs, dataSlice(data, 4)); |
| 729 | } |
| 730 | /** |
| 731 | * Encodes the ``tx.data`` for a transaction that calls the function |
| 732 | * specified (see [[getFunction]] for valid values for %%fragment%%) with |
no test coverage detected