diff --git a/features/vesting/hooks.ts b/features/vesting/hooks.ts index abc61b7..59a4903 100644 --- a/features/vesting/hooks.ts +++ b/features/vesting/hooks.ts @@ -289,15 +289,12 @@ export const useSnapshotDelegate = (escrow: string | undefined) => { export const useSnapshotDelegateAddress = (escrow = AddressZero) => { const { contractRpc } = useSnapshotDelegationContract(); - const { chainId } = useWeb3(); return useSWR(`snapshot-delegate-${escrow}`, () => - chainId === CHAINS.Holesky - ? AddressZero - : contractRpc.delegation( - escrow, - '0x0000000000000000000000000000000000000000000000000000000000000000', - ), + contractRpc.delegation( + escrow, + '0x0000000000000000000000000000000000000000000000000000000000000000', + ), ); }; diff --git a/features/vesting/vestingDelegateBadge.tsx b/features/vesting/vestingDelegateBadge.tsx new file mode 100644 index 0000000..18c35ac --- /dev/null +++ b/features/vesting/vestingDelegateBadge.tsx @@ -0,0 +1,39 @@ +import { FC, memo } from 'react'; +import { AddressZero } from '@ethersproject/constants'; + +import { encodeAddress, useENS } from '../addressModal'; +import { useModal } from '../walletModal'; +import { InlineLoader } from '@lidofinance/lido-ui'; +import { Badge, BadgeContainer } from './vestingSlideStyles'; + +type Props = { + delegateAddress: string | undefined; +}; + +export const VestingDelegateBadge: FC = memo(({ delegateAddress }) => { + const { data: ensName, isLoading } = useENS(delegateAddress); + + const delegateNameToShow = ensName ?? delegateAddress; + + const { openModal } = useModal(encodeAddress(delegateAddress, 'delegate')); + + if (isLoading) { + return ; + } + + if (!delegateAddress || delegateAddress === AddressZero) { + return <>Not delegated; + } + + return ( + + + + ); +}); + +VestingDelegateBadge.displayName = 'VestingDelegateBadge'; diff --git a/features/vesting/vestingSummarySlide.tsx b/features/vesting/vestingSummarySlide.tsx index 9b2333a..26af33b 100644 --- a/features/vesting/vestingSummarySlide.tsx +++ b/features/vesting/vestingSummarySlide.tsx @@ -19,14 +19,11 @@ import { BadgeContainer, Row, VestingSlide, - EnsName, } from './vestingSlideStyles'; import { BigNumber } from 'ethers'; -import { AddressZero } from '@ethersproject/constants'; import { useModal } from '../walletModal'; import { encodeAddress } from '../addressModal'; -import { useENS } from '../addressModal'; -import { InlineLoader } from '@lidofinance/lido-ui'; +import { VestingDelegateBadge } from './vestingDelegateBadge'; export type VestingSummarySlideProps = { title?: string; @@ -47,12 +44,11 @@ export const VestingSummarySlide: FC = memo( useAragonDelegateAddress(vesting?.escrow); const { data: snapshotDelegate, isLoading: snapshotDelegateIsLoading } = useSnapshotDelegateAddress(vesting?.escrow); - const { data: ensName, isLoading: ensNameIsLoading } = - useENS(aragonDelegate); + + const delegateAddress = + showDelegation === 'snapshot' ? snapshotDelegate : aragonDelegate; + const { data: token, isLoading: tokenIsLoading } = useVestingToken(); - const { openModal: openDelegateModal } = useModal( - encodeAddress(aragonDelegate, 'delegate'), - ); const { openModal: openEscrowModal } = useModal( encodeAddress(vesting?.escrow, 'trp'), ); @@ -66,9 +62,6 @@ export const VestingSummarySlide: FC = memo( return null; } - const delegate = - showDelegation === 'snapshot' ? snapshotDelegate : aragonDelegate; - if ( unclaimedIsLoading || lockedIsLoading || @@ -128,23 +121,7 @@ export const VestingSummarySlide: FC = memo( Delegated to - {delegate === AddressZero ? ( - 'Not delegated' - ) : ( - - {ensNameIsLoading ? ( - - ) : !ensName ? ( - - ) : ( - {ensName} - )} - - )} + )}