Skip to content

Commit

Permalink
♻️ governance: change space url for goerli
Browse files Browse the repository at this point in the history
  • Loading branch information
JuampiRombola committed Sep 22, 2023
1 parent dcd5b0c commit 219613c
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 7 deletions.
12 changes: 10 additions & 2 deletions components/governance/Proposals/index.tsx
Original file line number Diff line number Diff line change
@@ -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 (
<Box display="flex" flexDirection="column" gap={4}>
Expand All @@ -19,7 +27,7 @@ const Proposals = () => {
</Typography>
</Box>
</Box>
<a href="https://gov.exact.ly/" target="_blank" rel="noreferrer noopener">
<a href={spaceURL} target="_blank" rel="noreferrer noopener">
<Button variant="outlined" fullWidth endIcon={<OpenInNewIcon sx={{ height: 12 }} />}>
https://gov.exact.ly/
</Button>
Expand Down
9 changes: 6 additions & 3 deletions hooks/useDelegateRegistry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand All @@ -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({
Expand All @@ -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({
Expand Down
5 changes: 3 additions & 2 deletions hooks/useGovernance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<number | undefined>(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(
() => [
Expand Down

0 comments on commit 219613c

Please sign in to comment.