-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
♻️ governance: get vp with snapshot api
- Loading branch information
1 parent
e033ce2
commit 13980ac
Showing
5 changed files
with
61 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -167,4 +167,4 @@ const NFT: FC = () => { | |
); | ||
}; | ||
|
||
export default Claimable; | ||
export default React.memo(Claimable); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import snapshot from '@snapshot-labs/snapshot.js'; | ||
import { useWeb3 } from './useWeb3'; | ||
import { useEffect, useMemo, useState } from 'react'; | ||
import optimismEXA from '@exactly/protocol/deployments/optimism/EXA.json'; | ||
import goerliEXA from '@exactly/protocol/deployments/goerli/EXA.json'; | ||
|
||
export default function useGovernance() { | ||
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 strategies = useMemo( | ||
() => [ | ||
{ | ||
name: 'erc20-balance-of', | ||
params: { | ||
symbol: 'EXA', | ||
address: exaAddress, | ||
decimals: 18, | ||
}, | ||
}, | ||
{ | ||
name: 'sablier-v2', | ||
params: { | ||
policy: 'reserved-recipient', | ||
symbol: 'EXA', | ||
address: exaAddress, | ||
decimals: 18, | ||
}, | ||
}, | ||
], | ||
[exaAddress], | ||
); | ||
|
||
const delegation = true; | ||
const url = 'https://score.snapshot.org/'; | ||
|
||
useEffect(() => { | ||
if (!walletAddress) return; | ||
|
||
snapshot.utils | ||
.getVp(walletAddress, String(chain.id), strategies, 'latest', space, delegation, { url }) | ||
.then(({ vp }) => setVotingPower(vp)); | ||
}, [chain.id, chain.network, delegation, space, strategies, url, votingPower, walletAddress]); | ||
|
||
return { votingPower }; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters