Closed kkirka closed 1 year ago
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
hardhat.ethers.getContractAt(contractName, "0x00…000");
However, starting from @nomiclabs/hardhat-ethers v2.1.1 getContractAt throws an error if the on-chain code at the address is "0x".
getContractAt
Reproduction steps @nomiclabs/hardhat-ethers@^2.1.1
@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:
The related hardhat PR: https://github.com/NomicFoundation/hardhat/pull/2916
It looks like this issue have been fixed on their end.
https://github.com/NomicFoundation/hardhat/pull/3301
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#L50However, 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
tests/bar.ts
Expected behavior No error
Actual behavior
System Specs: