Commit a30c0fd6 authored by isstuev's avatar isstuev Committed by tom goriunov

token transfer total is possibly null

parent 6a5ee48d
...@@ -27,19 +27,19 @@ export type Erc404TotalPayload = { ...@@ -27,19 +27,19 @@ export type Erc404TotalPayload = {
export type TokenTransfer = ( export type TokenTransfer = (
{ {
token: TokenInfo<'ERC-20'>; token: TokenInfo<'ERC-20'>;
total: Erc20TotalPayload; total: Erc20TotalPayload | null;
} | } |
{ {
token: TokenInfo<'ERC-721'>; token: TokenInfo<'ERC-721'>;
total: Erc721TotalPayload; total: Erc721TotalPayload | null;
} | } |
{ {
token: TokenInfo<'ERC-1155'>; token: TokenInfo<'ERC-1155'>;
total: Erc1155TotalPayload; total: Erc1155TotalPayload | null;
} | } |
{ {
token: TokenInfo<'ERC-404'>; token: TokenInfo<'ERC-404'>;
total: Erc404TotalPayload; total: Erc404TotalPayload | null;
} }
) & TokenTransferBase ) & TokenTransferBase
......
...@@ -36,7 +36,7 @@ const TokenTransferListItem = ({ ...@@ -36,7 +36,7 @@ const TokenTransferListItem = ({
enableTimeIncrement, enableTimeIncrement,
isLoading, isLoading,
}: Props) => { }: Props) => {
const { usd, valueStr } = 'value' in total && total.value !== null ? getCurrencyValue({ const { usd, valueStr } = total && 'value' in total && total.value !== null ? getCurrencyValue({
value: total.value, value: total.value,
exchangeRate: token.exchange_rate, exchangeRate: token.exchange_rate,
accuracy: 8, accuracy: 8,
......
...@@ -35,7 +35,7 @@ const TokenTransferTableItem = ({ ...@@ -35,7 +35,7 @@ const TokenTransferTableItem = ({
enableTimeIncrement, enableTimeIncrement,
isLoading, isLoading,
}: Props) => { }: Props) => {
const { usd, valueStr } = 'value' in total && total.value !== null ? getCurrencyValue({ const { usd, valueStr } = total && 'value' in total && total.value !== null ? getCurrencyValue({
value: total.value, value: total.value,
exchangeRate: token.exchange_rate, exchangeRate: token.exchange_rate,
accuracy: 8, accuracy: 8,
......
...@@ -30,7 +30,10 @@ const TokenTransferSnippet = ({ data, isLoading, noAddressIcons = true }: Props) ...@@ -30,7 +30,10 @@ const TokenTransferSnippet = ({ data, isLoading, noAddressIcons = true }: 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 | null;
if (total === null || total.value === null) {
return null;
}
return <TokenTransferSnippetFiat token={ data.token } value={ total.value } decimals={ total.decimals }/>; return <TokenTransferSnippetFiat token={ data.token } value={ total.value } decimals={ total.decimals }/>;
} }
...@@ -58,7 +61,10 @@ const TokenTransferSnippet = ({ data, isLoading, noAddressIcons = true }: Props) ...@@ -58,7 +61,10 @@ const TokenTransferSnippet = ({ data, isLoading, noAddressIcons = true }: Props)
} }
case 'ERC-404': { case 'ERC-404': {
const total = data.total as Erc404TotalPayload; const total = data.total as Erc404TotalPayload | null;
if (total === null) {
return null;
}
if (total.token_id !== null) { if (total.token_id !== null) {
return ( return (
......
...@@ -26,7 +26,7 @@ const TokenTransferListItem = ({ ...@@ -26,7 +26,7 @@ const TokenTransferListItem = ({
tokenId, tokenId,
isLoading, isLoading,
}: Props) => { }: Props) => {
const { usd, valueStr } = 'value' in total && total.value !== null ? getCurrencyValue({ const { usd, valueStr } = total && 'value' in total && total.value !== null ? getCurrencyValue({
value: total.value, value: total.value,
exchangeRate: token.exchange_rate, exchangeRate: token.exchange_rate,
accuracy: 8, accuracy: 8,
......
...@@ -24,7 +24,7 @@ const TokenTransferTableItem = ({ ...@@ -24,7 +24,7 @@ const TokenTransferTableItem = ({
tokenId, tokenId,
isLoading, isLoading,
}: Props) => { }: Props) => {
const { usd, valueStr } = 'value' in total && total.value !== null ? getCurrencyValue({ const { usd, valueStr } = total && 'value' in total && total.value !== null ? getCurrencyValue({
value: total.value, value: total.value,
exchangeRate: token.exchange_rate, exchangeRate: token.exchange_rate,
accuracy: 8, accuracy: 8,
......
...@@ -21,7 +21,7 @@ type Props = { ...@@ -21,7 +21,7 @@ type Props = {
const TokenTransfersListItem = ({ item, isLoading }: Props) => { const TokenTransfersListItem = ({ item, isLoading }: Props) => {
const { valueStr } = 'value' in item.total && item.total.value !== null ? getCurrencyValue({ const { valueStr } = item.total && 'value' in item.total && item.total.value !== null ? getCurrencyValue({
value: item.total.value, value: item.total.value,
exchangeRate: item.token.exchange_rate, exchangeRate: item.token.exchange_rate,
accuracy: 8, accuracy: 8,
......
...@@ -19,7 +19,7 @@ type Props = { ...@@ -19,7 +19,7 @@ type Props = {
} }
const TokenTransferTableItem = ({ item, isLoading }: Props) => { const TokenTransferTableItem = ({ item, isLoading }: Props) => {
const { valueStr } = 'value' in item.total && item.total.value !== null ? getCurrencyValue({ const { valueStr } = item.total && 'value' in item.total && item.total.value !== null ? getCurrencyValue({
value: item.total.value, value: item.total.value,
exchangeRate: item.token.exchange_rate, exchangeRate: item.token.exchange_rate,
accuracy: 8, accuracy: 8,
......
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