From 1e9e98e6f05007b956abbcf105c01239be853ee9 Mon Sep 17 00:00:00 2001 From: MrX-SNX Date: Fri, 30 Aug 2024 19:53:22 +0100 Subject: [PATCH] Releave Gov 2 (#421) * ref: wallet connect id * ref: removed comment * feat: added new proxies * ref: smaller font size for select * fix: parameter * wip * ref: deps * ref: linting * ci: removed ci * feat: updated contracts * fix: more max witdh for wallet input --- .circleci/config.yml | 108 +- .../cypress/cypress/tasks/changePeriod.js | 18 +- .../cypress/tasks/prepareVotingPower.js | 2 +- governance/cypress/package.json | 2 +- .../components/CouncilTabs/CouncilSelect.tsx | 2 +- .../UserProfileForm/UserProfileForm.tsx | 2 +- governance/ui/src/mutations/useCastVotes.ts | 2 +- .../ui/src/mutations/useDeclareVotingPower.ts | 2 +- .../ui/src/mutations/useEditNomination.ts | 7 +- .../ui/src/mutations/useNominateSelf.ts | 5 +- governance/ui/src/queries/index.ts | 1 + .../ui/src/queries/useGetHistoricalVotes.ts | 18 + .../ui/src/queries/useGetUserDetailsQuery.ts | 3 - .../ui/src/queries/useGetUserVotingPower.ts | 4 +- governance/ui/src/utils/abi.ts | 1138 +---------------- governance/ui/src/utils/contracts.ts | 27 +- governance/ui/src/utils/onboard.ts | 11 +- 17 files changed, 136 insertions(+), 1216 deletions(-) create mode 100644 governance/ui/src/queries/useGetHistoricalVotes.ts diff --git a/.circleci/config.yml b/.circleci/config.yml index d53e14c78..b58c8421b 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -120,56 +120,56 @@ jobs: - run: git diff --name-only --exit-code - run: yarn typecheck - governance-e2e: - working_directory: /tmp/app - docker: - - image: cypress/included:<< pipeline.parameters.cypress-version >> - resource_class: large - environment: - NODE_ENV: test - TESTNET: 1 - steps: - - checkout - - install-foundry - - yarn-install - - - run: - name: Run server localhost:3000 - working_directory: /tmp/app/governance/ui - command: CI=true yarn start - background: true - - - run: - name: Run anvil localhost:8545 - command: 'anvil --fork-url https://testnet.snaxchain.io --fork-block-number 296528' - background: true - - - run: - name: Wait for server localhost:3000 - command: wget --retry-connrefused --waitretry=20 --read-timeout=20 --timeout=15 -t 10 http://localhost:3000 - - - run: - name: Wait for anvil localhost:8545 - command: wget -q -O - --retry-connrefused --waitretry=20 --read-timeout=20 --timeout=15 -t 10 --post-data='{"method":"eth_chainId","params":[],"id":1,"jsonrpc":"2.0"}' --header='Content-Type:application/json' http://localhost:8545 - - - run: - working_directory: /tmp/app/governance/cypress - command: cypress run --e2e --browser chrome - - - store_test_results: - path: 'governance/cypress/cypress/reports' - - - store_artifacts: - path: 'governance/cypress/.nyc_output' - destination: 'coverage' - - - store_artifacts: - path: 'governance/cypress/cypress/screenshots' - destination: 'screenshots' - - - store_artifacts: - path: 'governance/cypress/cypress/videos' - destination: 'videos' + # governance-e2e: + # working_directory: /tmp/app + # docker: + # - image: cypress/included:<< pipeline.parameters.cypress-version >> + # resource_class: large + # environment: + # NODE_ENV: test + # TESTNET: 1 + # steps: + # - checkout + # - install-foundry + # - yarn-install + + # - run: + # name: Run server localhost:3000 + # working_directory: /tmp/app/governance/ui + # command: CI=true yarn start + # background: true + + # - run: + # name: Run anvil localhost:8545 + # command: 'anvil --fork-url https://testnet.snaxchain.io --fork-block-number 296528' + # background: true + + # - run: + # name: Wait for server localhost:3000 + # command: wget --retry-connrefused --waitretry=20 --read-timeout=20 --timeout=15 -t 10 http://localhost:3000 + + # - run: + # name: Wait for anvil localhost:8545 + # command: wget -q -O - --retry-connrefused --waitretry=20 --read-timeout=20 --timeout=15 -t 10 --post-data='{"method":"eth_chainId","params":[],"id":1,"jsonrpc":"2.0"}' --header='Content-Type:application/json' http://localhost:8545 + + # - run: + # working_directory: /tmp/app/governance/cypress + # command: cypress run --e2e --browser chrome + + # - store_test_results: + # path: 'governance/cypress/cypress/reports' + + # - store_artifacts: + # path: 'governance/cypress/.nyc_output' + # destination: 'coverage' + + # - store_artifacts: + # path: 'governance/cypress/cypress/screenshots' + # destination: 'screenshots' + + # - store_artifacts: + # path: 'governance/cypress/cypress/videos' + # destination: 'videos' liquidity-e2e: parameters: @@ -269,7 +269,7 @@ jobs: - run: rm -rf /tmp/cov - run: yarn download-cci-coverage tests /tmp/cov || true - run: yarn download-cci-coverage liquidity-cy /tmp/cov || true - # - run: yarn download-cci-coverage governance-cy /tmp/cov || true + # - run: yarn download-cci-coveragegovernance-cy /tmp/cov || true - run: yarn download-cci-coverage liquidity-e2e-base-mainnet /tmp/cov || true - run: yarn download-cci-coverage liquidity-e2e-optimism-mainnet /tmp/cov || true - run: mkdir -p /tmp/cov @@ -307,8 +307,8 @@ workflows: - typecheck - tests - liquidity-cy - - governance-e2e: - name: governance-e2e-snax-testnet + # - governance-e2e: + # name: governance-e2e-snax-testnet - liquidity-e2e: name: liquidity-e2e-base-mainnet chainId: 8453 @@ -323,7 +323,7 @@ workflows: requires: [ tests, liquidity-cy, - governance-e2e-snax-testnet, + # governance-e2e-snax-testnet, liquidity-e2e-base-mainnet, #liquidity-e2e-sepolia, ] diff --git a/governance/cypress/cypress/tasks/changePeriod.js b/governance/cypress/cypress/tasks/changePeriod.js index 5c1a3dfa9..c6fd3b708 100644 --- a/governance/cypress/cypress/tasks/changePeriod.js +++ b/governance/cypress/cypress/tasks/changePeriod.js @@ -1,16 +1,20 @@ -import { ethers, Wallet } from 'ethers'; -import { getCouncilContract } from '../../../ui/src/utils/contracts'; +import { Contract, ethers, Wallet } from 'ethers'; +import { electionModuleABITest } from '../../../ui/src/utils/abi'; export async function changePeriod({ council, period }) { const provider = new ethers.providers.JsonRpcProvider('http://127.0.0.1:8545'); - const proxy = getCouncilContract(council, 13001); + const proxy = { + spartan: new Contract('0xBC85F11300A8EF619592fD678418Ec4eF26FBdFD', electionModuleABITest), + ambassador: new Contract('0xCdbEf5753cE3CEbF361e143117e345ADd7498F80', electionModuleABITest), + treasury: new Contract('0xe3aB2C6F1C9E46Fb53eD6b297c6fff68e935B161', electionModuleABITest), + }; const block = await provider.getBlock('latest'); const signer = new Wallet( '0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80', provider ); if (period === 'admin') { - await proxy + await proxy[council] .connect(signer) .Epoch_setEpochDates( 0, @@ -20,7 +24,7 @@ export async function changePeriod({ council, period }) { block.timestamp + 30000 ); } else if (period === 'nomination') { - await proxy + await proxy[council] .connect(signer) .Epoch_setEpochDates( 0, @@ -30,7 +34,7 @@ export async function changePeriod({ council, period }) { block.timestamp + 20000 ); } else if (period === 'voting') { - await proxy + await proxy[council] .connect(signer) .Epoch_setEpochDates( 0, @@ -40,7 +44,7 @@ export async function changePeriod({ council, period }) { block.timestamp + 10000 ); } else { - await proxy + await proxy[council] .connect(signer) .Epoch_setEpochDates( 0, diff --git a/governance/cypress/cypress/tasks/prepareVotingPower.js b/governance/cypress/cypress/tasks/prepareVotingPower.js index 13c1f9049..2061463d6 100644 --- a/governance/cypress/cypress/tasks/prepareVotingPower.js +++ b/governance/cypress/cypress/tasks/prepareVotingPower.js @@ -3,7 +3,7 @@ import { getCouncilContract, SnapshotRecordContract } from '../../../ui/src/util export async function prepareVotingPower({ council }) { const provider = new ethers.providers.JsonRpcProvider('http://127.0.0.1:8545'); - const proxy = getCouncilContract(council, 13001); + const proxy = getCouncilContract(council); const signer = new Wallet( '0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80', provider diff --git a/governance/cypress/package.json b/governance/cypress/package.json index f51bbbfb6..94b198966 100644 --- a/governance/cypress/package.json +++ b/governance/cypress/package.json @@ -4,7 +4,7 @@ "main": "index.ts", "version": "0.0.1", "scripts": { - "anvil:snax": "anvil --fork-url https://testnet.snaxchain.io --fork-block-number 296528", + "anvil:snax": "anvil --fork-url https://testnet.snaxchain.io --fork-block-number 296428", "e2e": "cypress open --e2e --browser electron" }, "devDependencies": { diff --git a/governance/ui/src/components/CouncilTabs/CouncilSelect.tsx b/governance/ui/src/components/CouncilTabs/CouncilSelect.tsx index 729808a72..83d2c8e1d 100644 --- a/governance/ui/src/components/CouncilTabs/CouncilSelect.tsx +++ b/governance/ui/src/components/CouncilTabs/CouncilSelect.tsx @@ -27,7 +27,7 @@ export const CouncilsSelect = ({ activeCouncil }: { activeCouncil: CouncilSlugs - getCouncilContract(council, network.id).connect(signer) + getCouncilContract(council).connect(signer) ); const prepareBallotData = councils .map((council, index) => { diff --git a/governance/ui/src/mutations/useDeclareVotingPower.ts b/governance/ui/src/mutations/useDeclareVotingPower.ts index 45b1b9e42..e504140d3 100644 --- a/governance/ui/src/mutations/useDeclareVotingPower.ts +++ b/governance/ui/src/mutations/useDeclareVotingPower.ts @@ -11,7 +11,7 @@ export default function useDeclareVotingPower(council: CouncilSlugs) { mutationFn: async () => { if (signer && network) { try { - const electionModule = getCouncilContract(council, network.id).connect(signer); + const electionModule = getCouncilContract(council).connect(signer); const voter = await signer.getAddress(); await electionModule.prepareBallotWithSnapshot( SnapshotRecordContract(network.id, council)?.address, diff --git a/governance/ui/src/mutations/useEditNomination.ts b/governance/ui/src/mutations/useEditNomination.ts index 3e0421420..85bf0e52e 100644 --- a/governance/ui/src/mutations/useEditNomination.ts +++ b/governance/ui/src/mutations/useEditNomination.ts @@ -1,5 +1,5 @@ import { useMutation, useQueryClient } from '@tanstack/react-query'; -import { useNetwork, useSigner } from '../queries/useWallet'; +import { useSigner } from '../queries/useWallet'; import { getCouncilContract } from '../utils/contracts'; import { CouncilSlugs } from '../utils/councils'; import { useToast } from '@chakra-ui/react'; @@ -17,14 +17,13 @@ export default function useEditNomination({ const signer = useSigner(); const toast = useToast(); const multicall = useMulticall(); - const { network } = useNetwork(); return useMutation({ mutationFn: async () => { if (signer) { const txs = []; if ((nextNomination && currentNomination) || (!nextNomination && currentNomination)) { txs.push({ - target: getCouncilContract(currentNomination, network?.id).address, + target: getCouncilContract(currentNomination).address, callData: getCouncilContract(currentNomination).interface.encodeFunctionData( 'withdrawNomination' @@ -33,7 +32,7 @@ export default function useEditNomination({ } if (nextNomination) { txs.push({ - target: getCouncilContract(nextNomination, network?.id).address, + target: getCouncilContract(nextNomination).address, callData: getCouncilContract(nextNomination).interface.encodeFunctionData('nominate'), }); } diff --git a/governance/ui/src/mutations/useNominateSelf.ts b/governance/ui/src/mutations/useNominateSelf.ts index 880bfee50..05e338cb0 100644 --- a/governance/ui/src/mutations/useNominateSelf.ts +++ b/governance/ui/src/mutations/useNominateSelf.ts @@ -1,7 +1,7 @@ import { useMutation, useQueryClient } from '@tanstack/react-query'; import { CouncilSlugs } from '../utils/councils'; import { getCouncilContract } from '../utils/contracts'; -import { useNetwork, useSigner } from '../queries/useWallet'; +import { useSigner } from '../queries/useWallet'; import { useToast } from '@chakra-ui/react'; import { utils } from 'ethers'; @@ -9,13 +9,12 @@ export default function useNominateSelf(council: CouncilSlugs, address?: string) const query = useQueryClient(); const signer = useSigner(); const toast = useToast(); - const { network } = useNetwork(); return useMutation({ mutationFn: async () => { if (signer) { try { - const tx = await getCouncilContract(council, network?.id) + const tx = await getCouncilContract(council) .connect(signer) .nominate({ maxPriorityFeePerGas: utils.parseUnits('1', 'gwei'), diff --git a/governance/ui/src/queries/index.ts b/governance/ui/src/queries/index.ts index b0c4a9a28..9ddfe506d 100644 --- a/governance/ui/src/queries/index.ts +++ b/governance/ui/src/queries/index.ts @@ -12,3 +12,4 @@ export * from './useGetUserBallot'; export * from './useGetUserDetailsQuery'; export * from './useGetUserVotingPower'; export * from './useWallet'; +export * from './useGetHistoricalVotes'; diff --git a/governance/ui/src/queries/useGetHistoricalVotes.ts b/governance/ui/src/queries/useGetHistoricalVotes.ts new file mode 100644 index 000000000..126218be7 --- /dev/null +++ b/governance/ui/src/queries/useGetHistoricalVotes.ts @@ -0,0 +1,18 @@ +import { useQuery } from '@tanstack/react-query'; +import { CouncilSlugs } from '../utils/councils'; +import { useNetwork } from './useWallet'; + +const testnetURL = 'https://api.synthetix.io/v3/snax-testnet/votes'; + +export function useGetHistoricalVotes(council: CouncilSlugs) { + const { network } = useNetwork(); + return useQuery({ + queryKey: ['historical-votes', council, network?.id], + queryFn: async () => { + const res = await fetch(network?.id === 2192 ? testnetURL : testnetURL); + const votes = await res.json(); + return votes; + }, + staleTime: 900000, + }); +} diff --git a/governance/ui/src/queries/useGetUserDetailsQuery.ts b/governance/ui/src/queries/useGetUserDetailsQuery.ts index c6991bf18..494679999 100644 --- a/governance/ui/src/queries/useGetUserDetailsQuery.ts +++ b/governance/ui/src/queries/useGetUserDetailsQuery.ts @@ -110,9 +110,6 @@ export async function getUserDetails( return { ...data, delegationPitch: foundPitch, - // foundPitch.find( - // (pitch) => pitch[0]?.address.toLowerCase() === data.address.toLowerCase() - // )[0]?.delegationPitch || '', }; } catch (error) { console.error(error); diff --git a/governance/ui/src/queries/useGetUserVotingPower.ts b/governance/ui/src/queries/useGetUserVotingPower.ts index 1c8df37c7..610915994 100644 --- a/governance/ui/src/queries/useGetUserVotingPower.ts +++ b/governance/ui/src/queries/useGetUserVotingPower.ts @@ -17,9 +17,7 @@ export function useGetUserVotingPower(council: CouncilSlugs) { if (!activeWallet || !provider || !network?.id) return; try { - const electionModule = getCouncilContract(council, network.id).connect( - motherShipProvider(network.id) - ); + const electionModule = getCouncilContract(council).connect(motherShipProvider(network.id)); const isMC = process.env.CI === 'true' ? true : isMotherchain(network.id); const electionId = await electionModule.getEpochIndex(); diff --git a/governance/ui/src/utils/abi.ts b/governance/ui/src/utils/abi.ts index 020c9cb6b..a17f61e3d 100644 --- a/governance/ui/src/utils/abi.ts +++ b/governance/ui/src/utils/abi.ts @@ -874,6 +874,25 @@ export const multicallABI = [ ]; export const electionModuleABITest = [ + { + inputs: [ + { + internalType: 'address', + name: 'voter', + type: 'address', + }, + ], + name: 'getPreparedBallot', + outputs: [ + { + internalType: 'uint256', + name: 'power', + type: 'uint256', + }, + ], + stateMutability: 'view', + type: 'function', + }, { inputs: [ { @@ -3278,1123 +3297,4 @@ export const electionModuleABITest = [ stateMutability: 'nonpayable', type: 'function', }, - { - inputs: [], - name: 'Council_get_currentElectionId', - outputs: [ - { - internalType: 'uint256', - name: '', - type: 'uint256', - }, - ], - stateMutability: 'view', - type: 'function', - }, - { - inputs: [], - name: 'Council_get_initialized', - outputs: [ - { - internalType: 'bool', - name: '', - type: 'bool', - }, - ], - stateMutability: 'view', - type: 'function', - }, - { - inputs: [], - name: 'Council_jumpToNominationPeriod', - outputs: [], - stateMutability: 'nonpayable', - type: 'function', - }, - { - inputs: [], - name: 'Council_newElection', - outputs: [ - { - internalType: 'uint256', - name: '', - type: 'uint256', - }, - ], - stateMutability: 'nonpayable', - type: 'function', - }, - { - inputs: [ - { - internalType: 'enum Epoch.ElectionPeriod', - name: 'period', - type: 'uint8', - }, - ], - name: 'Council_onlyInPeriod', - outputs: [], - stateMutability: 'view', - type: 'function', - }, - { - inputs: [ - { - internalType: 'enum Epoch.ElectionPeriod', - name: 'period1', - type: 'uint8', - }, - { - internalType: 'enum Epoch.ElectionPeriod', - name: 'period2', - type: 'uint8', - }, - ], - name: 'Council_onlyInPeriods', - outputs: [], - stateMutability: 'view', - type: 'function', - }, - { - inputs: [ - { - internalType: 'uint256', - name: 'val', - type: 'uint256', - }, - ], - name: 'Council_set_currentElectionId', - outputs: [], - stateMutability: 'nonpayable', - type: 'function', - }, - { - inputs: [ - { - internalType: 'bool', - name: 'val', - type: 'bool', - }, - ], - name: 'Council_set_initialized', - outputs: [], - stateMutability: 'nonpayable', - type: 'function', - }, - { - inputs: [ - { - internalType: 'uint64', - name: 'epochStartDate', - type: 'uint64', - }, - { - internalType: 'uint64', - name: 'nominationPeriodStartDate', - type: 'uint64', - }, - { - internalType: 'uint64', - name: 'votingPeriodStartDate', - type: 'uint64', - }, - { - internalType: 'uint64', - name: 'epochEndDate', - type: 'uint64', - }, - ], - name: 'Council_validateEpochSchedule', - outputs: [], - stateMutability: 'view', - type: 'function', - }, - { - inputs: [ - { - internalType: 'uint256', - name: '_load_electionId', - type: 'uint256', - }, - { - internalType: 'address', - name: '_load_voter', - type: 'address', - }, - { - internalType: 'uint256', - name: '_load_chainId', - type: 'uint256', - }, - { - internalType: 'uint256', - name: 'idx', - type: 'uint256', - }, - ], - name: 'Ballot_get_amounts', - outputs: [ - { - internalType: 'uint256', - name: '', - type: 'uint256', - }, - ], - stateMutability: 'view', - type: 'function', - }, - { - inputs: [ - { - internalType: 'uint256', - name: '_load_electionId', - type: 'uint256', - }, - { - internalType: 'address', - name: '_load_voter', - type: 'address', - }, - { - internalType: 'uint256', - name: '_load_chainId', - type: 'uint256', - }, - { - internalType: 'uint256', - name: 'idx', - type: 'uint256', - }, - ], - name: 'Ballot_get_votedCandidates', - outputs: [ - { - internalType: 'address', - name: '', - type: 'address', - }, - ], - stateMutability: 'view', - type: 'function', - }, - { - inputs: [ - { - internalType: 'uint256', - name: '_load_electionId', - type: 'uint256', - }, - { - internalType: 'address', - name: '_load_voter', - type: 'address', - }, - { - internalType: 'uint256', - name: '_load_chainId', - type: 'uint256', - }, - ], - name: 'Ballot_get_votingPower', - outputs: [ - { - internalType: 'uint256', - name: '', - type: 'uint256', - }, - ], - stateMutability: 'view', - type: 'function', - }, - { - inputs: [ - { - internalType: 'uint256', - name: '_load_electionId', - type: 'uint256', - }, - { - internalType: 'address', - name: '_load_voter', - type: 'address', - }, - { - internalType: 'uint256', - name: '_load_chainId', - type: 'uint256', - }, - ], - name: 'Ballot_hasVoted', - outputs: [ - { - internalType: 'bool', - name: '', - type: 'bool', - }, - ], - stateMutability: 'view', - type: 'function', - }, - { - inputs: [ - { - internalType: 'uint256', - name: '_load_electionId', - type: 'uint256', - }, - { - internalType: 'address', - name: '_load_voter', - type: 'address', - }, - { - internalType: 'uint256', - name: '_load_chainId', - type: 'uint256', - }, - ], - name: 'Ballot_isValid', - outputs: [ - { - internalType: 'bool', - name: '', - type: 'bool', - }, - ], - stateMutability: 'view', - type: 'function', - }, - { - inputs: [ - { - internalType: 'uint256', - name: '_load_electionId', - type: 'uint256', - }, - { - internalType: 'address', - name: '_load_voter', - type: 'address', - }, - { - internalType: 'uint256', - name: '_load_chainId', - type: 'uint256', - }, - { - internalType: 'uint256', - name: 'idx', - type: 'uint256', - }, - { - internalType: 'uint256', - name: 'val', - type: 'uint256', - }, - ], - name: 'Ballot_set_amounts', - outputs: [], - stateMutability: 'nonpayable', - type: 'function', - }, - { - inputs: [ - { - internalType: 'uint256', - name: '_load_electionId', - type: 'uint256', - }, - { - internalType: 'address', - name: '_load_voter', - type: 'address', - }, - { - internalType: 'uint256', - name: '_load_chainId', - type: 'uint256', - }, - { - internalType: 'uint256', - name: 'idx', - type: 'uint256', - }, - { - internalType: 'address', - name: 'val', - type: 'address', - }, - ], - name: 'Ballot_set_votedCandidates', - outputs: [], - stateMutability: 'nonpayable', - type: 'function', - }, - { - inputs: [ - { - internalType: 'uint256', - name: '_load_electionId', - type: 'uint256', - }, - { - internalType: 'address', - name: '_load_voter', - type: 'address', - }, - { - internalType: 'uint256', - name: '_load_chainId', - type: 'uint256', - }, - { - internalType: 'uint256', - name: 'val', - type: 'uint256', - }, - ], - name: 'Ballot_set_votingPower', - outputs: [], - stateMutability: 'nonpayable', - type: 'function', - }, - { - inputs: [ - { - internalType: 'uint256', - name: '_load_electionId', - type: 'uint256', - }, - { - internalType: 'address', - name: '_load_voter', - type: 'address', - }, - { - internalType: 'uint256', - name: '_load_chainId', - type: 'uint256', - }, - ], - name: 'Ballot_validate', - outputs: [], - stateMutability: 'view', - type: 'function', - }, - { - inputs: [ - { - internalType: 'address', - name: '_load_snapshotContract', - type: 'address', - }, - { - internalType: 'uint256', - name: 'ballotBalance', - type: 'uint256', - }, - ], - name: 'SnapshotVotePower_calculateVotingPower', - outputs: [ - { - internalType: 'uint256', - name: '', - type: 'uint256', - }, - ], - stateMutability: 'view', - type: 'function', - }, - { - inputs: [ - { - internalType: 'address', - name: '_load_snapshotContract', - type: 'address', - }, - ], - name: 'SnapshotVotePower_get_enabled', - outputs: [ - { - internalType: 'bool', - name: '', - type: 'bool', - }, - ], - stateMutability: 'view', - type: 'function', - }, - { - inputs: [ - { - internalType: 'address', - name: '_load_snapshotContract', - type: 'address', - }, - ], - name: 'SnapshotVotePower_get_scale', - outputs: [ - { - internalType: 'uint256', - name: '', - type: 'uint256', - }, - ], - stateMutability: 'view', - type: 'function', - }, - { - inputs: [ - { - internalType: 'address', - name: '_load_snapshotContract', - type: 'address', - }, - { - internalType: 'bool', - name: 'val', - type: 'bool', - }, - ], - name: 'SnapshotVotePower_set_enabled', - outputs: [], - stateMutability: 'nonpayable', - type: 'function', - }, - { - inputs: [ - { - internalType: 'address', - name: '_load_snapshotContract', - type: 'address', - }, - { - internalType: 'uint256', - name: 'val', - type: 'uint256', - }, - ], - name: 'SnapshotVotePower_set_scale', - outputs: [], - stateMutability: 'nonpayable', - type: 'function', - }, - { - inputs: [ - { - internalType: 'uint256', - name: '_load_epochIndex', - type: 'uint256', - }, - ], - name: 'ElectionSettings_get_epochDuration', - outputs: [ - { - internalType: 'uint64', - name: '', - type: 'uint64', - }, - ], - stateMutability: 'view', - type: 'function', - }, - { - inputs: [ - { - internalType: 'uint256', - name: '_load_epochIndex', - type: 'uint256', - }, - ], - name: 'ElectionSettings_get_epochSeatCount', - outputs: [ - { - internalType: 'uint8', - name: '', - type: 'uint8', - }, - ], - stateMutability: 'view', - type: 'function', - }, - { - inputs: [ - { - internalType: 'uint256', - name: '_load_epochIndex', - type: 'uint256', - }, - ], - name: 'ElectionSettings_get_maxDateAdjustmentTolerance', - outputs: [ - { - internalType: 'uint64', - name: '', - type: 'uint64', - }, - ], - stateMutability: 'view', - type: 'function', - }, - { - inputs: [ - { - internalType: 'uint256', - name: '_load_epochIndex', - type: 'uint256', - }, - ], - name: 'ElectionSettings_get_minimumActiveMembers', - outputs: [ - { - internalType: 'uint8', - name: '', - type: 'uint8', - }, - ], - stateMutability: 'view', - type: 'function', - }, - { - inputs: [ - { - internalType: 'uint256', - name: '_load_epochIndex', - type: 'uint256', - }, - ], - name: 'ElectionSettings_get_nominationPeriodDuration', - outputs: [ - { - internalType: 'uint64', - name: '', - type: 'uint64', - }, - ], - stateMutability: 'view', - type: 'function', - }, - { - inputs: [ - { - internalType: 'uint256', - name: '_load_epochIndex', - type: 'uint256', - }, - ], - name: 'ElectionSettings_get_votingPeriodDuration', - outputs: [ - { - internalType: 'uint64', - name: '', - type: 'uint64', - }, - ], - stateMutability: 'view', - type: 'function', - }, - { - inputs: [ - { - internalType: 'uint256', - name: '_load_epochIndex', - type: 'uint256', - }, - ], - name: 'ElectionSettings_minimumElectionPeriodDuration', - outputs: [ - { - internalType: 'uint256', - name: '', - type: 'uint256', - }, - ], - stateMutability: 'view', - type: 'function', - }, - { - inputs: [ - { - internalType: 'uint256', - name: '_load_epochIndex', - type: 'uint256', - }, - { - internalType: 'uint8', - name: 'epochSeatCount', - type: 'uint8', - }, - { - internalType: 'uint8', - name: 'minimumActiveMembers', - type: 'uint8', - }, - { - internalType: 'uint64', - name: 'epochDuration', - type: 'uint64', - }, - { - internalType: 'uint64', - name: 'nominationPeriodDuration', - type: 'uint64', - }, - { - internalType: 'uint64', - name: 'votingPeriodDuration', - type: 'uint64', - }, - { - internalType: 'uint64', - name: 'maxDateAdjustmentTolerance', - type: 'uint64', - }, - ], - name: 'ElectionSettings_setElectionSettings', - outputs: [], - stateMutability: 'nonpayable', - type: 'function', - }, - { - inputs: [ - { - internalType: 'uint256', - name: '_load_epochIndex', - type: 'uint256', - }, - { - internalType: 'uint64', - name: 'val', - type: 'uint64', - }, - ], - name: 'ElectionSettings_set_epochDuration', - outputs: [], - stateMutability: 'nonpayable', - type: 'function', - }, - { - inputs: [ - { - internalType: 'uint256', - name: '_load_epochIndex', - type: 'uint256', - }, - { - internalType: 'uint8', - name: 'val', - type: 'uint8', - }, - ], - name: 'ElectionSettings_set_epochSeatCount', - outputs: [], - stateMutability: 'nonpayable', - type: 'function', - }, - { - inputs: [ - { - internalType: 'uint256', - name: '_load_epochIndex', - type: 'uint256', - }, - { - internalType: 'uint64', - name: 'val', - type: 'uint64', - }, - ], - name: 'ElectionSettings_set_maxDateAdjustmentTolerance', - outputs: [], - stateMutability: 'nonpayable', - type: 'function', - }, - { - inputs: [ - { - internalType: 'uint256', - name: '_load_epochIndex', - type: 'uint256', - }, - { - internalType: 'uint8', - name: 'val', - type: 'uint8', - }, - ], - name: 'ElectionSettings_set_minimumActiveMembers', - outputs: [], - stateMutability: 'nonpayable', - type: 'function', - }, - { - inputs: [ - { - internalType: 'uint256', - name: '_load_epochIndex', - type: 'uint256', - }, - { - internalType: 'uint64', - name: 'val', - type: 'uint64', - }, - ], - name: 'ElectionSettings_set_nominationPeriodDuration', - outputs: [], - stateMutability: 'nonpayable', - type: 'function', - }, - { - inputs: [ - { - internalType: 'uint256', - name: '_load_epochIndex', - type: 'uint256', - }, - { - internalType: 'uint64', - name: 'val', - type: 'uint64', - }, - ], - name: 'ElectionSettings_set_votingPeriodDuration', - outputs: [], - stateMutability: 'nonpayable', - type: 'function', - }, - { - inputs: [ - { - internalType: 'uint256', - name: '_load_epochIndex', - type: 'uint256', - }, - ], - name: 'ElectionSettings_validate', - outputs: [], - stateMutability: 'view', - type: 'function', - }, - { - inputs: [ - { - internalType: 'uint256', - name: '_load_epochIndex', - type: 'uint256', - }, - { - internalType: 'address', - name: 'idx', - type: 'address', - }, - ], - name: 'Election_get_candidateVoteTotals', - outputs: [ - { - internalType: 'uint256', - name: '', - type: 'uint256', - }, - ], - stateMutability: 'view', - type: 'function', - }, - { - inputs: [ - { - internalType: 'uint256', - name: '_load_epochIndex', - type: 'uint256', - }, - ], - name: 'Election_get_evaluated', - outputs: [ - { - internalType: 'bool', - name: '', - type: 'bool', - }, - ], - stateMutability: 'view', - type: 'function', - }, - { - inputs: [ - { - internalType: 'uint256', - name: '_load_epochIndex', - type: 'uint256', - }, - ], - name: 'Election_get_numEvaluatedBallots', - outputs: [ - { - internalType: 'uint256', - name: '', - type: 'uint256', - }, - ], - stateMutability: 'view', - type: 'function', - }, - { - inputs: [ - { - internalType: 'uint256', - name: '_load_epochIndex', - type: 'uint256', - }, - { - internalType: 'address', - name: 'idx', - type: 'address', - }, - { - internalType: 'uint256', - name: 'val', - type: 'uint256', - }, - ], - name: 'Election_set_candidateVoteTotals', - outputs: [], - stateMutability: 'nonpayable', - type: 'function', - }, - { - inputs: [ - { - internalType: 'uint256', - name: '_load_epochIndex', - type: 'uint256', - }, - { - internalType: 'bool', - name: 'val', - type: 'bool', - }, - ], - name: 'Election_set_evaluated', - outputs: [], - stateMutability: 'nonpayable', - type: 'function', - }, - { - inputs: [ - { - internalType: 'uint256', - name: '_load_epochIndex', - type: 'uint256', - }, - { - internalType: 'uint256', - name: 'val', - type: 'uint256', - }, - ], - name: 'Election_set_numEvaluatedBallots', - outputs: [], - stateMutability: 'nonpayable', - type: 'function', - }, - { - inputs: [ - { - internalType: 'uint256', - name: '_load_epochIndex', - type: 'uint256', - }, - ], - name: 'Epoch_getCurrentPeriod', - outputs: [ - { - internalType: 'enum Epoch.ElectionPeriod', - name: '', - type: 'uint8', - }, - ], - stateMutability: 'view', - type: 'function', - }, - { - inputs: [ - { - internalType: 'uint256', - name: '_load_epochIndex', - type: 'uint256', - }, - ], - name: 'Epoch_get_endDate', - outputs: [ - { - internalType: 'uint64', - name: '', - type: 'uint64', - }, - ], - stateMutability: 'view', - type: 'function', - }, - { - inputs: [ - { - internalType: 'uint256', - name: '_load_epochIndex', - type: 'uint256', - }, - ], - name: 'Epoch_get_nominationPeriodStartDate', - outputs: [ - { - internalType: 'uint64', - name: '', - type: 'uint64', - }, - ], - stateMutability: 'view', - type: 'function', - }, - { - inputs: [ - { - internalType: 'uint256', - name: '_load_epochIndex', - type: 'uint256', - }, - ], - name: 'Epoch_get_startDate', - outputs: [ - { - internalType: 'uint64', - name: '', - type: 'uint64', - }, - ], - stateMutability: 'view', - type: 'function', - }, - { - inputs: [ - { - internalType: 'uint256', - name: '_load_epochIndex', - type: 'uint256', - }, - ], - name: 'Epoch_get_votingPeriodStartDate', - outputs: [ - { - internalType: 'uint64', - name: '', - type: 'uint64', - }, - ], - stateMutability: 'view', - type: 'function', - }, - { - inputs: [ - { - internalType: 'uint256', - name: '_load_epochIndex', - type: 'uint256', - }, - { - internalType: 'uint64', - name: 'startDate', - type: 'uint64', - }, - { - internalType: 'uint64', - name: 'nominationPeriodStartDate', - type: 'uint64', - }, - { - internalType: 'uint64', - name: 'votingPeriodStartDate', - type: 'uint64', - }, - { - internalType: 'uint64', - name: 'endDate', - type: 'uint64', - }, - ], - name: 'Epoch_setEpochDates', - outputs: [], - stateMutability: 'nonpayable', - type: 'function', - }, - { - inputs: [ - { - internalType: 'uint256', - name: '_load_epochIndex', - type: 'uint256', - }, - { - internalType: 'uint64', - name: 'val', - type: 'uint64', - }, - ], - name: 'Epoch_set_endDate', - outputs: [], - stateMutability: 'nonpayable', - type: 'function', - }, - { - inputs: [ - { - internalType: 'uint256', - name: '_load_epochIndex', - type: 'uint256', - }, - { - internalType: 'uint64', - name: 'val', - type: 'uint64', - }, - ], - name: 'Epoch_set_nominationPeriodStartDate', - outputs: [], - stateMutability: 'nonpayable', - type: 'function', - }, - { - inputs: [ - { - internalType: 'uint256', - name: '_load_epochIndex', - type: 'uint256', - }, - { - internalType: 'uint64', - name: 'val', - type: 'uint64', - }, - ], - name: 'Epoch_set_startDate', - outputs: [], - stateMutability: 'nonpayable', - type: 'function', - }, - { - inputs: [ - { - internalType: 'uint256', - name: '_load_epochIndex', - type: 'uint256', - }, - { - internalType: 'uint64', - name: 'val', - type: 'uint64', - }, - ], - name: 'Epoch_set_votingPeriodStartDate', - outputs: [], - stateMutability: 'nonpayable', - type: 'function', - }, ]; diff --git a/governance/ui/src/utils/contracts.ts b/governance/ui/src/utils/contracts.ts index 99f935ac0..85acd8a81 100644 --- a/governance/ui/src/utils/contracts.ts +++ b/governance/ui/src/utils/contracts.ts @@ -11,35 +11,34 @@ export const isMotherchain = (chainId?: string | number) => { }; const SpartanCouncilContract = new Contract( - '0xBC85F11300A8EF619592fD678418Ec4eF26FBdFD', + '0x2082d5A6f6F17F5e421FD6508b867D794472A42a', electionModuleABITest ); const AmbassadorCouncilContract = new Contract( - '0xCdbEf5753cE3CEbF361e143117e345ADd7498F80', + '0x93D3A11B8403C2140D0d1f1c0460601e4FBB52DE', electionModuleABITest ); const TreasuryCouncilContract = new Contract( - '0xe3aB2C6F1C9E46Fb53eD6b297c6fff68e935B161', + '0xECfA1d4B17AaCD691173b6194C3ade361ef38367', electionModuleABITest ); -export function getCouncilContract(council: CouncilSlugs, chainId?: string | number) { - const parsedChainId = process.env.CI === 'true' ? 13001 : chainId ? Number(chainId) : 2192; +export function getCouncilContract(council: CouncilSlugs) { switch (council) { case 'spartan': - return parsedChainId === 2192 || parsedChainId === 10 - ? SpartanCouncilContract.attach('0xB3026a683AAC2499e70Bbd988a9411A99b00EBD2') - : SpartanCouncilContract.attach('0xBC85F11300A8EF619592fD678418Ec4eF26FBdFD'); + if (process.env.CI === 'true') + return SpartanCouncilContract.connect('0xBC85F11300A8EF619592fD678418Ec4eF26FBdFD'); + return SpartanCouncilContract; case 'ambassador': - return parsedChainId === 2192 - ? AmbassadorCouncilContract.attach('0xB3026a683AAC2499e70Bbd988a9411A99b00EBD2') - : AmbassadorCouncilContract.attach('0xCdbEf5753cE3CEbF361e143117e345ADd7498F80'); + if (process.env.CI === 'true') + return AmbassadorCouncilContract.connect('0xCdbEf5753cE3CEbF361e143117e345ADd7498F80'); + return AmbassadorCouncilContract; case 'treasury': - return parsedChainId === 2192 - ? TreasuryCouncilContract.attach('0xB3026a683AAC2499e70Bbd988a9411A99b00EBD2') - : TreasuryCouncilContract.attach('0xe3aB2C6F1C9E46Fb53eD6b297c6fff68e935B161'); + if (process.env.CI === 'true') + return TreasuryCouncilContract.connect('0xe3aB2C6F1C9E46Fb53eD6b297c6fff68e935B161'); + return TreasuryCouncilContract; default: throw new Error('could not find contract'); } diff --git a/governance/ui/src/utils/onboard.ts b/governance/ui/src/utils/onboard.ts index 86921038b..a2565be2b 100644 --- a/governance/ui/src/utils/onboard.ts +++ b/governance/ui/src/utils/onboard.ts @@ -7,7 +7,7 @@ import { init } from '@web3-onboard/react'; import trezorModule from '@web3-onboard/trezor'; import walletConnectModule from '@web3-onboard/walletconnect'; -export const supportedNetworks = [2192, 13001, 10, 1]; +export const supportedNetworks = [2192, 10, 1]; export const chains = NETWORKS.filter((network) => supportedNetworks.includes(network.id)).map( (network) => ({ @@ -27,12 +27,17 @@ export const onboard = init({ email: 'info@synthetix.io', }), ledgerModule({ - projectId: process.env.WC_PROJECT_ID ?? '824270fbfdf10d95099e9702d3cb3741', + projectId: process.env.WC_PROJECT_ID + ? process.env.WC_PROJECT_ID + : '824270fbfdf10d95099e9702d3cb3741', walletConnectVersion: 2, }), walletConnectModule({ version: 2, - projectId: process.env.WC_PROJECT_ID ?? '824270fbfdf10d95099e9702d3cb3741', + projectId: process.env.WC_PROJECT_ID + ? process.env.WC_PROJECT_ID + : '824270fbfdf10d95099e9702d3cb3741', + dappUrl: 'https://governance.synthetix.eth', }), gnosisModule(), ],