You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jan 15, 2024. It is now read-only.
const{ ethers, network }=require("hardhat");const{VOTING_DELAY,VOTING_PERIOD,PROPOSAL_DESCRIPTION,NEW_STORE_VALUE,FUNC,DEVELOPMENT_CHAINS,MIN_DELAY,QUORUM_PERCENTAGE,PROPOSAL_FILE,}=require("../globals");constfs=require("fs");letcaller;letdeployer;letgovernorAddress;letgovernorTokenAddress;lettimelockAddress;letboxAddress;letproposalIdString;constsetCaller=async()=>{constaccs=awaitethers.getSigners();caller=accs[0];deployer=accs[1];};constgetLatestBlock=async()=>{returnawaitethers.provider.getBlockNumber();};asyncfunctionmoveTime(amount){awaitnetwork.provider.send("evm_increaseTime",[amount]);console.log(`🕞 Moved forward in time ${amount} seconds`);}asyncfunctionmoveBlocks(amount){console.log("Moving blocks...");for(letindex=0;index<amount;index++){awaitnetwork.provider.request({method: "evm_mine",params: [],});}console.log(`Moved ${amount} blocks`);}constpropose=async(args,functionToCall,proposalDescription)=>{// Deploying governor token contract.constGovernorToken=awaitethers.getContractFactory("GovernanceToken");constgovernorToken=awaitGovernorToken.connect(deployer).deploy();governorTokenAddress=governorToken.address;// Deploying Timelock contract.constTimelock=awaitethers.getContractFactory("Timelock");consttimelock=awaitTimelock.connect(deployer).deploy(MIN_DELAY,[],[]);// Governor contract.constGovernor=awaitethers.getContractFactory("DAO");constgovernor=awaitGovernor.connect(deployer).deploy(governorToken.address,timelock.address,QUORUM_PERCENTAGE,VOTING_PERIOD,VOTING_DELAY);governorAddress=governor.address;// Giving governor the rights to propose something on the timelock contract.constproposerRole=awaittimelock.PROPOSER_ROLE();constexecutorRole=awaittimelock.EXECUTOR_ROLE();await(awaittimelock.grantRole(proposerRole,governor.address)).wait(1);await(awaittimelock.grantRole(executorRole,governor.address)).wait(1);// Box Contract.constBox=awaitethers.getContractFactory("Box");constbox=awaitBox.connect(deployer).deploy();boxAddress=box.address;constencodedFunctionCall=box.interface.encodeFunctionData(functionToCall,args);console.log(`Proposing ${functionToCall} on ${box.address} with ${args}`);console.log(`Proposal Description:\n ${proposalDescription}`);// Check the existing value in Box contract.console.log("Box :: Value: ",awaitbox.retrieve());constproposeTx=awaitgovernor.propose([box.address],[0],[encodedFunctionCall],proposalDescription);console.log("⛏ Block Number: ",awaitgetLatestBlock());if(DEVELOPMENT_CHAINS.includes(network.name)){console.log("Jumping blocks.");awaitmoveBlocks(VOTING_DELAY+1);}constproposeReciept=awaitproposeTx.wait(1);constproposalId=proposeReciept.events[0].args.proposalId;proposalIdString=proposalId;console.log(`Proposed with proposal ID:\n ${proposalId}`);constproposalState=awaitgovernor.state(proposalId);constproposalSnapShot=awaitgovernor.proposalSnapshot(proposalId);constproposalDeadline=awaitgovernor.proposalDeadline(proposalId);// save the proposalIdletproposals=JSON.parse(fs.readFileSync(PROPOSAL_FILE,"utf8"));console.log("Network Chain Id: ",network.config.chainId);proposals[network.config.chainId.toString()].push(proposalId.toString());fs.writeFileSync(PROPOSAL_FILE,JSON.stringify(proposals));// The state of the proposal. 1 is not passed. 0 is passed.console.log(`Current Proposal State: ${proposalState}`);// What block # the proposal was snapshotconsole.log(`Current Proposal Snapshot: ${proposalSnapShot}`);// The block number the proposal voting expiresconsole.log(`Current Proposal Deadline: ${proposalDeadline}`);console.log("⛏ Block Number: ",awaitgetLatestBlock());constlatestBlock=awaitgetLatestBlock();constpower=awaitgovernorToken.getVotes(deployer.address);console.log("💪🏻 Power: ",power);console.table([{name: "Caller",balance: awaitgovernorToken.balanceOf(caller.address)},{name: "Deployer",balance: awaitgovernorToken.balanceOf(deployer.address),},]);};constvote=async(proposalId,voteWay,reason)=>{console.log("⛏ Block Number: ",awaitgetLatestBlock());console.log("Voting started.");constGovernor=awaitethers.getContractFactory("DAO");console.log("Governor Address: ",governorAddress);constgovernor=awaitGovernor.attach(governorAddress);constGovernanceToken=awaitethers.getContractFactory("GovernanceToken");constgovernanceToken=awaitGovernanceToken.attach(governorTokenAddress);await(awaitgovernanceToken.connect(deployer).delegate(deployer.address)).wait(1);constvoteTx=awaitgovernor.connect(deployer).castVoteWithReason(proposalId,voteWay,reason);constvoteTx1=awaitgovernor.connect(caller).castVoteWithReason(proposalId,voteWay,reason);awaitvoteTx1.wait(1);constvoteTxReceipt=awaitvoteTx.wait(1);console.log(voteTxReceipt.events[0].args.reason);constproposalState=awaitgovernor.state(proposalId);constvoteBalance=awaitgovernanceToken.getVotes(deployer.address);console.log(`Vote Balance: ${voteBalance}`);console.log(`Current Proposal State: ${proposalState}`);if(DEVELOPMENT_CHAINS.includes(network.name)){console.log(`📦 Moving ${VOTING_PERIOD+1} blocks`);awaitmoveBlocks(VOTING_PERIOD+1);}// Logging the proposal state.console.log(`📝 State of proposal: ${awaitgovernor.state(proposalId)}`);console.log(`Proposal Votes:`,awaitgovernor.proposalVotes(proposalId));};constqueueAndExecute=async()=>{console.log("Block Number",awaitgetLatestBlock());console.log("🛳 Queue and Execute");constBox=awaitethers.getContractFactory("Box");constbox=Box.attach(boxAddress);constencodedFunctionCall=box.interface.encodeFunctionData(FUNC,[NEW_STORE_VALUE,]);constdescriptionHash=ethers.utils.keccak256(ethers.utils.toUtf8Bytes(PROPOSAL_DESCRIPTION));constGovernor=awaitethers.getContractFactory("DAO");constgovernor=awaitGovernor.attach(governorAddress);constqueueTx=awaitgovernor.queue([box.address],[0],[encodedFunctionCall],descriptionHash);awaitqueueTx.wait(1);};constmain=async()=>{awaitsetCaller();awaitpropose([NEW_STORE_VALUE],FUNC,PROPOSAL_DESCRIPTION);awaitvote(proposalIdString,1,"I like the proposal that's it.");awaitqueueAndExecute();};main().then(()=>process.exit(0)).catch((e)=>{console.error(e);process.exit(1);});
The text was updated successfully, but these errors were encountered:
Can someone tell me why this issue arises?
These are my tests
The text was updated successfully, but these errors were encountered: