Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Demo for Pontus-X Explorer #1247

Closed
wants to merge 20 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Make sure account links are always used correctly
  • Loading branch information
csillag committed Feb 28, 2024

Verified

This commit was signed with the committer’s verified signature.
renovate-bot Mend Renovate
commit f5c192f1b693b0e5b8c11034710b1ec34b6082c4
25 changes: 18 additions & 7 deletions src/app/components/Account/ContractCreatorInfo.tsx
Original file line number Diff line number Diff line change
@@ -14,7 +14,11 @@ import Box from '@mui/material/Box'
import Skeleton from '@mui/material/Skeleton'
import { useScreenSize } from '../../hooks/useScreensize'

const TxSender: FC<{ scope: SearchScope; txHash: string }> = ({ scope, txHash }) => {
const TxSender: FC<{ scope: SearchScope; txHash: string; alwaysTrim?: boolean }> = ({
scope,
txHash,
alwaysTrim,
}) => {
const { t } = useTranslation()
if (scope.layer === Layer.consensus) {
throw AppErrors.UnsupportedLayer
@@ -31,7 +35,7 @@ const TxSender: FC<{ scope: SearchScope; txHash: string }> = ({ scope, txHash })
}}
/>
) : senderAddress ? (
<AccountLink scope={scope} address={senderAddress} alwaysTrim />
<AccountLink scope={scope} address={senderAddress} alwaysTrim={alwaysTrim} />
) : (
t('common.missing')
)
@@ -41,7 +45,8 @@ export const ContractCreatorInfo: FC<{
scope: SearchScope
isLoading?: boolean
creationTxHash: string | undefined
}> = ({ scope, isLoading, creationTxHash }) => {
alwaysTrim?: boolean
}> = ({ scope, isLoading, creationTxHash, alwaysTrim }) => {
const { t } = useTranslation()
const { isMobile } = useScreenSize()

@@ -59,17 +64,18 @@ export const ContractCreatorInfo: FC<{
minWidth: '25%',
}}
>
<TxSender scope={scope} txHash={creationTxHash} />
<TxSender scope={scope} txHash={creationTxHash} alwaysTrim={alwaysTrim} />
<Box>{t('contract.createdAt')}</Box>
<TransactionLink scope={scope} hash={creationTxHash} alwaysTrim />
<TransactionLink scope={scope} hash={creationTxHash} alwaysTrim={alwaysTrim} />
</Box>
)
}

