From 961b3fccb82ea5405cc9aa005396db6dcd2939d4 Mon Sep 17 00:00:00 2001 From: Juan Pablo Rombola Date: Fri, 22 Sep 2023 08:49:35 -0300 Subject: [PATCH] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20governance:=20change=20spa?= =?UTF-8?q?ce=20url=20for=20goerli?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/governance/Proposals/index.tsx | 12 ++++++++++-- hooks/useDelegateRegistry.ts | 9 ++++++--- hooks/useGovernance.ts | 5 +++-- 3 files changed, 19 insertions(+), 7 deletions(-) diff --git a/components/governance/Proposals/index.tsx b/components/governance/Proposals/index.tsx index 74ed1b0c1..ee3289bad 100644 --- a/components/governance/Proposals/index.tsx +++ b/components/governance/Proposals/index.tsx @@ -1,10 +1,18 @@ -import React from 'react'; +import React, { useMemo } from 'react'; import { Box, Button, Divider, Typography } from '@mui/material'; import { useTranslation } from 'react-i18next'; import OpenInNewIcon from '@mui/icons-material/OpenInNew'; +import { optimism } from 'wagmi/chains'; +import { useWeb3 } from 'hooks/useWeb3'; const Proposals = () => { const { t } = useTranslation(); + const { chain } = useWeb3(); + + const spaceURL = useMemo( + () => (chain.id === optimism.id ? 'https://gov.exact.ly/' : 'https://demo.snapshot.org/#/exa.eth'), + [chain], + ); return ( @@ -19,7 +27,7 @@ const Proposals = () => { - + diff --git a/hooks/useDelegateRegistry.ts b/hooks/useDelegateRegistry.ts index 97083778c..ff126155d 100644 --- a/hooks/useDelegateRegistry.ts +++ b/hooks/useDelegateRegistry.ts @@ -6,12 +6,15 @@ import { } from 'types/abi'; import { useWeb3 } from './useWeb3'; import { useMemo } from 'react'; +import { optimism } from 'wagmi/chains'; const DELEGATE_REGISTRY_ADDRESS = '0x469788fE6E9E9681C6ebF3bF78e7Fd26Fc015446'; +const SNAPSHOT_SPACE_OPTIMISM = 'gov.exa.eth'; +const SNAPSHOT_SPACE_GOERLI = 'exa.eth'; export const useDelegation = () => { const { chain, walletAddress } = useWeb3(); - const space = useMemo(() => (chain.id === 10 ? 'gov.exa.eth' : 'exa.eth'), [chain.id]); + const space = useMemo(() => (chain.id === optimism.id ? SNAPSHOT_SPACE_OPTIMISM : SNAPSHOT_SPACE_GOERLI), [chain.id]); const encodedSpace = useMemo(() => stringToHex(space, { size: 32 }), [space]); return useDelegateRegistryDelegation({ @@ -23,7 +26,7 @@ export const useDelegation = () => { export const usePrepareDelegate = (address: Address) => { const { chain, walletAddress } = useWeb3(); - const space = useMemo(() => (chain.id === 10 ? 'gov.exa.eth' : 'exa.eth'), [chain.id]); + const space = useMemo(() => (chain.id === optimism.id ? SNAPSHOT_SPACE_OPTIMISM : SNAPSHOT_SPACE_GOERLI), [chain.id]); const encodedSpace = useMemo(() => stringToHex(space, { size: 32 }), [space]); return usePrepareDelegateRegistrySetDelegate({ @@ -36,7 +39,7 @@ export const usePrepareDelegate = (address: Address) => { export const usePrepareClearDelegate = () => { const { chain, walletAddress } = useWeb3(); - const space = useMemo(() => (chain.id === 10 ? 'gov.exa.eth' : 'exa.eth'), [chain.id]); + const space = useMemo(() => (chain.id === optimism.id ? SNAPSHOT_SPACE_OPTIMISM : SNAPSHOT_SPACE_GOERLI), [chain.id]); const encodedSpace = useMemo(() => stringToHex(space, { size: 32 }), [space]); return usePrepareDelegateRegistryClearDelegate({ diff --git a/hooks/useGovernance.ts b/hooks/useGovernance.ts index e7d2f6b34..0719d4f5b 100644 --- a/hooks/useGovernance.ts +++ b/hooks/useGovernance.ts @@ -3,13 +3,14 @@ import { useWeb3 } from './useWeb3'; import { useCallback, useEffect, useMemo, useState } from 'react'; import optimismEXA from '@exactly/protocol/deployments/optimism/EXA.json'; import goerliEXA from '@exactly/protocol/deployments/goerli/EXA.json'; +import { optimism } from 'wagmi/chains'; export default function useGovernance(delegation = true) { const [votingPower, setVotingPower] = useState(undefined); const { chain, walletAddress } = useWeb3(); - const exaAddress = useMemo(() => (chain.id === 10 ? optimismEXA.address : goerliEXA.address), [chain.id]); - const space = useMemo(() => (chain.id === 10 ? 'gov.exa.eth' : 'exa.eth'), [chain.id]); + const exaAddress = useMemo(() => (chain.id === optimism.id ? optimismEXA.address : goerliEXA.address), [chain.id]); + const space = useMemo(() => (chain.id === optimism.id ? 'gov.exa.eth' : 'exa.eth'), [chain.id]); const strategies = useMemo( () => [