(_data, tx)
| 775 | }); |
| 776 | } |
| 777 | makeError(_data, tx) { |
| 778 | const data = getBytes(_data, "data"); |
| 779 | const error = AbiCoder.getBuiltinCallException("call", tx, data); |
| 780 | // Not a built-in error; try finding a custom error |
| 781 | const customPrefix = "execution reverted (unknown custom error)"; |
| 782 | if (error.message.startsWith(customPrefix)) { |
| 783 | const selector = hexlify(data.slice(0, 4)); |
| 784 | const ef = this.getError(selector); |
| 785 | if (ef) { |
| 786 | try { |
| 787 | const args = this.#abiCoder.decode(ef.inputs, data.slice(4)); |
| 788 | error.revert = { |
| 789 | name: ef.name, signature: ef.format(), args |
| 790 | }; |
| 791 | error.reason = error.revert.signature; |
| 792 | error.message = `execution reverted: ${error.reason}`; |
| 793 | } |
| 794 | catch (e) { |
| 795 | error.message = `execution reverted (coult not decode custom error)`; |
| 796 | } |
| 797 | } |
| 798 | } |
| 799 | // Add the invocation, if available |
| 800 | const parsed = this.parseTransaction(tx); |
| 801 | if (parsed) { |
| 802 | error.invocation = { |
| 803 | method: parsed.name, |
| 804 | signature: parsed.signature, |
| 805 | args: parsed.args |
| 806 | }; |
| 807 | } |
| 808 | return error; |
| 809 | } |
| 810 | /** |
| 811 | * Encodes the result data (e.g. from an ``eth_call``) for the |
| 812 | * specified function (see [[getFunction]] for valid values |
no test coverage detected