Commit 0dbb04b0 authored by Igor Stuev's avatar Igor Stuev Committed by GitHub

Merge pull request #1780 from blockscout/1280-hf2

1280 hf2
parents 3fd7f42b 586831e3
...@@ -208,6 +208,7 @@ export const erc404A: TokenTransfer = { ...@@ -208,6 +208,7 @@ export const erc404A: TokenTransfer = {
total: { total: {
value: '42000000000000000000000000', value: '42000000000000000000000000',
decimals: '18', decimals: '18',
token_id: null,
}, },
tx_hash: '0x05d6589367633c032d757a69c5fb16c0e33e3994b0d9d1483f82aeee1f05d746', tx_hash: '0x05d6589367633c032d757a69c5fb16c0e33e3994b0d9d1483f82aeee1f05d746',
type: 'token_transfer', type: 'token_transfer',
......
...@@ -17,10 +17,11 @@ export type Erc1155TotalPayload = { ...@@ -17,10 +17,11 @@ export type Erc1155TotalPayload = {
} }
export type Erc404TotalPayload = { export type Erc404TotalPayload = {
decimals: string | null; decimals: string;
value: string | null; value: string;
token_id: null;
} | { } | {
token_id: string | null; token_id: string;
}; };
export type TokenTransfer = ( export type TokenTransfer = (
......
...@@ -27,6 +27,7 @@ const init = () => { ...@@ -27,6 +27,7 @@ const init = () => {
'--w3m-z-index': zIndices.modal, '--w3m-z-index': zIndices.modal,
}, },
featuredWalletIds: [], featuredWalletIds: [],
allowUnsupportedChain: true,
}); });
} catch (error) {} } catch (error) {}
}; };
......
import { chakra } from '@chakra-ui/react';
import React from 'react';
import type { TokenInfo } from 'types/api/token';
import getCurrencyValue from 'lib/getCurrencyValue';
import TokenEntity from 'ui/shared/entities/token/TokenEntity';
interface Props {
token: TokenInfo;
value: string;
decimals: string | null;
}
const FtTokenTransferSnippet = ({ token, value, decimals }: Props) => {
const { valueStr, usd } = getCurrencyValue({
value: value,
exchangeRate: token.exchange_rate,
accuracyUsd: 2,
decimals: decimals,
});
return (
<>
<chakra.span color="text_secondary">for</chakra.span>
<span>{ valueStr }</span>
<TokenEntity
token={{ ...token, name: token.symbol || token.name }}
noCopy
noSymbol
w="auto"
/>
{ usd && <chakra.span color="text_secondary">(${ usd })</chakra.span> }
</>
);
};
export default React.memo(FtTokenTransferSnippet);
import { Flex, chakra } from '@chakra-ui/react'; import { Flex } from '@chakra-ui/react';
import React from 'react'; import React from 'react';
import type { import type {
...@@ -9,11 +9,11 @@ import type { ...@@ -9,11 +9,11 @@ import type {
Erc404TotalPayload, Erc404TotalPayload,
} from 'types/api/tokenTransfer'; } from 'types/api/tokenTransfer';
import getCurrencyValue from 'lib/getCurrencyValue';
import AddressFromTo from 'ui/shared/address/AddressFromTo'; import AddressFromTo from 'ui/shared/address/AddressFromTo';
import TokenEntity from 'ui/shared/entities/token/TokenEntity';
import NftTokenTransferSnippet from 'ui/tx/NftTokenTransferSnippet'; import NftTokenTransferSnippet from 'ui/tx/NftTokenTransferSnippet';
import FtTokenTransferSnippet from '../FtTokenTransferSnippet';
interface Props { interface Props {
data: TTokenTransfer; data: TTokenTransfer;
} }
...@@ -24,26 +24,7 @@ const TxDetailsTokenTransfer = ({ data }: Props) => { ...@@ -24,26 +24,7 @@ const TxDetailsTokenTransfer = ({ data }: Props) => {
switch (data.token.type) { switch (data.token.type) {
case 'ERC-20': { case 'ERC-20': {
const total = data.total as Erc20TotalPayload; const total = data.total as Erc20TotalPayload;
const { valueStr, usd } = getCurrencyValue({ return <FtTokenTransferSnippet token={ data.token } value={ total.value } decimals={ total.decimals }/>;
value: total.value,
exchangeRate: data.token.exchange_rate,
accuracyUsd: 2,
decimals: total.decimals,
});
return (
<>
<chakra.span color="text_secondary">for</chakra.span>
<span>{ valueStr }</span>
<TokenEntity
token={{ ...data.token, name: data.token.symbol || data.token.name }}
noCopy
noSymbol
w="auto"
/>
{ usd && <chakra.span color="text_secondary">(${ usd })</chakra.span> }
</>
);
} }
case 'ERC-721': { case 'ERC-721': {
...@@ -71,16 +52,22 @@ const TxDetailsTokenTransfer = ({ data }: Props) => { ...@@ -71,16 +52,22 @@ const TxDetailsTokenTransfer = ({ data }: Props) => {
case 'ERC-404': { case 'ERC-404': {
const total = data.total as Erc404TotalPayload; const total = data.total as Erc404TotalPayload;
if (total.token_id !== null) {
return ( return (
<NftTokenTransferSnippet <NftTokenTransferSnippet
token={ data.token } token={ data.token }
tokenId={ 'token_id' in total ? total.token_id : null } tokenId={ total.token_id }
value={ 'value' in total && total.value ? value="1"
getCurrencyValue({ value: total.value, decimals: total.decimals || '0', accuracy: 2 }).valueStr :
'1'
}
/> />
); );
} else {
if (total.value === null) {
return null;
}
return <FtTokenTransferSnippet token={ data.token } value={ total.value } decimals={ total.decimals }/>;
}
} }
} }
})(); })();
......
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