Skip to content

Commit

Permalink
Display Token Type in account token transfers
Browse files Browse the repository at this point in the history
  • Loading branch information
csillag committed Jul 10, 2023
1 parent 5618b81 commit 7970432
Showing 1 changed file with 27 additions and 1 deletion.
28 changes: 27 additions & 1 deletion src/app/components/Tokens/TokenTransfers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import Skeleton from '@mui/material/Skeleton'
import { TokenLink } from './TokenLink'
import { PlaceholderLabel } from '../../utils/placeholderLabel'
import { useTokenWithBase64Address } from './hooks'
import { TokenTypeTag } from './TokenList'

const NULL_ADDRESS = '0x0000000000000000000000000000000000000000'

Expand Down Expand Up @@ -102,6 +103,19 @@ const DelayedEventBalance: FC<{
}
}

const DelayedTokenTransferTokenType: FC<{ event: RuntimeEvent }> = ({ event }) => {
const { t } = useTranslation()
const { isLoading, isError, token } = useTokenWithBase64Address(event, event.body.address)

if (isLoading) {
return <Skeleton variant="text" />
}
if (isError || !token) {
return t('common.missing')
}
return <TokenTypeTag tokenType={token.type} />
}

type TokenTransfersProps = {
transfers?: TableRuntimeEvent[]
/**
Expand Down Expand Up @@ -133,6 +147,9 @@ export const TokenTransfers: FC<TokenTransfersProps> = ({
{ key: 'type', content: t('common.type'), align: TableCellAlign.Center },
{ key: 'from', content: t('common.from'), width: '150px' },
{ key: 'to', content: t('common.to'), width: '150px' },
...(differentTokens
? [{ key: 'tokenType', content: t('tokens.type'), align: TableCellAlign.Center }]
: []),
{ key: 'value', align: TableCellAlign.Right, content: t('common.value'), width: '250px' },
]
const tableRows = transfers?.map((transfer, index) => {
Expand Down Expand Up @@ -223,7 +240,16 @@ export const TokenTransfers: FC<TokenTransfersProps> = ({
<AccountLink scope={transfer} address={toAddress} alwaysTrim={true} />
),
},

...(differentTokens
? [
{
key: 'tokenType',
// TODO: temporary workaround until token type becomes available as part of RuntimeEvent
content: <DelayedTokenTransferTokenType event={transfer} />,
align: TableCellAlign.Center,
},
]
: []),
{
key: 'value',
align: TableCellAlign.Right,
Expand Down

0 comments on commit 7970432

Please sign in to comment.