export const DelayedContractCreatorInfo: FC<{
scope: SearchScope
contractOasisAddress: string | undefined
}> = ({ scope, contractOasisAddress }) => {
alwaysTrim?: boolean
}> = ({ scope, contractOasisAddress, alwaysTrim }) => {
const accountQuery = useGetRuntimeAccountsAddress(
scope.network,
scope.layer as Runtime,
@@ -82,6 +88,11 @@ export const DelayedContractCreatorInfo: FC<{
const creationTxHash = contract?.eth_creation_tx || contract?.creation_tx

return (
<ContractCreatorInfo scope={scope} isLoading={accountQuery.isLoading} creationTxHash={creationTxHash} />
<ContractCreatorInfo
scope={scope}
isLoading={accountQuery.isLoading}
creationTxHash={creationTxHash}
alwaysTrim={alwaysTrim}
/>
)
}
1 change: 1 addition & 0 deletions src/app/components/Account/index.tsx
Original file line number Diff line number Diff line change
@@ -100,6 +100,7 @@ export const Account: FC<AccountProps> = ({ account, token, isLoading, tokenPric
<ContractCreatorInfo
scope={account}
creationTxHash={contract.eth_creation_tx || contract.creation_tx}
alwaysTrim
/>
</dd>
</>
2 changes: 1 addition & 1 deletion src/app/components/AccountList/index.tsx
Original file line number Diff line number Diff line change
@@ -39,7 +39,7 @@ export const AccountList: FC<AccountListProps> = ({ isLoading, limit, pagination
key: 'size',
},
{
content: <AccountLink scope={account} address={account.address} />,
content: <AccountLink scope={account} address={account.address} alwaysTrim />,
key: 'address',
},
...(verbose
6 changes: 5 additions & 1 deletion src/app/components/Tokens/TokenHolders.tsx
Original file line number Diff line number Diff line change
@@ -53,7 +53,11 @@ export const TokenHolders: FC<TokenHoldersProps> = ({
{
key: 'address',
content: (
<AccountLink scope={holder} address={holder.eth_holder_address || holder.holder_address} />
<AccountLink
scope={holder}
address={holder.eth_holder_address || holder.holder_address}
alwaysTrim
/>
),
},
{
6 changes: 5 additions & 1 deletion src/app/components/Tokens/TokenList.tsx
Original file line number Diff line number Diff line change
@@ -107,7 +107,11 @@ export const TokenList = (props: TokensProps) => {
{
content: (
<span>
<AccountLink scope={token} address={token.eth_contract_addr ?? token.contract_addr} />
<AccountLink
scope={token}
address={token.eth_contract_addr ?? token.contract_addr}
alwaysTrim
/>
<CopyToClipboard value={token.eth_contract_addr ?? token.contract_addr} />
</span>
),
4 changes: 2 additions & 2 deletions src/app/components/Tokens/TokenTransfers.tsx
Original file line number Diff line number Diff line change
@@ -186,7 +186,7 @@ export const TokenTransfers: FC<TokenTransfersProps> = ({
{trimLongString(fromAddress)}
</Typography>
) : (
<AccountLink scope={transfer} address={fromAddress} alwaysTrim={true} />
<AccountLink scope={transfer} address={fromAddress} alwaysTrim />
)}

<StyledCircle>
@@ -210,7 +210,7 @@ export const TokenTransfers: FC<TokenTransfersProps> = ({
{trimLongString(toAddress)}
</Typography>
) : (
<AccountLink scope={transfer} address={toAddress} alwaysTrim={true} />
<AccountLink scope={transfer} address={toAddress} alwaysTrim />
),
},
...(differentTokens
23 changes: 7 additions & 16 deletions src/app/components/Transactions/ConsensusTransactions.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import { FC } from 'react'
import { useTranslation } from 'react-i18next'
import Box from '@mui/material/Box'
import Typography from '@mui/material/Typography'
import { Transaction } from '../../../oasis-nexus/api'
import { Table, TableCellAlign, TableColProps } from '../../components/Table'
import { RoundedBalance } from '../../components/RoundedBalance'
import { trimLongString } from '../../utils/trimLongString'
import { TablePaginationProps } from '../Table/TablePagination'
import { BlockLink } from '../Blocks/BlockLink'
import { AccountLink } from '../Account/AccountLink'
@@ -66,7 +64,7 @@ export const ConsensusTransactions: FC<ConsensusTransactionsProps> = ({
key: 'success',
},
{
content: <TransactionLink scope={transaction} alwaysTrim={true} hash={transaction.hash} />,
content: <TransactionLink scope={transaction} alwaysTrim hash={transaction.hash} />,
key: 'hash',
},
{
@@ -95,19 +93,12 @@ export const ConsensusTransactions: FC<ConsensusTransactionsProps> = ({
pr: 3,
}}
>
{!!ownAddress && transaction.sender === ownAddress ? (
<Typography
variant="mono"
component="span"
sx={{
fontWeight: 700,
}}
>
{trimLongString(transaction.sender)}
</Typography>
) : (
<AccountLink scope={transaction} address={transaction.sender} alwaysTrim={true} />
)}
<AccountLink
scope={transaction}
address={transaction.sender}
alwaysTrim
plain={!!ownAddress && transaction.sender === ownAddress}
/>
</Box>
),
key: 'from',
56 changes: 18 additions & 38 deletions src/app/components/Transactions/RuntimeTransactions.tsx
Original file line number Diff line number Diff line change
@@ -14,8 +14,6 @@ import { TablePaginationProps } from '../Table/TablePagination'
import { BlockLink } from '../Blocks/BlockLink'
import { AccountLink } from '../Account/AccountLink'
import { TransactionLink } from './TransactionLink'
import { trimLongString } from '../../utils/trimLongString'
import Typography from '@mui/material/Typography'
import { doesAnyOfTheseLayersSupportEncryptedTransactions } from '../../../types/layers'
import { TransactionEncryptionStatus } from '../TransactionEncryptionStatus'
import { Age } from '../Age'
@@ -104,11 +102,7 @@ export const RuntimeTransactions: FC<TransactionsProps> = ({
: []),
{
content: (
<TransactionLink
scope={transaction}
alwaysTrim={true}
hash={transaction.eth_hash || transaction.hash}
/>
<TransactionLink scope={transaction} alwaysTrim hash={transaction.eth_hash || transaction.hash} />
),
key: 'hash',
},
@@ -139,24 +133,15 @@ export const RuntimeTransactions: FC<TransactionsProps> = ({
pr: 3,
}}
>
{!!ownAddress &&
(transaction.sender_0_eth === ownAddress || transaction.sender_0 === ownAddress) ? (
<Typography
variant="mono"
component="span"
sx={{
fontWeight: 700,
}}
>
{trimLongString(transaction.sender_0_eth || transaction.sender_0)}
</Typography>
) : (
<AccountLink
scope={transaction}
address={transaction.sender_0_eth || transaction.sender_0}
alwaysTrim={true}
/>
)}
<AccountLink
scope={transaction}
address={transaction.sender_0_eth || transaction.sender_0}
alwaysTrim
plain={
!!ownAddress &&
(transaction.sender_0_eth === ownAddress || transaction.sender_0 === ownAddress)
}
/>
{targetAddress && (
<StyledCircle>
<ArrowForwardIcon fontSize="inherit" />
@@ -168,19 +153,14 @@ export const RuntimeTransactions: FC<TransactionsProps> = ({
},
{
content: targetAddress ? (
!!ownAddress && (transaction.to_eth === ownAddress || transaction.to === ownAddress) ? (
<Typography
variant="mono"
component="span"
sx={{
fontWeight: 700,
}}
>
{trimLongString(targetAddress)}
</Typography>
) : (
<AccountLink scope={transaction} address={targetAddress} alwaysTrim={true} />
)
<AccountLink
scope={transaction}
address={targetAddress}
alwaysTrim
plain={
!!ownAddress && (transaction.to_eth === ownAddress || transaction.to === ownAddress)
}
/>
) : null,
key: 'to',
},
Original file line number Diff line number Diff line change
@@ -44,7 +44,7 @@ export const AccountNFTCollectionCard: FC<AccountDetailsContext> = ({ scope, add
isFetched &&
firstToken && (
<Box sx={{ display: 'flex', alignItems: 'flex-start', paddingY: 3 }}>
<AccountLink scope={scope} address={firstToken?.eth_contract_addr} />
<AccountLink scope={scope} address={firstToken?.eth_contract_addr} alwaysTrim />
<CopyToClipboard value={firstToken?.eth_contract_addr} />
</Box>
)
14 changes: 11 additions & 3 deletions src/app/pages/AccountDetailsPage/AccountTokensCard.tsx
Original file line number Diff line number Diff line change
@@ -30,10 +30,14 @@ type AccountTokensCardProps = AccountDetailsContext & {

export const accountTokenContainerId = 'tokens'

export const ContractLink: FC<{ scope: SearchScope; address: string }> = ({ scope, address }) => {
export const ContractLink: FC<{ scope: SearchScope; address: string; alwaysTrim?: boolean }> = ({
scope,
address,
alwaysTrim,
}) => {
return (
<Box sx={{ display: 'flex', alignContent: 'center' }}>
<AccountLink scope={scope} address={address} />
<AccountLink scope={scope} address={address} alwaysTrim={alwaysTrim} />
<CopyToClipboard value={address} />
</Box>
)
@@ -79,7 +83,11 @@ export const AccountTokensCard: FC<AccountTokensCardProps> = ({ scope, account,
{
content: (
<LinkableDiv id={item.token_contract_addr_eth ?? item.token_contract_addr}>
<ContractLink scope={scope} address={item.token_contract_addr_eth ?? item.token_contract_addr} />
<ContractLink
scope={scope}
address={item.token_contract_addr_eth ?? item.token_contract_addr}
alwaysTrim
/>
</LinkableDiv>
),
key: 'hash',
Original file line number Diff line number Diff line change
@@ -66,7 +66,7 @@ export const InstanceTitleCard: FC<InstanceTitleCardProps> = ({ isFetched, isLoa
}}
>
<VerificationIcon address_eth={token.eth_contract_addr} verified={token.is_verified} noLink />
<AccountLink scope={scope} address={displayAddress!} />
<AccountLink scope={scope} address={displayAddress!} alwaysTrim />
<CopyToClipboard value={displayAddress!} />
</Box>
</Box>
36 changes: 15 additions & 21 deletions src/app/pages/RuntimeTransactionDetailPage/index.tsx
Original file line number Diff line number Diff line change
@@ -270,24 +270,21 @@ export const RuntimeTransactionDetailView: FC<{
<>
<dt>{t('common.from')}</dt>
<dd>
<TransactionInfoTooltip
label={
<AccountLink
scope={transaction}
address={
from ||
((isOasisAddressFormat ? transaction?.sender_0_eth : transaction?.sender_0) as string)
}
plain={!from}
extraTooltip={
from
? isOasisAddressFormat
? t('transaction.tooltips.senderTooltipOasis')
: t('transaction.tooltips.senderTooltipEth')
: t('transaction.tooltips.senderTooltipUnavailable')
}
>
<AccountLink
scope={transaction}
address={
from ||
((isOasisAddressFormat ? transaction?.sender_0_eth : transaction?.sender_0) as string)
}
plain={!from}
/>
</TransactionInfoTooltip>
/>
{from && <CopyToClipboard value={from} />}
</dd>
</>
@@ -297,21 +294,18 @@ export const RuntimeTransactionDetailView: FC<{
<>
<dt>{t('common.to')}</dt>
<dd>
<TransactionInfoTooltip
label={
<AccountLink
scope={transaction}
address={to || ((isOasisAddressFormat ? transaction?.to_eth : transaction?.to) as string)}
plain={!to}
extraTooltip={
to
? isOasisAddressFormat
? t('transaction.tooltips.recipientTooltipOasis')
: t('transaction.tooltips.recipientTooltipEth')
: t('transaction.tooltips.recipientTooltipUnavailable')
}
>
<AccountLink
scope={transaction}
address={to || ((isOasisAddressFormat ? transaction?.to_eth : transaction?.to) as string)}
plain={!to}
/>
</TransactionInfoTooltip>
/>
{to && <CopyToClipboard value={to} />}
</dd>
</>
5 changes: 3 additions & 2 deletions src/app/pages/TokenDashboardPage/NFTLinks.tsx
Original file line number Diff line number Diff line change
@@ -66,8 +66,9 @@ export const NFTInstanceLink: FC<NFTLinkProps> = ({ scope, instance }) => {
type NFTOwnerLinkProps = {
scope: SearchScope
owner: string
alwaysTrim?: boolean
}
export const NFTOwnerLink: FC<NFTOwnerLinkProps> = ({ scope, owner }) => {
export const NFTOwnerLink: FC<NFTOwnerLinkProps> = ({ scope, owner, alwaysTrim }) => {
const { t } = useTranslation()

return (
@@ -76,7 +77,7 @@ export const NFTOwnerLink: FC<NFTOwnerLinkProps> = ({ scope, owner }) => {
i18nKey="nft.ownerLink"
t={t}
components={{
OwnerLink: <AccountLink scope={scope} address={owner} alwaysTrim={true} />,
OwnerLink: <AccountLink scope={scope} address={owner} alwaysTrim={alwaysTrim} />,
}}
/>
</StyledTypography>
Loading