Skip to content

Commit

Permalink
Use ConsensusAccountLink in additional views
Browse files Browse the repository at this point in the history
  • Loading branch information
buberdds committed Oct 25, 2024
1 parent bede916 commit 3bd883b
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 11 deletions.
12 changes: 9 additions & 3 deletions src/app/components/Account/ConsensusAccountLink.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,29 @@ import { AccountLink } from './AccountLink'

type ConsensusAccountLinkProps = {
address: string
alwaysTrim?: boolean
labelOnly?: boolean
network: Network
}

export const ConsensusAccountLink: FC<ConsensusAccountLinkProps> = ({ address, labelOnly, network }) => {
export const ConsensusAccountLink: FC<ConsensusAccountLinkProps> = ({
address,
alwaysTrim = true,
labelOnly,
network,
}) => {
const { data } = useGetConsensusValidatorsAddressNameMap(network)

if (data?.data?.[address]) {
return <ValidatorLink address={address} network={network} alwaysTrim />
return <ValidatorLink address={address} network={network} alwaysTrim={alwaysTrim} />
}

return (
<AccountLink
labelOnly={labelOnly}
scope={{ network, layer: Layer.consensus }}
address={address}
alwaysTrim
alwaysTrim={alwaysTrim}
/>
)
}
9 changes: 3 additions & 6 deletions src/app/pages/ConsensusTransactionDetailPage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { BlockLink } from 'app/components/Blocks/BlockLink'
import { ConsensusTransactionMethod } from 'app/components/ConsensusTransactionMethod'
import { useFormattedTimestampStringWithDistance } from 'app/hooks/useFormattedTimestamp'
import { RoundedBalance } from 'app/components/RoundedBalance'
import { AccountLink } from 'app/components/Account/AccountLink'
import { ConsensusAccountLink } from 'app/components/Account/ConsensusAccountLink'
import { getPreciseNumberFormat } from 'locales/getPreciseNumberFormat'
import { CurrentFiatValue } from '../../components/CurrentFiatValue'
import { ConsensusTransactionEvents } from '../../components/Transactions/ConsensusTransactionEvents'
Expand Down Expand Up @@ -109,17 +109,14 @@ export const ConsensusTransactionDetailView: FC<{
</dd>
<dt>{t('common.from')}</dt>
<dd>
<AccountLink scope={transaction} address={transaction.sender} />
<ConsensusAccountLink network={transaction.network} address={transaction.sender} alwaysTrim={false} />
<CopyToClipboard value={transaction.sender} />
</dd>
{transaction.to && (
<>
<dt>{t('common.to')}</dt>
<dd>
<AccountLink
scope={{ layer: transaction.layer, network: transaction.network }}
address={transaction.to}
/>
<ConsensusAccountLink network={transaction.network} address={transaction.to} alwaysTrim={false} />
<CopyToClipboard value={transaction.to} />
</dd>
</>
Expand Down
4 changes: 2 additions & 2 deletions src/app/pages/ProposalDetailsPage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { DashboardLink } from '../ParatimeDashboardPage/DashboardLink'
import { useScreenSize } from '../../hooks/useScreensize'
import { ProposalStatusIcon } from '../../components/Proposals/ProposalStatusIcon'
import { TextSkeleton } from '../../components/Skeleton'
import { AccountLink } from '../../components/Account/AccountLink'
import { ConsensusAccountLink } from '../../components/Account/ConsensusAccountLink'
import { HighlightedText } from '../../components/HighlightedText'
import { ProposalIdLoaderData } from '../../utils/route-utils'
import { COLORS } from 'styles/theme/colors'
Expand Down Expand Up @@ -119,7 +119,7 @@ export const ProposalDetailView: FC<{

<dt>{t('common.submitter')}</dt>
<dd>
<AccountLink scope={proposal} address={proposal.submitter} />
<ConsensusAccountLink network={proposal.network} address={proposal.submitter} alwaysTrim={false} />
</dd>

{(totalVotes || totalVotesLoading || totalVotesProblematic) && (
Expand Down

0 comments on commit 3bd883b

Please sign in to comment.