@@ -2,7 +2,6 @@ import {Signer} from 'ethers';
22import { ethers } from 'hardhat' ;
33import { impersonateAccountWithFunds , stopImpersonateAccount } from './AccountManipulation' ;
44import { increaseNextBlockTime , setNextBlockNumber } from './TimeManipulation' ;
5- import { POLYGON_AVERAGE_BLOCK_TIME } from './Constants' ;
65import { DeployedContracts } from './Forking' ;
76import { getABIFromPolygonscan } from './Polygonscan' ;
87
@@ -20,21 +19,14 @@ export const createAndExecuteProposal = async ({
2019 values : string [ ] ;
2120 calldatas : string [ ] ;
2221} & DeployedContracts ) => {
23- // 0. set voting delay & duration to 2 blocks, otherwise need to simulate 302,400 blocks
2422 const timeLockSigner = await impersonateAccountWithFunds ( timeLock . address ) ;
25- let originalVotingDelay = await governor . votingDelay ( ) ;
26- let originalVotingPeriod = await governor . votingPeriod ( ) ;
27- console . log ( 'setting voting delay and duration to 2 blocks...' ) ;
28- await governor . connect ( timeLockSigner ) . setVotingDelay ( `2` ) ;
29- await governor . connect ( timeLockSigner ) . setVotingPeriod ( `2` ) ;
3023
3124 // 1. borrow some treasury tokens to user as we need signer with min. proposalThreshold tokens to propose
3225 const quorumAmount = await governor . quorumVotes ( ) ;
3326 // careful, this sends ETH to timelock which might break real-world simulation for proposals involving Timelock ETH
3427 console . log ( 'transferring tokens to user for proposal creation...' ) ;
3528 await arenaToken . connect ( timeLockSigner ) . transfer ( await user . getAddress ( ) , quorumAmount ) ;
3629 await arenaToken . connect ( user ) . delegate ( await user . getAddress ( ) ) ;
37- const descriptionHash = ethers . utils . keccak256 ( [ ] ) ; // keccak(``)
3830 console . log ( 'creating proposal...' ) ;
3931 let tx = await governor . connect ( user ) [ 'propose(address[],uint256[],bytes[],string)' ] ( targets , values , calldatas , `` ) ;
4032 let { events} = await tx . wait ( ) ;
@@ -43,9 +35,8 @@ export const createAndExecuteProposal = async ({
4335
4436 // 2. advance time past voting delay and vote on proposal
4537 const voteStartBlock = await governor . proposalSnapshot ( proposalId ) ;
46- // simulate elapsed time close to original voting delay
47- await increaseNextBlockTime ( Math . floor ( POLYGON_AVERAGE_BLOCK_TIME * originalVotingDelay . toNumber ( ) ) ) ;
48- await setNextBlockNumber ( voteStartBlock . toNumber ( ) + 1 ) ; // is a blocknumber which fits in Number
38+ // simulate to voteStartBlock
39+ await setNextBlockNumber ( voteStartBlock . toNumber ( ) ) ;
4940 console . log ( 'casting vote...' ) ;
5041 tx = await governor . connect ( user ) [ 'castVote' ] ( proposalId , `1` ) ;
5142
@@ -54,17 +45,12 @@ export const createAndExecuteProposal = async ({
5445
5546 // 4. advance time past voting period and queue proposal calls to Timelock via GovernorTimelockControl.queue
5647 const voteEndBlock = await governor . proposalDeadline ( proposalId ) ;
57- // simulate elapsed time close to original voting delay
58- await increaseNextBlockTime ( Math . floor ( POLYGON_AVERAGE_BLOCK_TIME * originalVotingPeriod . toNumber ( ) ) ) ;
59- await setNextBlockNumber ( voteEndBlock . toNumber ( ) + 1 ) ; // is a blocknumber which fits in Number
48+ // simulate to voteEndBlock + 1
49+ await setNextBlockNumber ( voteEndBlock . toNumber ( ) + 1 ) ;
6050 console . log ( 'queueing proposal...' ) ;
6151 tx = await governor . connect ( user ) [ 'queue(uint256)' ] ( proposalId ) ;
6252 await tx . wait ( ) ;
6353
64- // can revert Governor changes now
65- console . log ( 'resetting voting delay and period...' ) ;
66- await governor . connect ( timeLockSigner ) . setVotingDelay ( originalVotingDelay ) ;
67- await governor . connect ( timeLockSigner ) . setVotingPeriod ( originalVotingPeriod ) ;
6854 await stopImpersonateAccount ( timeLock . address ) ;
6955
7056 // 5. advance time past timelock delay and then execute
0 commit comments