Skip to content

Commit

Permalink
Merge pull request MolochVentures#97 from daoeducation/hardhat
Browse files Browse the repository at this point in the history
Fixed tests and updated README file.
  • Loading branch information
Rahul Sethuram authored Dec 18, 2020
2 parents 762e579 + 3eb843d commit 4e786db
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 29 deletions.
36 changes: 18 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,42 +53,42 @@ To compute their code coverage run `npm run coverage`.

## Deploying an interacting with a Moloch DAO and a Pool

This project includes Buidler tasks for deploying and using DAOs and Pools.
This project includes Hardhat tasks for deploying and using DAOs and Pools.

#### Deploying a new DAO

Follow this instructions to deploy a new DAO:

1. Edit `buidler.config.js`, setting the values for `INFURA_API_KEY` and `MAINNET_PRIVATE_KEY`.
1. Edit `hardhat.config.js`, setting the values for `INFURA_API_KEY` and `MAINNET_PRIVATE_KEY`.
2. Edit `deployment-params.js`, setting your desired deployment parameters.
3. Run `npx buidler moloch-deploy --network mainnet`
4. Edit `buidler.config.js`, setting the address of the DAO in `networks.mainnet.deployedContracts.moloch`.
3. Run `npx hardhat moloch-deploy --network mainnet`
4. Edit `hardhat.config.js`, setting the address of the DAO in `networks.mainnet.deployedContracts.moloch`.

#### Deploying a new Pool

Follow this instructions to deploy a new Pool:

1. Edit `buidler.config.js`, setting the values for `INFURA_API_KEY` and `MAINNET_PRIVATE_KEY`.
2. Make sure you have the right address in `buidler.config.js`'s `networks.mainnet.deployedContracts.moloch` field.
3. Run `npx buidler pool-deploy --network mainnet --shares <shares> --tokens <tokens>` with the initial amount of tokens you want to donate to the pool, and how many shares you want in return.
1. Edit `hardhat.config.js`, setting the values for `INFURA_API_KEY` and `MAINNET_PRIVATE_KEY`.
2. Make sure you have the right address in `hardhat.config.js`'s `networks.mainnet.deployedContracts.moloch` field.
3. Run `npx hardhat pool-deploy --network mainnet --shares <shares> --tokens <tokens>` with the initial amount of tokens you want to donate to the pool, and how many shares you want in return.

### Interacting with the smart contracts

This project has tasks to work with DAOs and Pools. To use them, you should first follow this instructions:

1. Edit `buidler.config.js`, setting the values for `INFURA_API_KEY` and `MAINNET_PRIVATE_KEY`.
2. Make sure you have the right address in `buidler.config.js`'s `networks.mainnet.deployedContracts.moloch` field.
3. If you want to use a Pool, make sure you have the right address in `buidler.config.js`'s `networks.mainnet.deployedContracts.pool` field.
1. Edit `hardhat.config.js`, setting the values for `INFURA_API_KEY` and `MAINNET_PRIVATE_KEY`.
2. Make sure you have the right address in `hardhat.config.js`'s `networks.mainnet.deployedContracts.moloch` field.
3. If you want to use a Pool, make sure you have the right address in `hardhat.config.js`'s `networks.mainnet.deployedContracts.pool` field.

After following those instructions, you can run `npx buidler` to get a list with all the tasks:
After following those instructions, you can run `npx hardhat` to get a list with all the tasks:

```
$ npx buidler
$ npx hardhat
AVAILABLE TASKS:
clean Clears the cache and deletes all artifacts
compile Compiles the entire project, building all artifacts
console Opens a buidler console
console Opens a hardhat console
flatten Flattens and prints all contracts and their dependencies
help Prints this message
moloch-deploy Deploys a new instance of the Moloch DAO
Expand All @@ -109,13 +109,13 @@ AVAILABLE TASKS:
```


You can run `npx buidler help <task>` to get help about each tasks and their parameters. For example:
You can run `npx hardhat help <task>` to get help about each tasks and their parameters. For example:

```
$ npx buidler help moloch-submit-proposal
Buidler version 1.0.0-beta.7
$ npx hardhat help moloch-submit-proposal
hardhat version 2.0.0
Usage: buidler [GLOBAL OPTIONS] moloch-submit-proposal --applicant <STRING> --details <STRING> --shares <STRING> --tribute <STRING>
Usage: hardhat [GLOBAL OPTIONS] moloch-submit-proposal --applicant <STRING> --details <STRING> --shares <STRING> --tribute <STRING>
OPTIONS:
Expand All @@ -126,7 +126,7 @@ OPTIONS:
moloch-submit-proposal: Submits a proposal
For global options help run: buidler help
For global options help run: hardhat help
```

# Changelog v2
Expand Down
9 changes: 9 additions & 0 deletions contracts/Token.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
pragma solidity ^0.5.2;

import "./ERC20.sol";

contract Token is ERC20 {
constructor(uint256 supply) public {
_mint(msg.sender, supply);
}
}
6 changes: 3 additions & 3 deletions hardhat.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ module.exports = {
pool: ""
}
},
ropsten: {
/* ropsten: {
url: `https://ropsten.infura.io/v3/${INFURA_API_KEY}`,
accounts: [ROPSTEN_PRIVATE_KEY],
deployedContracts: {
Expand All @@ -35,12 +35,12 @@ module.exports = {
moloch: "0x1fd169A4f5c59ACf79d0Fd5d91D1201EF1Bce9f1", // The original Moloch
pool: ""
}
},
}, */
coverage: {
url: "http://localhost:8555"
}
},
solc: {
solidity: {
version: "0.5.3",
settings: {
optimizer: {
Expand Down
2 changes: 1 addition & 1 deletion scripts/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -54,5 +54,5 @@ echo "Hardhat version $(npx hardhat --version)"
if [ "$SOLIDITY_COVERAGE" = true ]; then
node_modules/.bin/solidity-coverage
else
npx hardhat test --network develop "$@"
npx hardhat test
fi
10 changes: 5 additions & 5 deletions test/molochV2-multitoken.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { artifacts, ethereum, web3 } = require('@nomiclabs/hardhat')
const { artifacts, network, web3 } = require('hardhat')
const chai = require('chai')
const { assert } = chai

Expand Down Expand Up @@ -54,15 +54,15 @@ async function blockTime () {
}

async function snapshot () {
return ethereum.send('evm_snapshot', [])
return network.provider.send('evm_snapshot', [])
}

async function restore (snapshotId) {
return ethereum.send('evm_revert', [snapshotId])
return network.provider.send('evm_revert', [snapshotId])
}

async function forceMine () {
return ethereum.send('evm_mine', [])
return network.provider.send('evm_mine', [])
}

const deploymentConfig = {
Expand All @@ -78,7 +78,7 @@ const deploymentConfig = {
async function moveForwardPeriods (periods) {
await blockTime()
const goToTime = deploymentConfig.PERIOD_DURATION_IN_SECONDS * periods
await ethereum.send('evm_increaseTime', [goToTime])
await network.provider.send('evm_increaseTime', [goToTime])
await forceMine()
await blockTime()
return true
Expand Down
2 changes: 1 addition & 1 deletion test/molochV2.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { artifacts, ethereum, web3 } = require('@nomiclabs/hardhat')
const { artifacts, ethereum, web3 } = require('hardhat')
const chai = require('chai')
const { assert } = chai

Expand Down
2 changes: 1 addition & 1 deletion test/molochV2Events.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { artifacts, ethereum, web3 } = require('@nomiclabs/hardhat')
const { artifacts, ethereum, web3 } = require('hardhat')
const chai = require('chai')
const { assert } = chai

Expand Down

0 comments on commit 4e786db

Please sign in to comment.