Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
kkirka opened this issue Aug 24, 2022 · 2 comments

Comments

@kkirka
Copy link

kkirka commented Aug 24, 2022

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:

return (await (hre as any).ethers.getContractAt(contractNameOrFullyQualifiedName, ethers.constants.AddressZero)).interface;

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
Copy link
Author

kkirka commented Aug 24, 2022

The related hardhat PR: NomicFoundation/hardhat#2916

@opticlab
Copy link

It looks like this issue have been fixed on their end.

NomicFoundation/hardhat#3301

@kkirka kkirka closed this as completed Jul 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants