Open fvictorio opened 1 year ago
Has it been solved/fixed? I am having similar issue right now.
It's kind of blocked by https://github.com/ethers-io/ethers.js/issues/3038, but we might fix it on our side if that issue takes too long to be solved. The problem is that the easiest fix on our side is technically a small breaking change, so we'd rather have this fixed in ethers itself.
This is the main issue for a recurring problem related to static calls from ethers.js to Hardhat that revert without return data (for example, by hitting a
require(false)
).Reproduction
Deploy this contract in Hardhat:
and call
foo.callStatic.f()
. This should throw an error, but it doesn't.The reason is that the plain RPC response from Hardhat is this:
The
"data": "0x"
part causes ethers to not throw. I reported this in the ethers.js repo six months ago (https://github.com/ethers-io/ethers.js/issues/3038) and assumed it would be fixed, but it hasn't yet.For reference, this does work in geth. The raw response for the same call is:
Decision to make
Our options are:
data
field if it's empty. This is technically a breaking change, but I think it's better than ethers not working correctly for these scenarios.EthersProviderWrapper
in thehardhat-ethers
plugin to somehow intercepteth_call
responses and remove thedata
field if it's0x
. I gave this a quick try to see if it was possible but it wasn't immediately obvious how to do it.To-do
hardhat-ethers
hardhat-chai-matchers
tests that we disabled because of this issue