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