diff --git a/package-lock.json b/package-lock.json index fcb17c82..0e209ef0 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,7 +9,7 @@ "version": "0.6.5", "license": "Apache-2.0", "dependencies": { - "@covalenthq/client-sdk": "^2.0.3", + "@covalenthq/client-sdk": "^2.1.1", "@radix-ui/react-avatar": "^1.0.4", "@radix-ui/react-checkbox": "^1.0.4", "@radix-ui/react-dialog": "^1.0.5", @@ -2231,9 +2231,9 @@ "dev": true }, "node_modules/@covalenthq/client-sdk": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/@covalenthq/client-sdk/-/client-sdk-2.0.3.tgz", - "integrity": "sha512-8t3oXIXvgvZii90vaTeYVjch06jGJVoLXirkJ/eODHjuuNkWnp9lNWFaYb6r6nsRfI56MH4YaxCY1bXi8X9Nmg==", + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/@covalenthq/client-sdk/-/client-sdk-2.1.1.tgz", + "integrity": "sha512-wrtb6sn5cUOTOTD+GbE1Xi92b2Q2Wd76roK2wwUMdbOQ591ucahgSPfaJEgZY29nocLc3wDV2vhR11fNX8nZxA==", "license": "Apache-2.0", "dependencies": { "big.js": "^6.2.1" diff --git a/package.json b/package.json index 86a4cc46..96ea88b2 100644 --- a/package.json +++ b/package.json @@ -82,7 +82,7 @@ "vite-plugin-dts": "^3.8.2" }, "dependencies": { - "@covalenthq/client-sdk": "^2.0.3", + "@covalenthq/client-sdk": "^2.1.1", "@radix-ui/react-avatar": "^1.0.4", "@radix-ui/react-checkbox": "^1.0.4", "@radix-ui/react-dialog": "^1.0.5", diff --git a/src/components/Atoms/Address/Address.tsx b/src/components/Atoms/Address/Address.tsx index 1fb265b6..80bae3be 100644 --- a/src/components/Atoms/Address/Address.tsx +++ b/src/components/Atoms/Address/Address.tsx @@ -17,6 +17,10 @@ export const Address: React.FC = ({ avatar = null, actionable_address = () => null, }) => { + if (!address) { + return <>; + } + const [showCopy, setShowCopy] = useState(false); const { toast } = useToast(); diff --git a/src/components/Atoms/NFT/NFT.tsx b/src/components/Atoms/NFT/NFT.tsx index 2ef714ee..332de5e4 100644 --- a/src/components/Atoms/NFT/NFT.tsx +++ b/src/components/Atoms/NFT/NFT.tsx @@ -44,7 +44,7 @@ export const NFT: React.FC = ({ diff --git a/src/components/Atoms/Timestamp/Timestamp.tsx b/src/components/Atoms/Timestamp/Timestamp.tsx index ace8492c..a6c87bc7 100644 --- a/src/components/Atoms/Timestamp/Timestamp.tsx +++ b/src/components/Atoms/Timestamp/Timestamp.tsx @@ -8,6 +8,10 @@ export const Timestamp: React.FC = ({ defaultType = "relative", dynamic = true, }) => { + if (!timestamp) { + return <>; + } + const [relativeTime, setRelativeTime] = useState( defaultType === "relative" ); diff --git a/src/components/Molecules/Address/AddressActivityDetails/AddressActivityDetails.tsx b/src/components/Molecules/Address/AddressActivityDetails/AddressActivityDetails.tsx index bdef3646..2699c49f 100644 --- a/src/components/Molecules/Address/AddressActivityDetails/AddressActivityDetails.tsx +++ b/src/components/Molecules/Address/AddressActivityDetails/AddressActivityDetails.tsx @@ -56,7 +56,7 @@ export const AddressActivityDetails: React.FC = ({ if (error.error) { throw error; } - setMaybeResult(new Some(data.items)); + setMaybeResult(new Some(data!.items)); } catch (error: GoldRushResponse | any) { setErrorMessage( error?.error_message ?? DEFAULT_ERROR_MESSAGE diff --git a/src/components/Molecules/Address/AddressActivityList/AddressActivityList.tsx b/src/components/Molecules/Address/AddressActivityList/AddressActivityList.tsx index fff052bf..7aed72b9 100644 --- a/src/components/Molecules/Address/AddressActivityList/AddressActivityList.tsx +++ b/src/components/Molecules/Address/AddressActivityList/AddressActivityList.tsx @@ -56,7 +56,7 @@ export const AddressActivityList: React.FC = ({ if (error.error) { throw error; } - setMaybeResult(new Some(data.items)); + setMaybeResult(new Some(data!.items)); } catch (error: GoldRushResponse | any) { setErrorMessage( error?.error_message ?? DEFAULT_ERROR_MESSAGE @@ -85,7 +85,7 @@ export const AddressActivityList: React.FC = ({ only_primary={true} primary_url={row.original.logo_url} size={GRK_SIZES.EXTRA_EXTRA_SMALL} - chain_color={row.original.color_theme.hex} + chain_color={row.original.color_theme?.hex} /> {row.getValue("label")} diff --git a/src/components/Molecules/Address/AddressDetails/AddressDetails.tsx b/src/components/Molecules/Address/AddressDetails/AddressDetails.tsx index 82ccdc5f..e5aba151 100644 --- a/src/components/Molecules/Address/AddressDetails/AddressDetails.tsx +++ b/src/components/Molecules/Address/AddressDetails/AddressDetails.tsx @@ -68,7 +68,7 @@ export const AddressDetails: React.FC = ({ if (balancesError.error) { throw balancesError; } - const balances = balancesData.items; + const balances = balancesData!.items; const nativeTokenIndex = balances.findIndex( (token) => token.native_token ); @@ -129,19 +129,19 @@ export const AddressDetails: React.FC = ({ } primary_url={ native.logo_urls - .chain_logo_url + ?.chain_logo_url } chain_color={ selectedChain?.color_theme - .hex + ?.hex } only_primary /> {calculatePrettyBalance( native.balance ?? 0, - native.contract_decimals, + native.contract_decimals || 0, false, - native.contract_decimals + native.contract_decimals || 0 )}{" "} {native.contract_ticker_symbol} @@ -157,7 +157,7 @@ export const AddressDetails: React.FC = ({ ) ), subtext: `@${prettifyCurrency( - native.quote_rate + native.quote_rate || 0 )}/${native.contract_ticker_symbol}`, }, { @@ -199,12 +199,12 @@ export const AddressDetails: React.FC = ({ GRK_SIZES.EXTRA_EXTRA_SMALL } primary_url={ - logo_urls.token_logo_url + logo_urls?.token_logo_url } chain_color={ selectedChain ?.color_theme - .hex + ?.hex } /> @@ -219,7 +219,8 @@ export const AddressDetails: React.FC = ({ <> {calculatePrettyBalance( balance, - contract_decimals, + contract_decimals || + 0, true )}{" "} { @@ -241,7 +242,10 @@ export const AddressDetails: React.FC = ({ heading: "LATEST TRANSACTION", content: (
= ({ subtext: ( ), @@ -260,7 +265,8 @@ export const AddressDetails: React.FC = ({ content: (
= ({ subtext: ( ), }, { heading: "TOTAL COUNT", - content: `${total_count.toLocaleString()} transactions`, + content: `${total_count?.toLocaleString()} transactions`, }, ] as CardDetailProps[] ).map((props) => ( diff --git a/src/components/Shared/Transactions.tsx b/src/components/Shared/Transactions.tsx index 08fff53f..7f089e4f 100644 --- a/src/components/Shared/Transactions.tsx +++ b/src/components/Shared/Transactions.tsx @@ -50,7 +50,7 @@ export const Transactions: React.FC = ({

{actionableWrapper( actionable_block(row.original.block_height), - row.original.block_height.toLocaleString() + row.original.block_height?.toLocaleString() )}

); @@ -128,9 +128,9 @@ export const Transactions: React.FC = ({

{calculatePrettyBalance( row.original.value, - row.original.gas_metadata.contract_decimals + row.original.gas_metadata?.contract_decimals )}{" "} - {row.original.gas_metadata.contract_ticker_symbol} + {row.original.gas_metadata?.contract_ticker_symbol}

) : (

-

@@ -152,7 +152,7 @@ export const Transactions: React.FC = ({

{calculatePrettyBalance( row.original.fees_paid, - row.original.gas_metadata.contract_decimals + row.original.gas_metadata?.contract_decimals )}

) : ( diff --git a/src/utils/types/atoms.types.ts b/src/utils/types/atoms.types.ts index 5727f80e..89ed19ce 100644 --- a/src/utils/types/atoms.types.ts +++ b/src/utils/types/atoms.types.ts @@ -9,11 +9,11 @@ import { } from "@covalenthq/client-sdk"; export interface AddressProps { - address: string; + address: string | null; label?: string | null; show_copy_icon?: boolean; avatar?: Omit; - actionable_address?: (address: string) => ActionableType; + actionable_address?: (address: string | null) => ActionableType; } export interface AddressCardProps { @@ -22,7 +22,7 @@ export interface AddressCardProps { avatar: Omit; show_copy_icon?: boolean; show_qr_code?: boolean; - actionable_address?: (address: string) => ActionableType; + actionable_address?: (address: string | null) => ActionableType; } export interface NFTProps { @@ -33,11 +33,11 @@ export interface NFTProps { attributes?: NftCollectionAttribute[]; children?: React.ReactNode; chain_name?: Chain; - actionable_contract?: (contract_address: string) => ActionableType; + actionable_contract?: (contract_address: string | null) => ActionableType; } export interface TimestampProps { - timestamp: string | Date; + timestamp: string | Date | null; defaultType?: "relative" | "descriptive"; dynamic?: boolean; } @@ -57,7 +57,7 @@ export interface PoolProps { token_1_ticker_symbol: string; token_0_logo_url: string; token_1_logo_url: string; - actionable_pool?: (address: string) => ActionableType; + actionable_pool?: (address: string | null) => ActionableType; } export interface TokenAvatarProps { diff --git a/src/utils/types/molecules.types.ts b/src/utils/types/molecules.types.ts index 98b5209b..080313cd 100644 --- a/src/utils/types/molecules.types.ts +++ b/src/utils/types/molecules.types.ts @@ -38,8 +38,8 @@ export interface NFTApprovalListProps { spender: NftApprovalSpender, contract_address: string ) => void; - actionable_spender?: (address: string) => ActionableType; - actionable_token?: (address: string) => ActionableType; + actionable_spender?: (address: string | null) => ActionableType; + actionable_token?: (address: string | null) => ActionableType; } export interface TokenApprovalListProps { @@ -49,8 +49,8 @@ export interface TokenApprovalListProps { spender: TokenSpenderItem, token_address: string ) => void; - actionable_spender?: (address: string) => ActionableType; - actionable_token?: (address: string) => ActionableType; + actionable_spender?: (address: string | null) => ActionableType; + actionable_token?: (address: string | null) => ActionableType; } export interface BlockDetailsProps { @@ -61,26 +61,26 @@ export interface BlockDetailsProps { export interface BlocksListProps { chain_name: Chain; page_size?: number; - actionable_block?: (block_height: number) => ActionableType; + actionable_block?: (block_height: number | null) => ActionableType; } export interface LatestBlocksProps { chain_name: Chain; page_size?: number; - actionable_block?: (block_height: number) => ActionableType; + actionable_block?: (block_height: number | null) => ActionableType; } export interface TransactionsListProps { chain_name: Chain; - actionable_block?: (block_height: number) => ActionableType; - actionable_transaction?: (tx_hash: string) => ActionableType; - actionable_address?: (address: string) => ActionableType; + actionable_block?: (block_height: number | null) => ActionableType; + actionable_transaction?: (tx_hash: string | null) => ActionableType; + actionable_address?: (address: string | null) => ActionableType; } export interface LatestTransactionsProps { chain_name: Chain; - actionable_transaction?: (address: string) => ActionableType; - actionable_address?: (address: string) => ActionableType; + actionable_transaction?: (address: string | null) => ActionableType; + actionable_address?: (address: string | null) => ActionableType; } export interface LatestPriceProps { @@ -94,7 +94,7 @@ export interface GasCardProps { export interface AddressDetailsProps { address: string; chain_name: Chain; - actionable_transaction?: (tx_hash: string) => ActionableType; + actionable_transaction?: (tx_hash: string | null) => ActionableType; } export interface ChainSelectorProps { @@ -120,7 +120,7 @@ export interface NFTWalletCollectionListProps { address: string; maybeResult?: Option | null; errorMessage?: string | null; - actionable_contract?: (address: string) => ActionableType; + actionable_contract?: (address: string | null) => ActionableType; } export interface AddressTransactionsProps extends Partial { @@ -138,7 +138,7 @@ export interface TokenBalancesListProps { address: string; hide_small_balances?: boolean; mask_balances?: boolean; - actionable_token?: (token_address: string) => ActionableType; + actionable_token?: (token_address: string | null) => ActionableType; } export interface TokenTransfersListProps { @@ -146,8 +146,8 @@ export interface TokenTransfersListProps { address: string; contract_address: string; page_size?: number; - actionable_from?: (address: string) => ActionableType; - actionable_to?: (address: string) => ActionableType; + actionable_from?: (address: string | null) => ActionableType; + actionable_to?: (address: string | null) => ActionableType; } export interface CrossChainBalanceItem extends BalanceItem { @@ -157,10 +157,10 @@ export interface CrossChainBalanceItem extends BalanceItem { export interface TransactionDetailsProps { chain_name: Chain; tx_hash: string; - actionable_block?: (block: number) => ActionableType; - actionable_transaction?: (address: string) => ActionableType; - actionable_from?: (address: string) => ActionableType; - actionable_to?: (address: string) => ActionableType; + actionable_block?: (block: number | null) => ActionableType; + actionable_transaction?: (address: string | null) => ActionableType; + actionable_from?: (address: string | null) => ActionableType; + actionable_to?: (address: string | null) => ActionableType; } export type EventDetails = { @@ -223,7 +223,7 @@ export interface DecodedTransactionType { export interface TransactionReceiptProps { chain_name: Chain; tx_hash: string; - actionable_transaction?: (address: string) => ActionableType; - actionable_from?: (address: string) => ActionableType; - actionable_to?: (address: string) => ActionableType; + actionable_transaction?: (address: string | null) => ActionableType; + actionable_from?: (address: string | null) => ActionableType; + actionable_to?: (address: string | null) => ActionableType; } diff --git a/src/utils/types/organisms.types.ts b/src/utils/types/organisms.types.ts index b0641137..1d3aeb40 100644 --- a/src/utils/types/organisms.types.ts +++ b/src/utils/types/organisms.types.ts @@ -4,7 +4,7 @@ import { type Chain } from "@covalenthq/client-sdk"; export interface NFTWalletCollectionViewProps { chain_name: Chain; address: string; - actionable_address?: (address: string) => ActionableType; + actionable_address?: (address: string | null) => ActionableType; } export interface NFTWalletTokenListViewProps { @@ -16,12 +16,12 @@ export interface NFTCollectionViewProps { chain_name: Chain; collection_address: string; page_size?: number; - actionable_address?: (address: string) => ActionableType; + actionable_address?: (address: string | null) => ActionableType; } export interface AddressActivityViewProps { address: string; - actionable_address?: (address: string) => ActionableType; + actionable_address?: (address: string | null) => ActionableType; } export interface AddressDetailsViewProps { diff --git a/src/utils/types/shared.types.ts b/src/utils/types/shared.types.ts index 470f250b..973a97db 100644 --- a/src/utils/types/shared.types.ts +++ b/src/utils/types/shared.types.ts @@ -38,9 +38,9 @@ export interface IconWrapperProps { export interface TransactionsProps { maybeResult: Option; errorMessage: string | null; - actionable_transaction?: (tx_hash: string) => ActionableType; - actionable_block?: (block_height: number) => ActionableType; - actionable_address?: (address: string) => ActionableType; + actionable_transaction?: (tx_hash: string | null) => ActionableType; + actionable_block?: (block_height: number | null) => ActionableType; + actionable_address?: (address: string | null) => ActionableType; } export interface TokenApprovalsTableProps {