* 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)
| 664 | * corresponding error. |
| 665 | */ |
| 666 | decodeFunctionResult(fragment, data) { |
| 667 | if (typeof (fragment) === "string") { |
| 668 | const f = this.getFunction(fragment); |
| 669 | assertArgument(f, "unknown function", "fragment", fragment); |
| 670 | fragment = f; |
| 671 | } |
| 672 | let message = "invalid length for result data"; |
| 673 | const bytes = getBytesCopy(data); |
| 674 | if ((bytes.length % 32) === 0) { |
| 675 | try { |
| 676 | return this.#abiCoder.decode(fragment.outputs, bytes); |
| 677 | } |
| 678 | catch (error) { |
| 679 | message = "could not decode result data"; |
| 680 | } |
| 681 | } |
| 682 | // Call returned data with no error, but the data is junk |
| 683 | assert(false, message, "BAD_DATA", { |
| 684 | value: hexlify(bytes), |
| 685 | info: { method: fragment.name, signature: fragment.format() } |
| 686 | }); |
| 687 | } |
| 688 | /** |
| 689 | * Encodes the result data (e.g. from an ``eth_call``) for the |
| 690 | * specified function (see [[getFunction]] for valid values |
nothing calls this directly
no test coverage detected