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

wait() after a deployment didn't work #4093

Closed
FournyP opened this issue Jun 30, 2023 · 5 comments
Closed

wait() after a deployment didn't work #4093

FournyP opened this issue Jun 30, 2023 · 5 comments
Labels
area:hardhat-ethers blocked-reason:needs-ethers-support status:blocked Blocked by other issues or external reasons type:bug Something isn't working

Comments

@FournyP
Copy link
Contributor

FournyP commented Jun 30, 2023

Version of Hardhat

2.15.0

What happened?

Durring a task to deploy on mumbai testnet, I want to wait for 5 or 20 transactions before to run the verify task.

But it's seem that the wait function doesn't work.
I've try to put 100 in the wait function but the programm pass directly to the next steps...

My dependencies :

"dependencies": {
    "@nomicfoundation/hardhat-toolbox": "^3.0.0",
    "@openzeppelin/contracts": "^4.9.1"
  },
  "devDependencies": {
    "@nomicfoundation/hardhat-chai-matchers": "2.0.1",
    "@nomicfoundation/hardhat-ethers": "3.0.2",
    "@nomicfoundation/hardhat-network-helpers": "1.0.8",
    "@nomicfoundation/hardhat-verify": "1.0.2",
    "@nomiclabs/hardhat-etherscan": "^3.1.7",
    "@typechain/ethers-v6": "0.4.0",
    "@typechain/hardhat": "8.0.0",
    "@types/chai": "^4.3.5",
    "@types/mocha": "^10.0.1",
    "chai": "4.2.0",
    "dotenv": "^16.1.4",
    "ethers": "^6.6.0",
    "hardhat": "^2.15.0",
    "hardhat-gas-reporter": "1.0.8",
    "mocha": "^10.2.0",
    "solidity-coverage": "0.8.1",
    "ts-node": "^10.9.1",
    "typechain": "8.2.0",
    "typescript": "^5.1.3"
  }

I've check the wait function and I found that the confirms param is not used :
image

Maybe by passing the argument to the super function it will work ? I've never really use classes in TS

Minimal reproduction steps

Write a task to deploy on the mumbai network like this :

import { task } from "hardhat/config";

...

task("deploy-collection-generator")
  .setAction(async (taskArgs, hre) => {
    const CollectionGenerator = await hre.ethers.getContractFactory(
      "CollectionGenerator"
    );
    const collectionGenerator = await CollectionGenerator.deploy();
    await collectionGenerator.waitForDeployment();

    let collectionGeneratorAddress = await collectionGenerator.getAddress();

    console.log("CollectionGenerator deployed to:", collectionGeneratorAddress);

    let res = await collectionGenerator.deploymentTransaction()?.wait(20);

    console.log(res);

    await hre.run("verify:verify", {
      address: collectionGeneratorAddress,
      constructorArguments: [controller6022Address, wETHAddress],
    });
  });

The res variable will be display a millisecond after the collection address. To my opinions, it didn't wait

As a result, I got the following error from the verify task :
image

Thanks for this librarie, it's awesome

Have a good day ;)

Search terms

wait deploy deployement hardhat

@FournyP
Copy link
Contributor Author

FournyP commented Jun 30, 2023

For the moment, to bypass the issue, i've write something like this :

// Wait for 5 blocks
let currentBlock = await hre.ethers.provider.getBlockNumber();
while (currentBlock + 5 > (await hre.ethers.provider.getBlockNumber())) {}

And it's work perfectly, the verify task work

@fvictorio
Copy link
Member

Confirmed, thanks. I'll work on this asap.

@fvictorio fvictorio added type:bug Something isn't working status:ready This issue is ready to be worked on area:hardhat-ethers and removed status:triaging labels Jul 3, 2023
@fvictorio fvictorio self-assigned this Jul 5, 2023
@fvictorio
Copy link
Member

Hi @FournyP, I took another look into this and apparently this is an upstream bug in ethers. I opened an issue about it: ethers-io/ethers.js#4212

I'm going to mark this issue as blocked and close it after ethers releases a fix for that.

@fvictorio fvictorio added status:blocked Blocked by other issues or external reasons blocked-reason:needs-ethers-support and removed status:ready This issue is ready to be worked on labels Jul 5, 2023
@fvictorio
Copy link
Member

In the meantime, this workaround might be useful:

const deploymentTx = contract.deploymentTransaction();

await provider.waitForTransaction(deploymentTx.hash, 3);

@fvictorio
Copy link
Member

This is working now with ethers@6.6.4.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 16, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area:hardhat-ethers blocked-reason:needs-ethers-support status:blocked Blocked by other issues or external reasons type:bug Something isn't working
Projects
Archived in project
Development

No branches or pull requests

2 participants