Inherited methods return "missing revert data" instead of revert string
See original GitHub issueEthers Version
8.3.0
Search Terms
missing revert data
Describe the Problem
When calling an inherited function which reverts, ethers throws “missing revert data in call” error instead of returning the supplied revert string. (This appears to work as expected in remix).
In the example below, I would expect the method call to return `forced revert’ but instread returns
Error: missing revert data in call exception [ See: https://links.ethers.org/v5-errors-CALL_EXCEPTION ] (error={"stackTrace":[{"type":4,"sourceReference":{"function":"getAttribute","contract":"Mymain","sourceName":"contracts/reader.sol","sourceContent":"// SPDX-License-Identifier: GPL-3.0\n\npragma solidity 0.8.6;\n\ncontract reader {\n\n address myAddress;\n \n\n function getAttribute() public pure returns(string memory) {\n \n require(false, \"forced revert\");\n return \"foo\";\n }\n}","line":12,"range":[191,222]},"message":{"value":{"type":"Buffer","data":[8,195,121,160,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,13,102,111,114,99,101,100,32,114,101,118,101,114,116,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]},"_selector":"08c379a0"},"isInvalidOpcodeError":false}]}, data="0x", code=CALL_EXCEPTION, version=providers/5.6.2)
This test code that produces this error is (hardhat typescript) is
import { ethers } from "hardhat";
import {Mymain} from '../typechain';
describe.only('Mymain', () => {
let mymain : Mymain;
before(async () => {
let bf = await ethers.getContractFactory("Mymain");
mymain = await bf.deploy();
});
it('test mymain', async () => {
let val = await mymain.getAttribute();
});
});
Code Snippet
pragma solidity 0.8.6;
contract reader {
address myAddress;
function getAttribute() public pure returns(string memory) {
require(false, "forced revert");
return "foo";
}
}
contract Mymain is reader {
constructor() {
myAddress=address(this);
}
function getName() public pure returns(string memory) {
return "foo";
}
function getFood() public pure returns(string memory) {
return "hamburger";
}
}
Contract ABI
No response
Errors
Error: missing revert data in call exception [ See: https://links.ethers.org/v5-errors-CALL_EXCEPTION ] (error={"stackTrace":[{"type":4,"sourceReference":{"function":"getAttribute","contract":"Mymain","sourceName":"contracts/reader.sol","sourceContent":"// SPDX-License-Identifier: GPL-3.0\n\npragma solidity 0.8.6;\n\ncontract reader {\n\n address myAddress;\n \n\n function getAttribute() public pure returns(string memory) {\n \n require(false, \"forced revert\");\n return \"foo\";\n }\n}","line":12,"range":[191,222]},"message":{"value":{"type":"Buffer","data":[8,195,121,160,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,13,102,111,114,99,101,100,32,114,101,118,101,114,116,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]},"_selector":"08c379a0"},"isInvalidOpcodeError":false}]}, data="0x", code=CALL_EXCEPTION, version=providers/5.6.2)
at Logger.makeError (node_modules/@ethersproject/logger/src.ts/index.ts:261:28)
at Logger.throwError (node_modules/@ethersproject/logger/src.ts/index.ts:273:20)
at checkError (node_modules/@ethersproject/providers/src.ts/json-rpc-provider.ts:60:16)
at EthersProviderWrapper.<anonymous> (node_modules/@ethersproject/providers/src.ts/json-rpc-provider.ts:590:20)
at step (node_modules/@ethersproject/providers/lib/json-rpc-provider.js:48:23)
at Object.throw (node_modules/@ethersproject/providers/lib/json-rpc-provider.js:29:53)
at rejected (node_modules/@ethersproject/providers/lib/json-rpc-provider.js:21:65)
Environment
node.js (v12 or newer), Hardhat
Environment (Other)
No response
Issue Analytics
- State:
- Created a year ago
- Comments:5 (1 by maintainers)
Top Results From Across the Web
c# Trying to reverse a list - Stack Overflow
Try: NavItems.Reverse(); return NavItems;. List<T>.Reverse() is an in-place reverse; it doesn't return a new list.
Read more >OOP Inheritance & Polymorphism - Java Programming Tutorial
A toString() method that returns a string description of this instance in the format of " Circle[center=(x,y),radius=r] ". You should re-use the Point...
Read more >Different Methods to Reverse a String in C++ - GeeksforGeeks
Different Methods to Reverse a String in C++ are: Making our own reverse function; Using 'inbuilt' reverse function; Using Constructor ...
Read more >How to Reverse a Number in Java - Javatpoint
Reverse a number using while loop ; public class ReverseNumberExample1 ; public static void main(String[] args) ; int number = 987654, reverse =...
Read more >Know How to Reverse A String In Java – A Beginners Guide
The main task of the CharAt() method is to return the character at the specified index in the given String. Then, I have...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
It’s not yet released on hardhat (please see https://github.com/ethers-io/ethers.js/discussions/2849#discussioncomment-2640553).
@ricmoo Any word on this?