Skip to content

Instantly share code, notes, and snippets.

@antojoseph
Last active November 8, 2023 14:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save antojoseph/77d6780e88e82ade04ffe0c7802867a0 to your computer and use it in GitHub Desktop.
Save antojoseph/77d6780e88e82ade04ffe0c7802867a0 to your computer and use it in GitHub Desktop.
Dedupe votes on Mainnet & Mantle
from web3 import Web3
import json
# Set up RPC providers for both chains
rpc_url = 'https://rpc.mantle.xyz/'
mainnet_rpc_url = 'https://rpc.ankr.com/eth'
# Initialize Web3 connections
web3 = Web3(Web3.HTTPProvider(rpc_url))
mainnet_web3 = Web3(Web3.HTTPProvider(mainnet_rpc_url))
# Contract addresses
contract_address = '0x471bb1b5bd70cff552f82a80797ea6253bac94e2'
mainnet_contract_address = '0xec17aaba6855461e0835a2113efa942f01fd5b39'
# Ensure addresses are checksummed
checksum_contract_address = web3.to_checksum_address(contract_address)
checksum_mainnet_contract_address = mainnet_web3.to_checksum_address(mainnet_contract_address)
# abi
jokerace_abi = json.loads('[{"inputs": [{"internalType": "string", "name": "_name", "type": "string"}, {"internalType": "string", "name": "_prompt", "type": "string"}, {"internalType": "bytes32", "name": "_submissionMerkleRoot", "type": "bytes32"}, {"internalType": "bytes32", "name": "_votingMerkleRoot", "type": "bytes32"}, {"internalType": "uint256", "name": "_costToPropose", "type": "uint256"}, {"internalType": "uint256", "name": "_percentageToCreator", "type": "uint256"}, {"internalType": "uint256[]", "name": "_constructorIntParams", "type": "uint256[]"}], "stateMutability": "nonpayable", "type": "constructor"}, {"inputs": [], "name": "InvalidShortString", "type": "error"}, {"inputs": [], "name": "NotInMerkle", "type": "error"}, {"inputs": [{"internalType": "string", "name": "str", "type": "string"}], "name": "StringTooLong", "type": "error"}, {"inputs": [], "name": "TooManyMetadatas", "type": "error"}, {"anonymous": false, "inputs": [], "name": "ContestCanceled", "type": "event"}, {"anonymous": false, "inputs": [{"indexed": false, "internalType": "uint256", "name": "oldContestStart", "type": "uint256"}, {"indexed": false, "internalType": "uint256", "name": "newContestStart", "type": "uint256"}], "name": "ContestStartSet", "type": "event"}, {"anonymous": false, "inputs": [{"indexed": false, "internalType": "address", "name": "oldCreator", "type": "address"}, {"indexed": false, "internalType": "address", "name": "newCreator", "type": "address"}], "name": "CreatorSet", "type": "event"}, {"anonymous": false, "inputs": [{"indexed": false, "internalType": "uint256", "name": "oldDownvotingAllowed", "type": "uint256"}, {"indexed": false, "internalType": "uint256", "name": "newDownvotingAllowed", "type": "uint256"}], "name": "DownvotingAllowedSet", "type": "event"}, {"anonymous": false, "inputs": [], "name": "EIP712DomainChanged", "type": "event"}, {"anonymous": false, "inputs": [{"indexed": false, "internalType": "string", "name": "name", "type": "string"}, {"indexed": false, "internalType": "address", "name": "creator", "type": "address"}], "name": "JokeraceCreated", "type": "event"}, {"anonymous": false, "inputs": [{"indexed": false, "internalType": "uint256", "name": "oldMaxProposalCount", "type": "uint256"}, {"indexed": false, "internalType": "uint256", "name": "newMaxProposalCount", "type": "uint256"}], "name": "MaxProposalCountSet", "type": "event"}, {"anonymous": false, "inputs": [{"indexed": false, "internalType": "uint256", "name": "oldNumAllowedProposalSubmissions", "type": "uint256"}, {"indexed": false, "internalType": "uint256", "name": "newNumAllowedProposalSubmissions", "type": "uint256"}], "name": "NumAllowedProposalSubmissionsSet", "type": "event"}, {"anonymous": false, "inputs": [{"indexed": false, "internalType": "contract RewardsModule", "name": "oldOfficialRewardsModule", "type": "address"}, {"indexed": false, "internalType": "contract RewardsModule", "name": "newOfficialRewardsModule", "type": "address"}], "name": "OfficialRewardsModuleSet", "type": "event"}, {"anonymous": false, "inputs": [{"indexed": false, "internalType": "address", "name": "to", "type": "address"}, {"indexed": false, "internalType": "uint256", "name": "amount", "type": "uint256"}], "name": "PaymentReleased", "type": "event"}, {"anonymous": false, "inputs": [{"indexed": false, "internalType": "uint256", "name": "proposalId", "type": "uint256"}, {"indexed": false, "internalType": "address", "name": "proposer", "type": "address"}], "name": "ProposalCreated", "type": "event"}, {"anonymous": false, "inputs": [{"indexed": false, "internalType": "uint256[]", "name": "proposalIds", "type": "uint256[]"}], "name": "ProposalsDeleted", "type": "event"}, {"anonymous": false, "inputs": [{"indexed": true, "internalType": "address", "name": "voter", "type": "address"}, {"indexed": false, "internalType": "uint256", "name": "proposalId", "type": "uint256"}, {"indexed": false, "internalType": "uint8", "name": "support", "type": "uint8"}, {"indexed": false, "internalType": "uint256", "name": "numVotes", "type": "uint256"}], "name": "VoteCast", "type": "event"}, {"anonymous": false, "inputs": [{"indexed": false, "internalType": "uint256", "name": "oldVotingDelay", "type": "uint256"}, {"indexed": false, "internalType": "uint256", "name": "newVotingDelay", "type": "uint256"}], "name": "VotingDelaySet", "type": "event"}, {"anonymous": false, "inputs": [{"indexed": false, "internalType": "uint256", "name": "oldVotingPeriod", "type": "uint256"}, {"indexed": false, "internalType": "uint256", "name": "newVotingPeriod", "type": "uint256"}], "name": "VotingPeriodSet", "type": "event"}, {"inputs": [], "name": "AMOUNT_FOR_SUMBITTER_PROOF", "outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}], "stateMutability": "view", "type": "function"}, {"inputs": [], "name": "JK_LABS_ADDRESS", "outputs": [{"internalType": "address", "name": "", "type": "address"}], "stateMutability": "view", "type": "function"}, {"inputs": [], "name": "METADATAS_COUNT", "outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}], "stateMutability": "view", "type": "function"}, {"inputs": [{"internalType": "address", "name": "", "type": "address"}], "name": "addressSubmitterVerified", "outputs": [{"internalType": "bool", "name": "", "type": "bool"}], "stateMutability": "view", "type": "function"}, {"inputs": [{"internalType": "address", "name": "", "type": "address"}], "name": "addressTotalCastVoteCounts", "outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}], "stateMutability": "view", "type": "function"}, {"inputs": [{"internalType": "address", "name": "", "type": "address"}], "name": "addressTotalVotes", "outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}], "stateMutability": "view", "type": "function"}, {"inputs": [{"internalType": "address", "name": "", "type": "address"}], "name": "addressTotalVotesVerified", "outputs": [{"internalType": "bool", "name": "", "type": "bool"}], "stateMutability": "view", "type": "function"}, {"inputs": [{"internalType": "uint256", "name": "", "type": "uint256"}], "name": "addressesThatHaveVoted", "outputs": [{"internalType": "address", "name": "", "type": "address"}], "stateMutability": "view", "type": "function"}, {"inputs": [], "name": "allProposalTotalVotes", "outputs": [{"internalType": "uint256[]", "name": "proposalIdsReturn", "type": "uint256[]"}, {"components": [{"internalType": "uint256", "name": "forVotes", "type": "uint256"}, {"internalType": "uint256", "name": "againstVotes", "type": "uint256"}], "internalType": "struct GovernorCountingSimple.VoteCounts[]", "name": "proposalVoteCountsArrayReturn", "type": "tuple[]"}], "stateMutability": "view", "type": "function"}, {"inputs": [], "name": "allProposalTotalVotesWithoutDeleted", "outputs": [{"internalType": "uint256[]", "name": "proposalIdsReturn", "type": "uint256[]"}, {"components": [{"internalType": "uint256", "name": "forVotes", "type": "uint256"}, {"internalType": "uint256", "name": "againstVotes", "type": "uint256"}], "internalType": "struct GovernorCountingSimple.VoteCounts[]", "name": "proposalVoteCountsArrayReturn", "type": "tuple[]"}], "stateMutability": "view", "type": "function"}, {"inputs": [], "name": "cancel", "outputs": [], "stateMutability": "nonpayable", "type": "function"}, {"inputs": [], "name": "canceled", "outputs": [{"internalType": "bool", "name": "", "type": "bool"}], "stateMutability": "view", "type": "function"}, {"inputs": [{"internalType": "uint256", "name": "proposalId", "type": "uint256"}, {"internalType": "uint8", "name": "support", "type": "uint8"}, {"internalType": "uint256", "name": "totalVotes", "type": "uint256"}, {"internalType": "uint256", "name": "numVotes", "type": "uint256"}, {"internalType": "bytes32[]", "name": "proof", "type": "bytes32[]"}], "name": "castVote", "outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}], "stateMutability": "nonpayable", "type": "function"}, {"inputs": [{"internalType": "uint256", "name": "proposalId", "type": "uint256"}, {"internalType": "uint8", "name": "support", "type": "uint8"}, {"internalType": "uint256", "name": "numVotes", "type": "uint256"}], "name": "castVoteWithoutProof", "outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}], "stateMutability": "nonpayable", "type": "function"}, {"inputs": [{"internalType": "address", "name": "addressToCheck", "type": "address"}, {"internalType": "uint256", "name": "amount", "type": "uint256"}, {"internalType": "bytes32[]", "name": "proof", "type": "bytes32[]"}, {"internalType": "bool", "name": "voting", "type": "bool"}], "name": "checkProof", "outputs": [{"internalType": "bool", "name": "verified", "type": "bool"}], "stateMutability": "view", "type": "function"}, {"inputs": [{"internalType": "address", "name": "userAddress", "type": "address"}], "name": "contestAddressTotalVotesCast", "outputs": [{"internalType": "uint256", "name": "userTotalVotesCast", "type": "uint256"}], "stateMutability": "view", "type": "function"}, {"inputs": [], "name": "contestDeadline", "outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}], "stateMutability": "view", "type": "function"}, {"inputs": [], "name": "contestStart", "outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}], "stateMutability": "view", "type": "function"}, {"inputs": [], "name": "costToPropose", "outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}], "stateMutability": "view", "type": "function"}, {"inputs": [], "name": "creator", "outputs": [{"internalType": "address", "name": "", "type": "address"}], "stateMutability": "view", "type": "function"}, {"inputs": [{"internalType": "uint256[]", "name": "proposalIdsToDelete", "type": "uint256[]"}], "name": "deleteProposals", "outputs": [], "stateMutability": "nonpayable", "type": "function"}, {"inputs": [{"internalType": "uint256", "name": "", "type": "uint256"}], "name": "deletedProposalIds", "outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}], "stateMutability": "view", "type": "function"}, {"inputs": [], "name": "downvotingAllowed", "outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}], "stateMutability": "view", "type": "function"}, {"inputs": [], "name": "eip712Domain", "outputs": [{"internalType": "bytes1", "name": "fields", "type": "bytes1"}, {"internalType": "string", "name": "name", "type": "string"}, {"internalType": "string", "name": "version", "type": "string"}, {"internalType": "uint256", "name": "chainId", "type": "uint256"}, {"internalType": "address", "name": "verifyingContract", "type": "address"}, {"internalType": "bytes32", "name": "salt", "type": "bytes32"}, {"internalType": "uint256[]", "name": "extensions", "type": "uint256[]"}], "stateMutability": "view", "type": "function"}, {"inputs": [], "name": "getAllAddressesThatHaveVoted", "outputs": [{"internalType": "address[]", "name": "", "type": "address[]"}], "stateMutability": "view", "type": "function"}, {"inputs": [], "name": "getAllDeletedProposalIds", "outputs": [{"internalType": "uint256[]", "name": "", "type": "uint256[]"}], "stateMutability": "view", "type": "function"}, {"inputs": [], "name": "getAllProposalAuthors", "outputs": [{"internalType": "address[]", "name": "", "type": "address[]"}], "stateMutability": "view", "type": "function"}, {"inputs": [], "name": "getAllProposalIds", "outputs": [{"internalType": "uint256[]", "name": "", "type": "uint256[]"}], "stateMutability": "view", "type": "function"}, {"inputs": [{"internalType": "address", "name": "account", "type": "address"}], "name": "getNumSubmissions", "outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}], "stateMutability": "view", "type": "function"}, {"inputs": [{"internalType": "uint256", "name": "proposalId", "type": "uint256"}], "name": "getProposal", "outputs": [{"components": [{"internalType": "address", "name": "author", "type": "address"}, {"internalType": "bool", "name": "exists", "type": "bool"}, {"internalType": "string", "name": "description", "type": "string"}, {"components": [{"internalType": "address", "name": "targetAddress", "type": "address"}], "internalType": "struct IGovernor.TargetMetadata", "name": "targetMetadata", "type": "tuple"}, {"components": [{"internalType": "address[]", "name": "signers", "type": "address[]"}, {"internalType": "uint256", "name": "threshold", "type": "uint256"}], "internalType": "struct IGovernor.SafeMetadata", "name": "safeMetadata", "type": "tuple"}], "internalType": "struct IGovernor.ProposalCore", "name": "", "type": "tuple"}], "stateMutability": "view", "type": "function"}, {"inputs": [{"components": [{"internalType": "address", "name": "author", "type": "address"}, {"internalType": "bool", "name": "exists", "type": "bool"}, {"internalType": "string", "name": "description", "type": "string"}, {"components": [{"internalType": "address", "name": "targetAddress", "type": "address"}], "internalType": "struct IGovernor.TargetMetadata", "name": "targetMetadata", "type": "tuple"}, {"components": [{"internalType": "address[]", "name": "signers", "type": "address[]"}, {"internalType": "uint256", "name": "threshold", "type": "uint256"}], "internalType": "struct IGovernor.SafeMetadata", "name": "safeMetadata", "type": "tuple"}], "internalType": "struct IGovernor.ProposalCore", "name": "proposal", "type": "tuple"}], "name": "hashProposal", "outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}], "stateMutability": "pure", "type": "function"}, {"inputs": [], "name": "highestTiedRanking", "outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}], "stateMutability": "view", "type": "function"}, {"inputs": [{"internalType": "uint256", "name": "proposalId", "type": "uint256"}], "name": "isProposalDeleted", "outputs": [{"internalType": "bool", "name": "", "type": "bool"}], "stateMutability": "view", "type": "function"}, {"inputs": [{"internalType": "uint256", "name": "ranking", "type": "uint256"}], "name": "isTied", "outputs": [{"internalType": "bool", "name": "", "type": "bool"}], "stateMutability": "view", "type": "function"}, {"inputs": [], "name": "lowestRanking", "outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}], "stateMutability": "view", "type": "function"}, {"inputs": [], "name": "maxProposalCount", "outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}], "stateMutability": "view", "type": "function"}, {"inputs": [], "name": "name", "outputs": [{"internalType": "string", "name": "", "type": "string"}], "stateMutability": "view", "type": "function"}, {"inputs": [], "name": "numAllowedProposalSubmissions", "outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}], "stateMutability": "view", "type": "function"}, {"inputs": [{"internalType": "address", "name": "", "type": "address"}], "name": "numSubmissions", "outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}], "stateMutability": "view", "type": "function"}, {"inputs": [], "name": "officialRewardsModule", "outputs": [{"internalType": "contract RewardsModule", "name": "", "type": "address"}], "stateMutability": "view", "type": "function"}, {"inputs": [], "name": "percentageToCreator", "outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}], "stateMutability": "view", "type": "function"}, {"inputs": [], "name": "prompt", "outputs": [{"internalType": "string", "name": "", "type": "string"}], "stateMutability": "view", "type": "function"}, {"inputs": [{"internalType": "uint256", "name": "proposalId", "type": "uint256"}, {"internalType": "address", "name": "userAddress", "type": "address"}], "name": "proposalAddressVotes", "outputs": [{"internalType": "uint256", "name": "forVotes", "type": "uint256"}, {"internalType": "uint256", "name": "againstVotes", "type": "uint256"}], "stateMutability": "view", "type": "function"}, {"inputs": [{"internalType": "uint256", "name": "proposalId", "type": "uint256"}], "name": "proposalAddressesHaveVoted", "outputs": [{"internalType": "address[]", "name": "", "type": "address[]"}], "stateMutability": "view", "type": "function"}, {"inputs": [{"internalType": "uint256", "name": "", "type": "uint256"}], "name": "proposalAuthors", "outputs": [{"internalType": "address", "name": "", "type": "address"}], "stateMutability": "view", "type": "function"}, {"inputs": [{"internalType": "uint256", "name": "", "type": "uint256"}], "name": "proposalIds", "outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}], "stateMutability": "view", "type": "function"}, {"inputs": [{"internalType": "uint256", "name": "", "type": "uint256"}], "name": "proposalIsDeleted", "outputs": [{"internalType": "bool", "name": "", "type": "bool"}], "stateMutability": "view", "type": "function"}, {"inputs": [{"internalType": "uint256", "name": "proposalId", "type": "uint256"}], "name": "proposalVotes", "outputs": [{"internalType": "uint256", "name": "forVotes", "type": "uint256"}, {"internalType": "uint256", "name": "againstVotes", "type": "uint256"}], "stateMutability": "view", "type": "function"}, {"inputs": [{"internalType": "uint256", "name": "", "type": "uint256"}], "name": "proposalVotesStructs", "outputs": [{"components": [{"internalType": "uint256", "name": "forVotes", "type": "uint256"}, {"internalType": "uint256", "name": "againstVotes", "type": "uint256"}], "internalType": "struct GovernorCountingSimple.VoteCounts", "name": "proposalVoteCounts", "type": "tuple"}], "stateMutability": "view", "type": "function"}, {"inputs": [{"internalType": "uint256", "name": "", "type": "uint256"}], "name": "proposals", "outputs": [{"internalType": "address", "name": "author", "type": "address"}, {"internalType": "bool", "name": "exists", "type": "bool"}, {"internalType": "string", "name": "description", "type": "string"}, {"components": [{"internalType": "address", "name": "targetAddress", "type": "address"}], "internalType": "struct IGovernor.TargetMetadata", "name": "targetMetadata", "type": "tuple"}, {"components": [{"internalType": "address[]", "name": "signers", "type": "address[]"}, {"internalType": "uint256", "name": "threshold", "type": "uint256"}], "internalType": "struct IGovernor.SafeMetadata", "name": "safeMetadata", "type": "tuple"}], "stateMutability": "view", "type": "function"}, {"inputs": [{"components": [{"internalType": "address", "name": "author", "type": "address"}, {"internalType": "bool", "name": "exists", "type": "bool"}, {"internalType": "string", "name": "description", "type": "string"}, {"components": [{"internalType": "address", "name": "targetAddress", "type": "address"}], "internalType": "struct IGovernor.TargetMetadata", "name": "targetMetadata", "type": "tuple"}, {"components": [{"internalType": "address[]", "name": "signers", "type": "address[]"}, {"internalType": "uint256", "name": "threshold", "type": "uint256"}], "internalType": "struct IGovernor.SafeMetadata", "name": "safeMetadata", "type": "tuple"}], "internalType": "struct IGovernor.ProposalCore", "name": "proposal", "type": "tuple"}, {"internalType": "bytes32[]", "name": "proof", "type": "bytes32[]"}], "name": "propose", "outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}], "stateMutability": "payable", "type": "function"}, {"inputs": [{"components": [{"internalType": "address", "name": "author", "type": "address"}, {"internalType": "bool", "name": "exists", "type": "bool"}, {"internalType": "string", "name": "description", "type": "string"}, {"components": [{"internalType": "address", "name": "targetAddress", "type": "address"}], "internalType": "struct IGovernor.TargetMetadata", "name": "targetMetadata", "type": "tuple"}, {"components": [{"internalType": "address[]", "name": "signers", "type": "address[]"}, {"internalType": "uint256", "name": "threshold", "type": "uint256"}], "internalType": "struct IGovernor.SafeMetadata", "name": "safeMetadata", "type": "tuple"}], "internalType": "struct IGovernor.ProposalCore", "name": "proposal", "type": "tuple"}], "name": "proposeWithoutProof", "outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}], "stateMutability": "payable", "type": "function"}, {"inputs": [{"internalType": "uint256", "name": "ranking", "type": "uint256"}], "name": "rankingPosition", "outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}], "stateMutability": "view", "type": "function"}, {"inputs": [{"internalType": "contract RewardsModule", "name": "officialRewardsModule_", "type": "address"}], "name": "setOfficialRewardsModule", "outputs": [], "stateMutability": "nonpayable", "type": "function"}, {"inputs": [], "name": "setSortedAndTiedProposals", "outputs": [], "stateMutability": "nonpayable", "type": "function"}, {"inputs": [], "name": "setSortedAndTiedProposalsHasBeenRun", "outputs": [{"internalType": "bool", "name": "", "type": "bool"}], "stateMutability": "view", "type": "function"}, {"inputs": [], "name": "sortedProposalIds", "outputs": [{"internalType": "uint256[]", "name": "", "type": "uint256[]"}], "stateMutability": "view", "type": "function"}, {"inputs": [{"internalType": "bool", "name": "excludeDeletedProposals", "type": "bool"}], "name": "sortedProposals", "outputs": [{"internalType": "uint256[]", "name": "sortedProposalIdsReturn", "type": "uint256[]"}], "stateMutability": "view", "type": "function"}, {"inputs": [], "name": "state", "outputs": [{"internalType": "enum IGovernor.ContestState", "name": "", "type": "uint8"}], "stateMutability": "view", "type": "function"}, {"inputs": [], "name": "submissionMerkleRoot", "outputs": [{"internalType": "bytes32", "name": "", "type": "bytes32"}], "stateMutability": "view", "type": "function"}, {"inputs": [{"internalType": "bytes4", "name": "interfaceId", "type": "bytes4"}], "name": "supportsInterface", "outputs": [{"internalType": "bool", "name": "", "type": "bool"}], "stateMutability": "view", "type": "function"}, {"inputs": [{"internalType": "uint256", "name": "", "type": "uint256"}], "name": "tiedAdjustedRankingPosition", "outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}], "stateMutability": "view", "type": "function"}, {"inputs": [], "name": "totalVotesCast", "outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}], "stateMutability": "view", "type": "function"}, {"inputs": [{"components": [{"internalType": "address", "name": "author", "type": "address"}, {"internalType": "bool", "name": "exists", "type": "bool"}, {"internalType": "string", "name": "description", "type": "string"}, {"components": [{"internalType": "address", "name": "targetAddress", "type": "address"}], "internalType": "struct IGovernor.TargetMetadata", "name": "targetMetadata", "type": "tuple"}, {"components": [{"internalType": "address[]", "name": "signers", "type": "address[]"}, {"internalType": "uint256", "name": "threshold", "type": "uint256"}], "internalType": "struct IGovernor.SafeMetadata", "name": "safeMetadata", "type": "tuple"}], "internalType": "struct IGovernor.ProposalCore", "name": "proposal", "type": "tuple"}], "name": "validateProposalData", "outputs": [{"internalType": "bool", "name": "dataValidated", "type": "bool"}], "stateMutability": "nonpayable", "type": "function"}, {"inputs": [{"internalType": "address", "name": "account", "type": "address"}, {"internalType": "bytes32[]", "name": "proof", "type": "bytes32[]"}], "name": "verifyProposer", "outputs": [{"internalType": "bool", "name": "verified", "type": "bool"}], "stateMutability": "nonpayable", "type": "function"}, {"inputs": [{"internalType": "address", "name": "account", "type": "address"}, {"internalType": "uint256", "name": "totalVotes", "type": "uint256"}, {"internalType": "bytes32[]", "name": "proof", "type": "bytes32[]"}], "name": "verifyVoter", "outputs": [{"internalType": "bool", "name": "verified", "type": "bool"}], "stateMutability": "nonpayable", "type": "function"}, {"inputs": [], "name": "version", "outputs": [{"internalType": "string", "name": "", "type": "string"}], "stateMutability": "view", "type": "function"}, {"inputs": [], "name": "voteStart", "outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}], "stateMutability": "view", "type": "function"}, {"inputs": [], "name": "votingDelay", "outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}], "stateMutability": "view", "type": "function"}, {"inputs": [], "name": "votingMerkleRoot", "outputs": [{"internalType": "bytes32", "name": "", "type": "bytes32"}], "stateMutability": "view", "type": "function"}, {"inputs": [], "name": "votingPeriod", "outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}], "stateMutability": "view", "type": "function"}]')
# Initialize contracts
contract = web3.eth.contract(address=checksum_contract_address, abi=jokerace_abi)
mainnet_contract = mainnet_web3.eth.contract(address=checksum_mainnet_contract_address, abi=jokerace_abi)
# Get all proposal IDs
proposals = contract.functions.getAllProposalIds().call()
mainnet_proposals = mainnet_contract.functions.getAllProposalIds().call()
print(proposals)
#Swell in 2 & 2 on the list of IDs returned
#proposal_id = proposals[2]
#mainnet_proposal_id = mainnet_proposals[2]
thisdict = {
0:"stakewise",
1:"Swell Protocol",
2:"WBETH",
3:"AnkrETH",
4:"OETH",
5:"ETHx",
6:"sfrxETH",
7:"mevETH"
}
#This seems to be the matching ids with mantle being first and mainnet being second
otherdict = {
0:[7,7],
1:[2,2],
2:[0,1],
3:[5,6],
4:[3,3],
5:[1,0],
6:[6,4],
7:[4,5]
}
def dedupe(proposal_id,mainnet_proposal_id):
# Get addresses that have voted for the given proposal
addresses_voted = contract.functions.proposalAddressesHaveVoted(proposal_id).call()
mainnet_addresses_voted = mainnet_contract.functions.proposalAddressesHaveVoted(mainnet_proposal_id).call()
# Find matching addresses that have voted on both chains
matching_addresses = [address for address in addresses_voted if address in mainnet_addresses_voted]
# Calculate votes sacrificed
votes_sacrificed = [
contract.functions.contestAddressTotalVotesCast(address).call() / 10**18
for address in matching_addresses
]
print("Total Votes Lost:","Contest: ",thisdict[index], sum(votes_sacrificed))
for index in range(len(proposals)):
dedupe(proposals[otherdict[index][0]],mainnet_proposals[otherdict[index][1]])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment