Skip to content

Commit

Permalink
customize votes
Browse files Browse the repository at this point in the history
  • Loading branch information
andresaiello committed Oct 29, 2024
1 parent 6893ead commit 3bb698d
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 5 deletions.
15 changes: 14 additions & 1 deletion packages/zevm-app-contracts/contracts/xp-nft/ZetaXPGov.sol
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ contract ZetaXPGov is Governor, GovernorSettings, GovernorCountingSimple, Govern
) internal view override returns (uint256) {
uint256 tokenId = xpNFT.tokenByUserTag(account, tagValidToVote);
uint256 level = xpNFT.getLevel(tokenId);
require(level > 0, "ZetaXPGov: invalid NFT level");

// Assign voting weight based on NFT level
if (level == 1) {
Expand Down Expand Up @@ -119,4 +118,18 @@ contract ZetaXPGov is Governor, GovernorSettings, GovernorCountingSimple, Govern
function _executor() internal view override(Governor, GovernorTimelockControl) returns (address) {
return super._executor();
}

function _castVote(
uint256 proposalId,
address account,
uint8 support,
string memory reason,
bytes memory params
) internal override returns (uint256) {
uint256 tokenId = xpNFT.tokenByUserTag(account, tagValidToVote);
uint256 level = xpNFT.getLevel(tokenId);
require(level > 0, "ZetaXPGov: invalid NFT level");

return super._castVote(proposalId, account, support, reason, params);
}
}
4 changes: 2 additions & 2 deletions packages/zevm-app-contracts/data/addresses.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
"ZetaXP": "0x5c25b6f4D2b7a550a80561d3Bf274C953aC8be7d",
"InstantRewards": "0x10DfEd4ba9b8F6a1c998E829FfC0325D533c80E3",
"ProofOfLiveness": "0x981EB6fD19717Faf293Fba0cBD05C6Ac97b8C808",
"TimelockController": "0x26F16EB99F195F1f401b0Afcafa2FEbb9427CE09",
"ZetaXPGov": "0x7B01E3060B9aAb92E3b981DB699330bB582a53C0"
"TimelockController": "0x75C2C7dD9f8Fe9f7B303570Db164504106D019F5",
"ZetaXPGov": "0xCA95803a99000863D935D3aA86a1a7F190F06D0a"
},
"zeta_mainnet": {
"disperse": "0x23ce409Ea60c3d75827d04D9db3d52F3af62e44d",
Expand Down
6 changes: 4 additions & 2 deletions packages/zevm-app-contracts/scripts/xp-nft/deploy-gov.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import { ethers, network } from "hardhat";
import { getZEVMAppAddress, saveAddress } from "../address.helpers";
import { verifyContract } from "../explorer.helpers";

const QUANTUM_PERCENTAGE = 4;

const networkName = network.name;

const encodeTag = (tag: string) => ethers.utils.keccak256(ethers.utils.defaultAbiCoder.encode(["string"], [tag]));
Expand Down Expand Up @@ -40,12 +42,12 @@ const deployXPGov = async () => {

// Deploy the ZetaXPGov contract
const ZetaXPGovFactory = await ethers.getContractFactory("ZetaXPGov");
const zetaGov = await ZetaXPGovFactory.deploy(zetaXPAddress, timelockAddress, 4, tag);
const zetaGov = await ZetaXPGovFactory.deploy(zetaXPAddress, timelockAddress, QUANTUM_PERCENTAGE, tag);
await zetaGov.deployed();

const zetaGovAddress = zetaGov.address;

executeVerifyContract("ZetaXPGov", zetaGovAddress, [zetaXPAddress, timelockAddress, 4, tag]);
executeVerifyContract("ZetaXPGov", zetaGovAddress, [zetaXPAddress, timelockAddress, QUANTUM_PERCENTAGE, tag]);

// Assign proposer and executor roles to the signer
const proposerRole = await timelock.PROPOSER_ROLE();
Expand Down

0 comments on commit 3bb698d

Please sign in to comment.