-
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: change delegation component to use delegate registry
- Loading branch information
1 parent
13980ac
commit 59dcd7b
Showing
5 changed files
with
109 additions
and
44 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
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,48 @@ | ||
import { Address, stringToHex, zeroAddress } from 'viem'; | ||
import { | ||
useDelegateRegistryDelegation, | ||
usePrepareDelegateRegistryClearDelegate, | ||
usePrepareDelegateRegistrySetDelegate, | ||
} from 'types/abi'; | ||
import { useWeb3 } from './useWeb3'; | ||
import { useMemo } from 'react'; | ||
|
||
const DELEGATE_REGISTRY_ADDRESS = '0x469788fE6E9E9681C6ebF3bF78e7Fd26Fc015446'; | ||
|
||
export const useDelegation = () => { | ||
const { chain, walletAddress } = useWeb3(); | ||
const space = useMemo(() => (chain.id === 10 ? 'gov.exa.eth' : 'exa.eth'), [chain.id]); | ||
const encodedSpace = useMemo(() => stringToHex(space, { size: 32 }), [space]); | ||
|
||
return useDelegateRegistryDelegation({ | ||
chainId: chain.id, | ||
address: DELEGATE_REGISTRY_ADDRESS, | ||
args: [walletAddress ?? zeroAddress, encodedSpace], | ||
}); | ||
}; | ||
|
||
export const usePrepareDelegate = (address: Address) => { | ||
const { chain, walletAddress } = useWeb3(); | ||
const space = useMemo(() => (chain.id === 10 ? 'gov.exa.eth' : 'exa.eth'), [chain.id]); | ||
const encodedSpace = useMemo(() => stringToHex(space, { size: 32 }), [space]); | ||
|
||
return usePrepareDelegateRegistrySetDelegate({ | ||
chainId: chain.id, | ||
address: DELEGATE_REGISTRY_ADDRESS, | ||
account: walletAddress ?? zeroAddress, | ||
args: [encodedSpace, address], | ||
}); | ||
}; | ||
|
||
export const usePrepareClearDelegate = () => { | ||
const { chain, walletAddress } = useWeb3(); | ||
const space = useMemo(() => (chain.id === 10 ? 'gov.exa.eth' : 'exa.eth'), [chain.id]); | ||
const encodedSpace = useMemo(() => stringToHex(space, { size: 32 }), [space]); | ||
|
||
return usePrepareDelegateRegistryClearDelegate({ | ||
chainId: chain.id, | ||
address: DELEGATE_REGISTRY_ADDRESS, | ||
account: walletAddress ?? zeroAddress, | ||
args: [encodedSpace], | ||
}); | ||
}; |
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