smock icon indicating copy to clipboard operation
smock copied to clipboard

Can't create fakes of abstract contracts after upgrading to hardhat-ethers v2.1.1

Open kkirka opened this issue 1 year ago • 2 comments

Describe the bug After upgrading hardhat-ethers to 2.1.1, I can't create fake contracts based on abstract contracts or interfaces.

Smock calls hardhat.ethers.getContractAt(contractName, "0x00…000"); to get an interface of a contract: https://github.com/defi-wonderland/smock/blob/91a7aadf0cfa14ba52edb98c15fa0d38562fef39/src/factories/ethers-interface.ts#L50

However, starting from @nomiclabs/hardhat-ethers v2.1.1 getContractAt throws an error if the on-chain code at the address is "0x".

Reproduction steps @nomiclabs/hardhat-ethers@^2.1.1

contracts/Foo.sol

/* ... */
interface Foo {
  function foo() external returns (uint);
} 

tests/bar.ts

/* ... */
const foo = await smock.fake<Foo>("Foo");
/* ... */

Expected behavior No error

Actual behavior

Error: unable to generate smock spec from contract name.
0x0000000000000000000000000000000000000000 is not a contract account.

System Specs:

  • OS: any
  • Package Version (or commit hash): 2.2.0

kkirka avatar Aug 24 '22 06:08 kkirka