-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
DAO-823: User wants to see which address have delegated stRIF to "Vot…
…ing power delegated" (#364) * add delegation section * check if it's not delegate to himself * fix subtitle * rename hook
- Loading branch information
1 parent
e1650f8
commit 23d1983
Showing
7 changed files
with
78 additions
and
22 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 |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { Span } from '@/components/Typography' | ||
import { EXPLORER_URL } from '@/lib/constants' | ||
import { RxExternalLink } from 'react-icons/rx' | ||
|
||
interface HolderColumnProps { | ||
address: string | ||
rns?: string | ||
image?: string | ||
} | ||
|
||
export const HolderColumn = ({ address, rns, image }: HolderColumnProps) => ( | ||
<a | ||
href={`${EXPLORER_URL}/address/${address}`} | ||
target="_blank" | ||
className="flex items-center gap-1.5 text-white" | ||
> | ||
<img src={image || '/images/treasury/holders.png'} width={24} height={24} alt="Holders Image" /> | ||
<Span className="underline text-left overflow-hidden whitespace-nowrap text-[14px]"> | ||
{rns || address} | ||
</Span> | ||
<RxExternalLink size={18} /> | ||
</a> | ||
) |
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,29 @@ | ||
import { HolderColumn } from '@/app/communities/HolderColumn' | ||
import { Table } from '@/components/Table' | ||
import { HeaderTitle } from '@/components/Typography' | ||
import { useAccount } from 'wagmi' | ||
import { RenderTotalBalance } from '../Balances/RenderTotalBalance' | ||
import { BalancesProvider } from '../Balances/context/BalancesContext' | ||
import { useGetDelegates } from './hooks/useGetDelegates' | ||
|
||
export const DelegationSection = () => { | ||
const { address } = useAccount() | ||
const { delegateeAddress } = useGetDelegates(address) | ||
|
||
if (!delegateeAddress || delegateeAddress === address) { | ||
return null | ||
} | ||
|
||
const delegatee = { | ||
'Voting Power Delegated': <HolderColumn address={delegateeAddress} />, | ||
Amount: <RenderTotalBalance symbol="stRIF" />, | ||
} | ||
return ( | ||
<> | ||
<HeaderTitle className="mb-6">Delegation</HeaderTitle> | ||
<BalancesProvider> | ||
<Table data={[delegatee]} /> | ||
</BalancesProvider> | ||
</> | ||
) | ||
} |
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,21 @@ | ||
import { StRIFTokenAbi } from '@/lib/abis/StRIFTokenAbi' | ||
import { tokenContracts } from '@/lib/contracts' | ||
import { Address } from 'viem' | ||
import { useReadContract } from 'wagmi' | ||
|
||
const stRifContract = { | ||
abi: StRIFTokenAbi, | ||
address: tokenContracts.stRIF, | ||
} | ||
|
||
export const useGetDelegates = (address: Address | undefined) => { | ||
const { data: delegateeAddress } = useReadContract( | ||
address && { | ||
...stRifContract, | ||
functionName: 'delegates', | ||
args: [address], | ||
}, | ||
) | ||
|
||
return { delegateeAddress } | ||
} |
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 @@ | ||
export * from './DelegationSection' |
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 |
---|---|---|
@@ -1,2 +1,2 @@ | ||
export * from './components' | ||
export { Table } from './Table' | ||
export * from './Table' |