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

[WIP] Chore: use hardhat deploy #53

Closed
wants to merge 19 commits into from
Closed

Conversation

fabianschu
Copy link
Contributor

@fabianschu fabianschu commented Jul 15, 2021

What's new?

  • instead of using custom deploy scripts, we use hardhat-deploy:
    • there is a new folder deploy that contains the deployment scripts
    • in order to deploy to rinkeby, one would have to run npx hardhat deploy --network rinkeby, for mainnet npx hardhat deploy --network mainnet
    • more infos about the plugin here
    • additional benefit: contracts are automatically deployed before running tests
  • instead of using custom scripts to interact with contracts we use hardhat tasks:
    • a task can be run via the CLI
    • check out npx hardhat to see all available tasks with their descriptions
    • if you run a task you need to specify the network where you want to run it, e.g. npx hardhat --network rinkeby changeOwner --address <some_address> runs the changeOwner task on rinkeby to change the owner address of SeedFactory
    • per default the signer is the first account (accounts[0] / root ). this can be changed.
    • more infos about tasks here
  • added hardhat-deploy-ethers which gives access to the getContract method which lets you easily instantiate contracts -> Caveat is that there currently is an issue when it's used together with hardhat-waffle. So, I deleted hardhat-waffle. For that reason the tests need to be slightly adapted (see todos)

Todo:

  • tasks involving gnosis api are not yet complete / working -> need to be finished
  • adapt existing tests to the new deployment logic
  • adapt existing tests to the missing hardhat-waffle dependency: this is easy, the following lines need to be added to the top of all spec files until there is a fix for the issue:
  const {expect, use} = require("chai");
  const {solidity} = require("ethereum-waffle");
  use(solidity);
  • write new tests for tasks? dunno

closes #50

@fabianschu fabianschu added the WIP work in progress label Jul 15, 2021
@fabianschu
Copy link
Contributor Author

Some more infos on hardhar-deploy:
If you deploy via hardhat-deploy it generates deployment files in the deployments folder. If you later on interact with contracts, e.g. via tasks, hardhat uses these deploymemt information to interact with the correct network and addresses. You can add historical deployments manually by adding the corresponding JSON files (these contain the contracts' addresses and abis).

@fabianschu
Copy link
Contributor Author

I miiight have become slightly obsessed with refactoring existing tests to make use of hardhat deploy scripts. However, I came to the conclusion that this is not really necessary. I wouldn't wan't to remove all commits, since at some point they could still be helpful (as inspiration), but I would like to close this branch. I created a new branch, where I went back to a previous commit (before all the refactoring). All tests are green there, but the original test-init.js script is still used. I think I would leave the tests like this for now. Please find the new branch here.

@fabianschu fabianschu closed this Jul 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
WIP work in progress
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Make scripts network agnostic
1 participant