Commit 493cdc6c authored by tom's avatar tom

token minted list

parent e6354ba1
...@@ -95,9 +95,12 @@ export const ROUTES = { ...@@ -95,9 +95,12 @@ export const ROUTES = {
crossNetworkNavigation: true, crossNetworkNavigation: true,
}, },
token_index: { token_index: {
pattern: `${ BASE_PATH }/token/[id]`, pattern: `${ BASE_PATH }/token/[hash]`,
crossNetworkNavigation: true, crossNetworkNavigation: true,
}, },
token_instance_item: {
pattern: `${ BASE_PATH }/token/[hash]/instance/[id]`,
},
// ADDRESSES // ADDRESSES
address_index: { address_index: {
......
import type { AddressParam } from './addressParams'; import type { AddressParam } from './addressParams';
export interface TokenTransfer { export type TokenTransfer = (
type: string; {
type: 'token_transfer';
total: {
value: string;
};
} |
{
type: 'token_minting';
total: {
token_id: string;
};
}
) & TokenTransferBase
interface TokenTransferBase {
txHash: string; txHash: string;
from: AddressParam; from: AddressParam;
to: AddressParam; to: AddressParam;
token_address: string; token_address: string;
token_symbol: string; token_symbol: string;
token_type: string; token_type: string;
total: {
value: string;
};
exchange_rate: string; exchange_rate: string;
} }
...@@ -14,7 +14,7 @@ interface Props { ...@@ -14,7 +14,7 @@ interface Props {
const TokenSnippet = ({ symbol, hash, name, className }: Props) => { const TokenSnippet = ({ symbol, hash, name, className }: Props) => {
const link = useLink(); const link = useLink();
const url = link('token_index', { id: hash }); const url = link('token_index', { hash });
return ( return (
<Center className={ className } columnGap={ 1 }> <Center className={ className } columnGap={ 1 }>
......
...@@ -21,7 +21,7 @@ const AddressLink = ({ alias, type, className, truncation = 'dynamic', hash, id, ...@@ -21,7 +21,7 @@ const AddressLink = ({ alias, type, className, truncation = 'dynamic', hash, id,
if (type === 'transaction') { if (type === 'transaction') {
url = link('tx_index', { id: id || hash }); url = link('tx_index', { id: id || hash });
} else if (type === 'token') { } else if (type === 'token') {
url = link('token_index', { id: id || hash }); url = link('token_index', { hash: id || hash });
} else if (type === 'block') { } else if (type === 'block') {
url = link('block_index', { id: id || hash }); url = link('block_index', { id: id || hash });
} else { } else {
......
import { Flex, Icon, Text } from '@chakra-ui/react'; import { Flex, Icon, Text, Link } from '@chakra-ui/react';
import React from 'react'; import React from 'react';
import type { TokenTransfer as TTokenTransfer } from 'types/api/tokenTransfer'; import type { TokenTransfer as TTokenTransfer } from 'types/api/tokenTransfer';
import rightArrowIcon from 'icons/arrows/east.svg'; import rightArrowIcon from 'icons/arrows/east.svg';
import { space } from 'lib/html-entities'; import { space } from 'lib/html-entities';
import useLink from 'lib/link/useLink';
import AddressLink from 'ui/shared/address/AddressLink'; import AddressLink from 'ui/shared/address/AddressLink';
import CurrencyValue from 'ui/shared/CurrencyValue'; import CurrencyValue from 'ui/shared/CurrencyValue';
import TokenSnippet from 'ui/shared/TokenSnippet'; import TokenSnippet from 'ui/shared/TokenSnippet';
type Props = TTokenTransfer type Props = TTokenTransfer
const TokenTransfer = ({ from, to, total, exchange_rate: exchangeRate, ...token }: Props) => { const TokenTransfer = ({ from, to, total, exchange_rate: exchangeRate, type, ...token }: Props) => {
const link = useLink();
const content = (() => {
switch (type) {
case 'token_transfer':
return (
<CurrencyValue value={ total.value } unit="ether" exchangeRate={ exchangeRate } fontWeight={ 600 }/>
);
case 'token_minting': {
const url = link('token_instance_item', { hash: token.token_address, id: total.token_id });
return <Text as="span">Token ID [<Link href={ url }>{ total.token_id }</Link>]</Text>;
}
}
})();
return ( return (
<Flex alignItems="center" flexWrap="wrap" columnGap={ 3 } rowGap={ 3 }> <Flex alignItems="center" flexWrap="wrap" columnGap={ 3 } rowGap={ 3 }>
<Flex alignItems="center"> <Flex alignItems="center">
...@@ -20,7 +37,7 @@ const TokenTransfer = ({ from, to, total, exchange_rate: exchangeRate, ...token ...@@ -20,7 +37,7 @@ const TokenTransfer = ({ from, to, total, exchange_rate: exchangeRate, ...token
<AddressLink fontWeight="500" hash={ to.hash } truncation="constant"/> <AddressLink fontWeight="500" hash={ to.hash } truncation="constant"/>
</Flex> </Flex>
<Text fontWeight={ 500 } as="span">For:{ space } <Text fontWeight={ 500 } as="span">For:{ space }
<CurrencyValue value={ total.value } unit="ether" exchangeRate={ exchangeRate } fontWeight={ 600 }/> { content }
</Text> </Text>
<TokenSnippet symbol={ token.token_symbol } hash={ token.token_address } name="Foo"/> <TokenSnippet symbol={ token.token_symbol } hash={ token.token_address } name="Foo"/>
</Flex> </Flex>
......
...@@ -164,7 +164,7 @@ const TxDecodedInputData = ({ data }: Props) => { ...@@ -164,7 +164,7 @@ const TxDecodedInputData = ({ data }: Props) => {
</Address> </Address>
) : ( ) : (
<Flex alignItems="flex-start" justifyContent="space-between" whiteSpace="normal" wordBreak="break-all"> <Flex alignItems="flex-start" justifyContent="space-between" whiteSpace="normal" wordBreak="break-all">
<Text>{ value }</Text> <Text>{ String(value) }</Text>
<CopyToClipboard text={ value }/> <CopyToClipboard text={ value }/>
</Flex> </Flex>
) } ) }
......
...@@ -66,6 +66,9 @@ const TxDetails = () => { ...@@ -66,6 +66,9 @@ const TxDetails = () => {
return <DataFetchAlert/>; return <DataFetchAlert/>;
} }
const transferredTokens = data.token_transfers?.filter(({ type }) => type === 'token_transfer') || [];
const mintedTokens = data.token_transfers?.filter(({ type }) => type === 'token_minting') || [];
return ( return (
<Grid columnGap={ 8 } rowGap={{ base: 3, lg: 3 }} templateColumns={{ base: 'minmax(0, 1fr)', lg: 'auto minmax(0, 1fr)' }}> <Grid columnGap={ 8 } rowGap={{ base: 3, lg: 3 }} templateColumns={{ base: 'minmax(0, 1fr)', lg: 'auto minmax(0, 1fr)' }}>
<DetailsInfoItem <DetailsInfoItem
...@@ -155,13 +158,23 @@ const TxDetails = () => { ...@@ -155,13 +158,23 @@ const TxDetails = () => {
</Tooltip> */ } </Tooltip> */ }
{ /* <TokenSnippet symbol="UP" name="User Pay" hash="0xA17ed5dFc62D0a3E74D69a0503AE9FdA65d9f212" ml={ 3 }/> */ } { /* <TokenSnippet symbol="UP" name="User Pay" hash="0xA17ed5dFc62D0a3E74D69a0503AE9FdA65d9f212" ml={ 3 }/> */ }
</DetailsInfoItem> </DetailsInfoItem>
{ (data.token_transfers?.length || 0) > 0 && ( { transferredTokens.length > 0 && (
<DetailsInfoItem <DetailsInfoItem
title="Token transferred" title="Token transferred"
hint="List of token transferred in the transaction." hint="List of token transferred in the transaction."
> >
<Flex flexDirection="column" alignItems="flex-start" rowGap={ 5 } w="100%"> <Flex flexDirection="column" alignItems="flex-start" rowGap={ 5 } w="100%">
{ data.token_transfers?.map((item, index) => <TokenTransfer key={ index } { ...item }/>) } { transferredTokens.map((item, index) => <TokenTransfer key={ index } { ...item }/>) }
</Flex>
</DetailsInfoItem>
) }
{ mintedTokens.length > 0 && (
<DetailsInfoItem
title="Token Minted"
hint="List of token minted in the transaction."
>
<Flex flexDirection="column" alignItems="flex-start" rowGap={ 5 } w="100%">
{ mintedTokens.map((item, index) => <TokenTransfer key={ index } { ...item }/>) }
</Flex> </Flex>
</DetailsInfoItem> </DetailsInfoItem>
) } ) }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment