ethers.js icon indicating copy to clipboard operation
ethers.js copied to clipboard

Revert Spelunking

Open hamdiallam opened this issue 3 years ago • 0 comments

Ethers Version

5.6.9

Search Terms

ganache, revert, eth_call

Describe the Problem

The library spelunks jsonrpc errors based on the existence of "reverted"

// These *are* the droids we're looking for.
    if (typeof(value.message) === "string" && value.message.match("reverted")) {
        const data = isHexString(value.data) ? value.data: null;
        if (!requireData || data) {
            return { message: value.message, data };
        }
    }

However ganache doesn't emit "reverted" in the message. Simply "revert"

Ganache Revert Msg: https://github.com/trufflesuite/ganache/blob/197c12a4975b5d719a58b34d98897ac9accd77b9/src/chains/ethereum/utils/src/errors/call-error.ts#L13 Constant Definition: https://github.com/ethereumjs/ethereumjs-monorepo/blob/master/packages/evm/src/exceptions.ts#L9

This breaks using ENSIP-10 wildcard resolution which relies on parsing the result of a revert. Simple fix would be to change "reverted" to "revert".

Environment

Local - Ganache

hamdiallam avatar Jul 01 '22 21:07 hamdiallam