Skip to content

Commit

Permalink
Merge pull request #23 from Snowfork/review
Browse files Browse the repository at this point in the history
Minor fixes/README/script improvements during review
  • Loading branch information
musnit authored May 5, 2021
2 parents a2417b6 + 4ca9f91 commit a13d3fa
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 31 deletions.
16 changes: 11 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@ npm install

### Create secrets file

A sample secrets file is provided, make a copy of it and replace with your project secrets.
A sample secrets file is provided, make a copy of it and replace with your project secrets.

```bash
cp './secrets-example.js' './secrets.js'
```

### Start a Local Instance
### Start a Local Instance

```bash
npx hardhat node
Expand Down Expand Up @@ -70,6 +70,7 @@ npx hardhat run --network ropsten deploy --reset

## Sample proposals

### Creating a new proposal
`sample-proposals` directory contains few examples of how to create proposals. Below is one such example of creating proposal.

#### **`proposal.json`**
Expand All @@ -86,7 +87,12 @@ npx hardhat run --network ropsten deploy --reset
}
```

Create above proposal by running following script
Create a copy of the sample, modify the json as needed, and then create the proposal by running following script:
```bash
HARDHAT_NETWORK=ropsten PRIVATE_KEY=your-key node ./createNewProposal.js ./proposal.json
```
HARDHAT_NETWORK=ropsten PRIVATE_KEY=your-key node ./scripts/createNewProposal.js ../modified-proposal.json
```

### Cancelling a proposal
```bash
HARDHAT_NETWORK=ropsten PRIVATE_KEY=your-key node ./scripts/cancelProposal.js PROPOSAL_ID
```
26 changes: 0 additions & 26 deletions createNewProposal.js

This file was deleted.

3 changes: 3 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 21 additions & 0 deletions scripts/cancelProposal.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
const network = process.env.HARDHAT_NETWORK
const hre = require("hardhat");
const ethers = hre.ethers;
const GovernorAlpha = require(`../deployments/${network}/GovernorAlpha.json`)
const proposalID = process.argv[2]

async function main() {
const provider = ethers.providers.getDefaultProvider(network);
const wallet = new ethers.Wallet(process.env.PRIVATE_KEY, provider);
const contract = new ethers.Contract(GovernorAlpha.address, GovernorAlpha.abi, wallet);

const tx = await contract.cancel(proposalID)
console.log("Transaction hash: ", tx.hash)
}

main()
.then(() => process.exit(0))
.catch(error => {
console.error(error);
process.exit(1);
});
23 changes: 23 additions & 0 deletions scripts/createNewProposal.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
const network = process.env.HARDHAT_NETWORK
const hre = require("hardhat");
const ethers = hre.ethers;
const GovernorAlpha = require(`../deployments/${network}/GovernorAlpha.json`)
const { encodeParameters } = require('../test/Utils/Ethereum');
const proposal = require(process.argv[2])

async function main() {
callDatas = [encodeParameters(proposal.parameters.types, proposal.parameters.values)]
const provider = ethers.providers.getDefaultProvider(network);
const wallet = new ethers.Wallet(process.env.PRIVATE_KEY, provider);
const contract = new ethers.Contract(GovernorAlpha.address, GovernorAlpha.abi, wallet);

const tx = await contract.propose(proposal.targets, proposal.values, proposal.signatures, callDatas, proposal.description, { gasPrice: 20000000000, gasLimit: 7600000 })
console.log("Transaction hash: ", tx.hash)
}

main()
.then(() => process.exit(0))
.catch(error => {
console.error(error);
process.exit(1);
});

0 comments on commit a13d3fa

Please sign in to comment.