-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #42 from code-423n4/feature/simProposal
Add script for simulating an existing proposal
- Loading branch information
Showing
15 changed files
with
123 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import {HardhatRuntimeEnvironment} from 'hardhat/types'; | ||
import {getPolygonContracts, getForkParams} from '../../shared/Forking'; | ||
import {createAndExecuteProposal} from '../../shared/Governance'; | ||
|
||
export async function simulateExistingProposal(proposalId: string, hre: HardhatRuntimeEnvironment) { | ||
const [user] = await hre.ethers.getSigners(); | ||
const deployment = getPolygonContracts(user); | ||
|
||
// attempt mainnet forking | ||
await hre.network.provider.request({ | ||
method: 'hardhat_reset', | ||
params: [getForkParams()], | ||
}); | ||
|
||
const proposalActions = await deployment.governor.getActions(proposalId); | ||
let valuesArray = proposalActions[1].map((value) => value.toString()); | ||
console.log(`proposal targets: ${proposalActions.targets}`); | ||
console.log(`proposal values: ${valuesArray}`); | ||
console.log(`proposal calldatas: ${proposalActions.calldatas}`); | ||
console.log(`cloning proposal...`); | ||
await createAndExecuteProposal({ | ||
user, | ||
targets: proposalActions.targets, | ||
values: valuesArray, | ||
calldatas: proposalActions.calldatas, | ||
...deployment, | ||
}); | ||
} |
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import fetch from 'node-fetch'; | ||
|
||
export async function getABIFromPolygonscan(address: string) { | ||
if (process.env.POLYGONSCAN_API_KEY == undefined) { | ||
console.log('Require polygonscan key, exiting...'); | ||
process.exit(1); | ||
} | ||
|
||
let abiRequest = await fetch( | ||
`https://api.polygonscan.com/api?module=contract&action=getabi` + | ||
`&address=${address}` + | ||
`&apikey=${process.env.POLYGONSCAN_API_KEY}` | ||
); | ||
let abi = await abiRequest.json(); | ||
if (abi.status == '0') { | ||
console.log(abi.result); | ||
process.exit(1); | ||
} | ||
return abi.result; | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters