* 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)
| 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); |
no test coverage detected