mirror of
https://github.com/luxfi/explore.git
synced 2026-09-24 00:28:18 +00:00
token transfer total is possibly null
This commit is contained in:
@@ -27,19 +27,19 @@ export type Erc404TotalPayload = {
|
||||
export type TokenTransfer = (
|
||||
{
|
||||
token: TokenInfo<'ERC-20'>;
|
||||
total: Erc20TotalPayload;
|
||||
total: Erc20TotalPayload | null;
|
||||
} |
|
||||
{
|
||||
token: TokenInfo<'ERC-721'>;
|
||||
total: Erc721TotalPayload;
|
||||
total: Erc721TotalPayload | null;
|
||||
} |
|
||||
{
|
||||
token: TokenInfo<'ERC-1155'>;
|
||||
total: Erc1155TotalPayload;
|
||||
total: Erc1155TotalPayload | null;
|
||||
} |
|
||||
{
|
||||
token: TokenInfo<'ERC-404'>;
|
||||
total: Erc404TotalPayload;
|
||||
total: Erc404TotalPayload | null;
|
||||
}
|
||||
) & TokenTransferBase
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ const TokenTransferListItem = ({
|
||||
enableTimeIncrement,
|
||||
isLoading,
|
||||
}: 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,
|
||||
exchangeRate: token.exchange_rate,
|
||||
accuracy: 8,
|
||||
|
||||
@@ -35,7 +35,7 @@ const TokenTransferTableItem = ({
|
||||
enableTimeIncrement,
|
||||
isLoading,
|
||||
}: 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,
|
||||
exchangeRate: token.exchange_rate,
|
||||
accuracy: 8,
|
||||
|
||||
@@ -30,7 +30,10 @@ const TokenTransferSnippet = ({ data, isLoading, noAddressIcons = true }: Props)
|
||||
|
||||
switch (data.token.type) {
|
||||
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 }/>;
|
||||
}
|
||||
|
||||
@@ -58,7 +61,10 @@ const TokenTransferSnippet = ({ data, isLoading, noAddressIcons = true }: Props)
|
||||
}
|
||||
|
||||
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) {
|
||||
return (
|
||||
|
||||
@@ -26,7 +26,7 @@ const TokenTransferListItem = ({
|
||||
tokenId,
|
||||
isLoading,
|
||||
}: 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,
|
||||
exchangeRate: token.exchange_rate,
|
||||
accuracy: 8,
|
||||
|
||||
@@ -24,7 +24,7 @@ const TokenTransferTableItem = ({
|
||||
tokenId,
|
||||
isLoading,
|
||||
}: 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,
|
||||
exchangeRate: token.exchange_rate,
|
||||
accuracy: 8,
|
||||
|
||||
@@ -21,7 +21,7 @@ type 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,
|
||||
exchangeRate: item.token.exchange_rate,
|
||||
accuracy: 8,
|
||||
|
||||
@@ -19,7 +19,7 @@ type 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,
|
||||
exchangeRate: item.token.exchange_rate,
|
||||
accuracy: 8,
|
||||
|
||||
Reference in New Issue
Block a user