Skip to content

Instantly share code, notes, and snippets.

@PJColombo
Last active September 13, 2021 22:24
Show Gist options
  • Save PJColombo/4d4536b87fbae6beece427f0d7de8bb9 to your computer and use it in GitHub Desktop.
Save PJColombo/4d4536b87fbae6beece427f0d7de8bb9 to your computer and use it in GitHub Desktop.
Disputable Voting and Tollgate installation
import { ethers } from "hardhat";
import { EVMcrispr, toDecimals } from "@commonsswarm/evmcrispr"
async function main() {
const signer = (await ethers.getSigners())[0];
const evmcrispr = await EVMcrispr.create(signer, gardensDAOAddress);
const encodedAction = await evmcrispr.encode(
[
evmcrispr.installNewApp("tollgate.open:new", [
"0xc7ad46e0b8a400bb3c915120d284aafba8fc4735", // fee token (DAI)
toDecimals(1), // fee amount
"0xc125218F4Df091eE40624784caF7F47B9738086f", // fee recipient
]),
evmcrispr.addPermissions(
[
[evmcrispr.ANY_ENTITY, "tollgate.open:new", "CHANGE_DESTINATION_ROLE"],
[evmcrispr.ANY_ENTITY, "tollgate.open:new", "CHANGE_AMOUNT_ROLE"],
],
"voting"
),
evmcrispr.installNewApp("disputable-voting.open:new-app", [
"0x1b00535443885342c903d009676e5fbda867c4bb", // token manager token
3600, // vote duration
toDecimals(0.02), // min. support required (in percentage)
toDecimals(0.01), // min. quorum required (in percentage)
1800, // delegated voting period
900, // quite ending period
900, // quite ending extension
900, // execution delay
]),
evmcrispr.addPermission([evmcrispr.ANY_ENTITY, "disputable-voting.open", "CREATE_VOTES_ROLE"], "voting"),
],
["token-manager", "voting"]
);
const txReceipt = await (
await signer.sendTransaction({
...encodedAction.action,
gasLimit: TX_GAS_LIMIT,
gasPrice: TX_GAS_PRICE,
})
).wait();
console.log(txReceipt.transactionHash);
}
main()
.then(() => process.exit(0))
.catch((error) => {
spinner.fail();
console.error(error);
process.exit(1);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment