diff --git a/.prettierrc.json b/.prettierrc.json
index dbe0e42b..6ffbfd86 100644
--- a/.prettierrc.json
+++ b/.prettierrc.json
@@ -6,7 +6,7 @@
"singleQuote": false,
"quoteProps": "as-needed",
"jsxSingleQuote": false,
- "trailingComma": "es5",
+ "trailingComma": "all",
"bracketSpacing": true,
"bracketSameLine": false,
"arrowParens": "always",
diff --git a/.storybook/manager.ts b/.storybook/manager.ts
index dcd4805b..529a035f 100644
--- a/.storybook/manager.ts
+++ b/.storybook/manager.ts
@@ -5,7 +5,8 @@ export const defaultTheme: ThemeVars = {
...themes.dark,
appBg: "black",
colorSecondary: "#FF4C8B",
- brandImage: "../src/static/goldrush-powered-by-covalent.svg",
+ brandImage:
+ "https://github.com/covalenthq/goldrush-kit/blob/main/src/static/goldrush-powered-by-covalent.svg",
base: "light",
brandTitle: "GoldRush Kit - powered by Covalent",
brandUrl: "https://github.com/covalenthq/goldrush-kit/",
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.stories.tsx b/src/components/Atoms/Address/Address.stories.tsx
index 3c82853a..3344aa33 100644
--- a/src/components/Atoms/Address/Address.stories.tsx
+++ b/src/components/Atoms/Address/Address.stories.tsx
@@ -15,6 +15,6 @@ export const Address: Story = {
args: {
address: "0xd8da6bf26964af9d7eed9e03e53415d37aa96045",
show_copy_icon: true,
- actionable_address: (address: string) => storyAction(address),
+ actionable_address: (address) => storyAction(address),
},
};
diff --git a/src/components/Atoms/Address/Address.tsx b/src/components/Atoms/Address/Address.tsx
index 1fb265b6..bcfae25f 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();
@@ -39,7 +43,7 @@ export const Address: React.FC = ({
{actionableWrapper(
actionable_address(address),
- label?.trim() || truncate(address)
+ label?.trim() || truncate(address),
)}
{show_copy_icon && (
diff --git a/src/components/Atoms/AddressAvatar/AddressAvatar.tsx b/src/components/Atoms/AddressAvatar/AddressAvatar.tsx
index f9a9d80d..1fb0dc12 100644
--- a/src/components/Atoms/AddressAvatar/AddressAvatar.tsx
+++ b/src/components/Atoms/AddressAvatar/AddressAvatar.tsx
@@ -51,7 +51,7 @@ export const AddressAvatar: React.FC = ({
const BG_COLOR = useMemo(
() => stringToColor(address),
- [address]
+ [address],
);
return (
diff --git a/src/components/Atoms/AddressCard/AddressCard.stories.tsx b/src/components/Atoms/AddressCard/AddressCard.stories.tsx
index a8e7bf0f..102c2510 100644
--- a/src/components/Atoms/AddressCard/AddressCard.stories.tsx
+++ b/src/components/Atoms/AddressCard/AddressCard.stories.tsx
@@ -15,6 +15,6 @@ export const AddressCard: Story = {
args: {
address: "0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045",
avatar: {},
- actionable_address: (address: string) => storyAction(address),
+ actionable_address: (address) => storyAction(address),
},
};
diff --git a/src/components/Atoms/NFT/NFT.stories.tsx b/src/components/Atoms/NFT/NFT.stories.tsx
index a4f5a798..40971608 100644
--- a/src/components/Atoms/NFT/NFT.stories.tsx
+++ b/src/components/Atoms/NFT/NFT.stories.tsx
@@ -52,6 +52,6 @@ export const NFT: Story = {
value: "Passion Red",
},
],
- actionable_contract: (address: string) => storyAction(address),
+ actionable_contract: (address) => storyAction(address),
},
};
diff --git a/src/components/Atoms/NFT/NFT.tsx b/src/components/Atoms/NFT/NFT.tsx
index 2ef714ee..fe72dbf3 100644
--- a/src/components/Atoms/NFT/NFT.tsx
+++ b/src/components/Atoms/NFT/NFT.tsx
@@ -25,7 +25,7 @@ export const NFT: React.FC = ({
const chain = useMemo(
() => chains?.find((o) => o.name === chain_name) ?? null,
- [chains, chain_name]
+ [chains, chain_name],
);
return (
@@ -44,7 +44,7 @@ export const NFT: React.FC = ({
@@ -56,7 +56,7 @@ export const NFT: React.FC = ({
storyAction(address),
+ actionable_pool: (address) => storyAction(address),
},
};
diff --git a/src/components/Atoms/Pool/Pool.tsx b/src/components/Atoms/Pool/Pool.tsx
index b1147550..ac401c56 100644
--- a/src/components/Atoms/Pool/Pool.tsx
+++ b/src/components/Atoms/Pool/Pool.tsx
@@ -28,7 +28,7 @@ export const Pool: React.FC = ({
{actionableWrapper(
actionable_pool(pool_address),
- `${token_0_ticker_symbol}-${token_1_ticker_symbol}`
+ `${token_0_ticker_symbol}-${token_1_ticker_symbol}`,
)}
);
diff --git a/src/components/Atoms/Timestamp/Timestamp.tsx b/src/components/Atoms/Timestamp/Timestamp.tsx
index ace8492c..4ca3f3a3 100644
--- a/src/components/Atoms/Timestamp/Timestamp.tsx
+++ b/src/components/Atoms/Timestamp/Timestamp.tsx
@@ -8,11 +8,15 @@ export const Timestamp: React.FC = ({
defaultType = "relative",
dynamic = true,
}) => {
+ if (!timestamp) {
+ return <>>;
+ }
+
const [relativeTime, setRelativeTime] = useState(
- defaultType === "relative"
+ defaultType === "relative",
);
const [parsedTime, setParsedTime] = useState(
- timestampParser(timestamp, relativeTime ? "relative" : "descriptive")
+ timestampParser(timestamp, relativeTime ? "relative" : "descriptive"),
);
useEffect(() => {
@@ -23,8 +27,8 @@ export const Timestamp: React.FC = ({
setParsedTime(
timestampParser(
timestamp,
- relativeTime ? "relative" : "descriptive"
- )
+ relativeTime ? "relative" : "descriptive",
+ ),
);
}, 1000);
}
@@ -39,7 +43,10 @@ export const Timestamp: React.FC = ({
const handleToggle = useCallback((isRelative: boolean) => {
setRelativeTime(!isRelative);
setParsedTime(
- timestampParser(timestamp, !isRelative ? "relative" : "descriptive")
+ timestampParser(
+ timestamp,
+ !isRelative ? "relative" : "descriptive",
+ ),
);
}, []);
diff --git a/src/components/Atoms/TokenAvatar/TokenAvatar.tsx b/src/components/Atoms/TokenAvatar/TokenAvatar.tsx
index 943e0f27..9c1cba70 100644
--- a/src/components/Atoms/TokenAvatar/TokenAvatar.tsx
+++ b/src/components/Atoms/TokenAvatar/TokenAvatar.tsx
@@ -51,7 +51,7 @@ export const TokenAvatar: React.FC = ({
await themedSvg(
primaryRef,
primary_url || "",
- DefaultToken.toString()
+ DefaultToken.toString(),
);
})();
}, [primary_url, primaryRef]);
@@ -62,7 +62,7 @@ export const TokenAvatar: React.FC = ({
await themedSvg(
secondaryRef,
secondary_url || "",
- DefaultToken.toString()
+ DefaultToken.toString(),
);
}
})();
diff --git a/src/components/Molecules/Address/AddressActivityDetails/AddressActivityDetails.tsx b/src/components/Molecules/Address/AddressActivityDetails/AddressActivityDetails.tsx
index bdef3646..3cc2ca5f 100644
--- a/src/components/Molecules/Address/AddressActivityDetails/AddressActivityDetails.tsx
+++ b/src/components/Molecules/Address/AddressActivityDetails/AddressActivityDetails.tsx
@@ -4,6 +4,7 @@ import { Skeleton } from "@/components/ui/skeleton";
import {
GRK_SIZES,
DEFAULT_ERROR_MESSAGE,
+ FALLBACK_ERROR,
} from "@/utils/constants/shared.constants";
import { type Option, None, Some } from "@/utils/option";
import { useGoldRush } from "@/utils/store";
@@ -25,7 +26,7 @@ export const AddressActivityDetails: React.FC = ({
const [maybeResult, setMaybeResult] =
useState
,
)}
wrapperClassName="flex flex-col-reverse"
/>
@@ -95,10 +99,11 @@ export const LatestBlocks: React.FC = ({
))
diff --git a/src/components/Molecules/ChainSelector/ChainSelector.tsx b/src/components/Molecules/ChainSelector/ChainSelector.tsx
index d46c4146..2a11856b 100644
--- a/src/components/Molecules/ChainSelector/ChainSelector.tsx
+++ b/src/components/Molecules/ChainSelector/ChainSelector.tsx
@@ -42,7 +42,7 @@ export const ChainSelector: React.FC = ({
chains.find(
({ name, chain_id }) =>
name === nameOrId ||
- chain_id.toString() === nameOrId.toString()
+ chain_id?.toString() === nameOrId.toString(),
) ?? null;
if (foundChain) {
acc.push(foundChain);
@@ -67,7 +67,7 @@ export const ChainSelector: React.FC = ({
{selectedChain.label}
@@ -94,7 +94,7 @@ export const ChainSelector: React.FC = ({
{dropdownChains.map((chain) => (
{
setSelectedChain(chain);
diff --git a/src/components/Molecules/GasCard/GasCard.tsx b/src/components/Molecules/GasCard/GasCard.tsx
index e6ec49de..2f462308 100644
--- a/src/components/Molecules/GasCard/GasCard.tsx
+++ b/src/components/Molecules/GasCard/GasCard.tsx
@@ -4,25 +4,20 @@ import { Skeleton } from "@/components/ui/skeleton";
import {
GRK_SIZES,
DEFAULT_ERROR_MESSAGE,
+ FALLBACK_ERROR,
} from "@/utils/constants/shared.constants";
import type { Option } from "@/utils/option";
import { None, Some } from "@/utils/option";
import { useGoldRush } from "@/utils/store";
-import { type GasCardProps } from "@/utils/types/molecules.types";
-import type {
- GoldRushResponse,
- GasPricesResponse,
-} from "@covalenthq/client-sdk";
+import type { GasCardData, GasCardProps } from "@/utils/types/molecules.types";
+import type { GoldRushResponse } from "@covalenthq/client-sdk";
import { useEffect, useMemo, useState } from "react";
export const GasCard: React.FC = ({ chain_name }) => {
- const [isErc20, setIsErc20] = useState(true);
- const [maybeResult, setMaybeResult] = useState<
- Option<{
- erc: GasPricesResponse;
- native: GasPricesResponse;
- } | null>
- >(None);
+ const [selectedValue, setSelectedValue] =
+ useState("erc");
+ const [maybeResult, setMaybeResult] =
+ useState>(None);
const [errorMessage, setErrorMessage] = useState(null);
const { goldrushClient } = useGoldRush();
@@ -37,11 +32,11 @@ export const GasCard: React.FC = ({ chain_name }) => {
] = await Promise.all([
goldrushClient.BaseService.getGasPrices(
chain_name,
- "erc20"
+ "erc20",
),
await goldrushClient.BaseService.getGasPrices(
chain_name,
- "nativetokens"
+ "nativetokens",
),
]);
if (ercError.error) {
@@ -50,11 +45,19 @@ export const GasCard: React.FC = ({ chain_name }) => {
if (nativeError.error) {
throw nativeError;
}
+ if (
+ !ercData ||
+ !ercData.items ||
+ !nativeData ||
+ !nativeData.items
+ ) {
+ throw FALLBACK_ERROR;
+ }
setMaybeResult(
new Some({
erc: ercData,
native: nativeData,
- })
+ }),
);
} catch (error: GoldRushResponse | any) {
setErrorMessage(error?.error_message ?? DEFAULT_ERROR_MESSAGE);
@@ -114,7 +117,7 @@ export const GasCard: React.FC = ({ chain_name }) => {
content: "High",
},
],
- []
+ [],
);
return (
@@ -160,76 +163,82 @@ export const GasCard: React.FC = ({ chain_name }) => {
{Math.round(
(Number(
- result?.[
- isErc20 ? "erc" : "native"
- ].base_fee
- ) ?? 0) / Math.pow(10, 9)
+ result?.[selectedValue]
+ .base_fee,
+ ) ?? 0) / Math.pow(10, 9),
)}{" "}
Gwei
- {result[isErc20 ? "erc" : "native"].items
- .sort(
- (a, b) =>
- parseInt(a.gas_price) -
- parseInt(b.gas_price)
- )
- .map(
- (
- {
- interval,
- gas_price,
- pretty_total_gas_quote,
- },
- i
- ) => (
-
-
- {copy[i].logo}
-
+ {result?.[selectedValue]?.items &&
+ result[selectedValue].items
+ .sort(
+ (a, b) =>
+ Number(a.gas_price) -
+ Number(b.gas_price),
+ )
+ .map(
+ (
+ {
+ interval,
+ gas_price,
+ pretty_total_gas_quote,
+ },
+ i,
+ ) => (
+
+
+ {copy[i].logo}
+
-
- {copy[i].content}
+
+ {copy[i].content}
-
- {Math.round(
- parseInt(gas_price) /
- Math.pow(10, 9)
- ).toFixed(0)}{" "}
- Gwei
-
- (
- {pretty_total_gas_quote}
- )
-
-
+
+ {Math.round(
+ Number(gas_price) /
+ Math.pow(10, 9),
+ ).toFixed(0)}{" "}
+ Gwei
+
+ (
+ {
+ pretty_total_gas_quote
+ }
+ )
+
+
-
- {interval}
-
+
+ {interval}
+
+
-
- )
- )}
+ ),
+ )}
- )
+ ),
)}
) : (
<>>
)}
- )
+ ),
)}
@@ -471,28 +460,28 @@ export const TransactionReceipt: React.FC = ({
title={calculatePrettyBalance(
BigInt(
result.tx_metadata
- .fees_paid || 0
+ .fees_paid || 0,
)!,
result.tx_metadata
.gas_metadata
- .contract_decimals
+ ?.contract_decimals,
)}
>
{calculatePrettyBalance(
BigInt(
result.tx_metadata
- .fees_paid || 0
+ .fees_paid || 0,
)!,
result.tx_metadata
.gas_metadata
- .contract_decimals,
+ ?.contract_decimals,
true,
- 4
+ 4,
)}{" "}
{
result.tx_metadata
.gas_metadata
- .contract_ticker_symbol
+ ?.contract_ticker_symbol
}{" "}
{
@@ -516,7 +505,7 @@ export const TransactionReceipt: React.FC = ({
{
result.tx_metadata
.gas_metadata
- .contract_ticker_symbol
+ ?.contract_ticker_symbol
}
@@ -531,18 +520,18 @@ export const TransactionReceipt: React.FC = ({
{calculatePrettyBalance(
BigInt(
result.tx_metadata
- .gas_price
+ ?.gas_price ?? 0,
),
result.tx_metadata
.gas_metadata
- .contract_decimals,
+ ?.contract_decimals,
true,
- 10
+ 10,
)}{" "}
{
result.tx_metadata
.gas_metadata
- .contract_ticker_symbol
+ ?.contract_ticker_symbol
}
@@ -550,13 +539,13 @@ export const TransactionReceipt: React.FC = ({
View on{" "}
- {result.tx_metadata.explorers[0].label ??
+ {result.tx_metadata.explorers?.[0].label ??
"Explorer"}
>
diff --git a/src/components/Molecules/Transaction/TransactionsList/TransactionsList.tsx b/src/components/Molecules/Transaction/TransactionsList/TransactionsList.tsx
index 60a83f9d..944ed1ca 100644
--- a/src/components/Molecules/Transaction/TransactionsList/TransactionsList.tsx
+++ b/src/components/Molecules/Transaction/TransactionsList/TransactionsList.tsx
@@ -1,6 +1,9 @@
import { Address, Timestamp } from "@/components/Atoms";
import { TableHeaderSorting, TableList } from "@/components/Shared";
-import { DEFAULT_ERROR_MESSAGE } from "@/utils/constants/shared.constants";
+import {
+ DEFAULT_ERROR_MESSAGE,
+ FALLBACK_ERROR,
+} from "@/utils/constants/shared.constants";
import { actionableWrapper, timestampParser } from "@/utils/functions";
import { None, Some, type Option } from "@/utils/option";
import { useGoldRush } from "@/utils/store";
@@ -36,27 +39,33 @@ export const TransactionsList: React.FC = ({
"2100-01-01",
{
pageSize: 1,
- }
+ },
);
if (blockError.error) {
setErrorMessage(blockError.error_message);
throw blockError;
}
+ if (!blockData?.items?.[0]) {
+ throw FALLBACK_ERROR;
+ }
const latestBlock = blockData.items[0];
const { data: txData, ...txError } =
await goldrushClient.TransactionService.getTransactionsForBlock(
chain_name,
- latestBlock.height - 2,
+ Number(latestBlock.height) - 2,
{
noLogs: true,
quoteCurrency: "USD",
withSafe: false,
- }
+ },
);
if (txError.error) {
setErrorMessage(txError.error_message);
throw txError;
}
+ if (!txData?.items) {
+ throw FALLBACK_ERROR;
+ }
setMaybeResult(new Some(txData.items));
} catch (error: GoldRushResponse | any) {
setErrorMessage(error?.error_message ?? DEFAULT_ERROR_MESSAGE);
@@ -108,7 +117,7 @@ export const TransactionsList: React.FC = ({
cell: ({ row }) =>
actionableWrapper(
actionable_block(row.original.block_height),
- row.original.block_height.toLocaleString()
+ row.original.block_height?.toLocaleString(),
),
},
{
@@ -149,11 +158,11 @@ export const TransactionsList: React.FC = ({
{calculatePrettyBalance(
row.original.value ?? 0,
- row.original.gas_metadata.contract_decimals,
+ row.original.gas_metadata?.contract_decimals,
true,
- 4
+ 4,
)}{" "}
- {row.original.gas_metadata.contract_ticker_symbol}
+ {row.original.gas_metadata?.contract_ticker_symbol}
{row.original.pretty_value_quote}
@@ -174,11 +183,11 @@ export const TransactionsList: React.FC
= ({
{calculatePrettyBalance(
BigInt(row.original.fees_paid || 0)!,
- row.original.gas_metadata.contract_decimals,
+ row.original.gas_metadata?.contract_decimals,
true,
- 4
+ 4,
)}{" "}
- {row.original.gas_metadata.contract_ticker_symbol}
+ {row.original.gas_metadata?.contract_ticker_symbol}
{row.original.pretty_gas_quote}
diff --git a/src/components/Organisms/AddressActivityView/AddressActivityView.stories.tsx b/src/components/Organisms/AddressActivityView/AddressActivityView.stories.tsx
index fb828d2c..50d56c7f 100644
--- a/src/components/Organisms/AddressActivityView/AddressActivityView.stories.tsx
+++ b/src/components/Organisms/AddressActivityView/AddressActivityView.stories.tsx
@@ -14,6 +14,6 @@ export default meta;
export const AddressActivityView: Story = {
args: {
address: "demo.eth",
- actionable_address: (address: string) => storyAction(address),
+ actionable_address: (address) => storyAction(address),
},
};
diff --git a/src/components/Organisms/AddressActivityView/AddressActivityView.tsx b/src/components/Organisms/AddressActivityView/AddressActivityView.tsx
index c1c72ec2..3990746f 100644
--- a/src/components/Organisms/AddressActivityView/AddressActivityView.tsx
+++ b/src/components/Organisms/AddressActivityView/AddressActivityView.tsx
@@ -3,7 +3,10 @@ import {
AddressActivityDetails,
AddressActivityList,
} from "@/components/Molecules";
-import { DEFAULT_ERROR_MESSAGE } from "@/utils/constants/shared.constants";
+import {
+ DEFAULT_ERROR_MESSAGE,
+ FALLBACK_ERROR,
+} from "@/utils/constants/shared.constants";
import { type Option, None, Some } from "@/utils/option";
import { useGoldRush } from "@/utils/store";
import { type AddressActivityViewProps } from "@/utils/types/organisms.types";
@@ -32,11 +35,14 @@ export const AddressActivityView: React.FC
= ({
address.trim(),
{
testnets: true,
- }
+ },
);
if (error.error) {
throw error;
}
+ if (!data?.items) {
+ throw FALLBACK_ERROR;
+ }
setMaybeResult(new Some(data.items));
} catch (error: GoldRushResponse | any) {
setErrorMessage(error?.error_message ?? DEFAULT_ERROR_MESSAGE);
diff --git a/src/components/Organisms/NFTCollectionView/NFTCollectionView.stories.tsx b/src/components/Organisms/NFTCollectionView/NFTCollectionView.stories.tsx
index 60d10d92..4ceb8479 100644
--- a/src/components/Organisms/NFTCollectionView/NFTCollectionView.stories.tsx
+++ b/src/components/Organisms/NFTCollectionView/NFTCollectionView.stories.tsx
@@ -15,6 +15,6 @@ export const NFTCollectionView: Story = {
args: {
chain_name: "eth-mainnet",
collection_address: "0xBC4CA0EdA7647A8aB7C2061c2E118A18a936f13D",
- actionable_address: (address: string) => storyAction(address),
+ actionable_address: (address) => storyAction(address),
},
};
diff --git a/src/components/Organisms/NFTWalletCollectionView/NFTWalletCollectionView.stories.tsx b/src/components/Organisms/NFTWalletCollectionView/NFTWalletCollectionView.stories.tsx
index eac680a7..e6ab7bd8 100644
--- a/src/components/Organisms/NFTWalletCollectionView/NFTWalletCollectionView.stories.tsx
+++ b/src/components/Organisms/NFTWalletCollectionView/NFTWalletCollectionView.stories.tsx
@@ -15,6 +15,6 @@ export const NFTWalletCollectionView: Story = {
args: {
chain_name: "eth-mainnet",
address: "0x1ae705a28f1cca0363b5d709159220aa2fe551de",
- actionable_address: (address: string) => storyAction(address),
+ actionable_address: (address) => storyAction(address),
},
};
diff --git a/src/components/Organisms/NFTWalletCollectionView/NFTWalletCollectionView.tsx b/src/components/Organisms/NFTWalletCollectionView/NFTWalletCollectionView.tsx
index 47d87801..b8ce40f0 100644
--- a/src/components/Organisms/NFTWalletCollectionView/NFTWalletCollectionView.tsx
+++ b/src/components/Organisms/NFTWalletCollectionView/NFTWalletCollectionView.tsx
@@ -3,7 +3,10 @@ import {
NFTWalletCollectionDetails,
NFTWalletCollectionList,
} from "@/components/Molecules";
-import { DEFAULT_ERROR_MESSAGE } from "@/utils/constants/shared.constants";
+import {
+ DEFAULT_ERROR_MESSAGE,
+ FALLBACK_ERROR,
+} from "@/utils/constants/shared.constants";
import { type Option, Some, None } from "@/utils/option";
import { useGoldRush } from "@/utils/store";
import { type NFTWalletCollectionViewProps } from "@/utils/types/organisms.types";
@@ -29,11 +32,14 @@ export const NFTWalletCollectionView: React.FC<
const { data, ...error } =
await goldrushClient.NftService.getNftsForAddress(
chain_name,
- address
+ address,
);
if (error.error) {
throw error;
}
+ if (!data?.items) {
+ throw FALLBACK_ERROR;
+ }
setMaybeResult(new Some(data.items));
} catch (error: GoldRushResponse | any) {
setErrorMessage(error?.error_message ?? DEFAULT_ERROR_MESSAGE);
diff --git a/src/components/Shared/BalancePriceDelta.tsx b/src/components/Shared/BalancePriceDelta.tsx
index 6a5ecb18..a7eb8250 100644
--- a/src/components/Shared/BalancePriceDelta.tsx
+++ b/src/components/Shared/BalancePriceDelta.tsx
@@ -7,7 +7,7 @@ export const BalancePriceDelta: React.FC = ({
}) => {
const DELTA = useMemo(
() => (1.0 - numerator / denominator) * 100,
- [numerator, denominator]
+ [numerator, denominator],
);
if (DELTA > 0) {
diff --git a/src/components/Shared/PaginationFooter.tsx b/src/components/Shared/PaginationFooter.tsx
index a45214d6..b1806d18 100644
--- a/src/components/Shared/PaginationFooter.tsx
+++ b/src/components/Shared/PaginationFooter.tsx
@@ -18,12 +18,12 @@ export const PaginationFooter: React.FC = ({
}) => {
const prevEnabled = useMemo(
() => !disabled && (pagination?.page_number || 0) > 0,
- [disabled, pagination]
+ [disabled, pagination],
);
const nextEnabled = useMemo(
() => !disabled && (pagination?.has_more ?? false),
- [disabled, pagination]
+ [disabled, pagination],
);
return pagination ? (
diff --git a/src/components/Shared/TableHeaderSorting.tsx b/src/components/Shared/TableHeaderSorting.tsx
index 59dcac4e..3c910bb1 100644
--- a/src/components/Shared/TableHeaderSorting.tsx
+++ b/src/components/Shared/TableHeaderSorting.tsx
@@ -2,7 +2,7 @@ import { IconWrapper } from ".";
import { type TableHeaderSortingProps } from "@/utils/types/shared.types";
export const TableHeaderSorting: (
- props: TableHeaderSortingProps
+ props: TableHeaderSortingProps,
) => React.ReactNode = ({ header, column, align, icon = true }) => {
const sortedIcon =
column.getIsSorted() === "asc"
diff --git a/src/components/Shared/TableList.tsx b/src/components/Shared/TableList.tsx
index 2336ff6f..332cddbc 100644
--- a/src/components/Shared/TableList.tsx
+++ b/src/components/Shared/TableList.tsx
@@ -58,13 +58,13 @@ export const TableList: (props: TableListProps) => React.ReactNode = ({
{flexRender(
cell.column.columnDef.cell,
- cell.getContext()
+ cell.getContext(),
)}
))}
),
- []
+ [],
);
return (
@@ -80,7 +80,7 @@ export const TableList: (props: TableListProps) => React.ReactNode = ({
onClick={() =>
header.column.toggleSorting(
header.column.getIsSorted() ===
- "asc"
+ "asc",
)
}
>
@@ -89,7 +89,7 @@ export const TableList: (props: TableListProps) => React.ReactNode = ({
: flexRender(
header.column.columnDef
.header,
- header.getContext()
+ header.getContext(),
)}
);
@@ -114,7 +114,7 @@ export const TableList: (props: TableListProps) => React.ReactNode = ({
customRows ? (
customRows(
table.getRowModel().rows,
- defaultRow
+ defaultRow,
)
) : (
table
diff --git a/src/components/Shared/Transactions.tsx b/src/components/Shared/Transactions.tsx
index 08fff53f..57393ee3 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/components/ThemeConfig/ThemeConfig.tsx b/src/components/ThemeConfig/ThemeConfig.tsx
index c7153902..60c25dac 100644
--- a/src/components/ThemeConfig/ThemeConfig.tsx
+++ b/src/components/ThemeConfig/ThemeConfig.tsx
@@ -123,7 +123,7 @@ export const ThemeConfig: React.FC = () => {
{mode} {shade}
- )
+ ),
)}
diff --git a/src/components/ui/avatar.tsx b/src/components/ui/avatar.tsx
index e38afe29..d0f1ad3f 100644
--- a/src/components/ui/avatar.tsx
+++ b/src/components/ui/avatar.tsx
@@ -10,7 +10,7 @@ const Avatar = forwardRef<
ref={ref}
className={cn(
"relative flex h-10 w-10 shrink-0 overflow-hidden rounded-full",
- className
+ className,
)}
{...props}
/>
@@ -37,7 +37,7 @@ const AvatarFallback = forwardRef<
ref={ref}
className={cn(
"bg-muted flex h-full w-full items-center justify-center rounded-full",
- className
+ className,
)}
{...props}
/>
diff --git a/src/components/ui/badge.tsx b/src/components/ui/badge.tsx
index 306d37b0..4636a804 100644
--- a/src/components/ui/badge.tsx
+++ b/src/components/ui/badge.tsx
@@ -21,7 +21,7 @@ const badgeVariants = cva(
defaultVariants: {
variant: "default",
},
- }
+ },
);
export interface BadgeProps
diff --git a/src/components/ui/button.tsx b/src/components/ui/button.tsx
index 0ff40ab4..a1bd7370 100644
--- a/src/components/ui/button.tsx
+++ b/src/components/ui/button.tsx
@@ -26,7 +26,7 @@ const buttonVariants = cva(
variant: "primary",
size: "default",
},
- }
+ },
);
export interface ButtonProps
@@ -45,7 +45,7 @@ const Button = forwardRef(
{...props}
/>
);
- }
+ },
);
Button.displayName = "Button";
diff --git a/src/components/ui/card.tsx b/src/components/ui/card.tsx
index 86f61256..6af786a6 100644
--- a/src/components/ui/card.tsx
+++ b/src/components/ui/card.tsx
@@ -7,11 +7,11 @@ const Card = forwardRef>(
ref={ref}
className={cn(
"rounded border border-secondary-light bg-background-light text-sm text-foreground-light dark:border-secondary-dark dark:bg-background-dark dark:text-foreground-dark",
- className
+ className,
)}
{...props}
/>
- )
+ ),
);
Card.displayName = "Card";
@@ -47,7 +47,7 @@ const CardDescription = forwardRef<
ref={ref}
className={cn(
"text-sm text-secondary-light dark:text-secondary-dark",
- className
+ className,
)}
{...props}
/>
diff --git a/src/components/ui/checkbox.tsx b/src/components/ui/checkbox.tsx
index 3bd4b408..20a553e8 100644
--- a/src/components/ui/checkbox.tsx
+++ b/src/components/ui/checkbox.tsx
@@ -11,7 +11,7 @@ const Checkbox = forwardRef<
ref={ref}
className={cn(
"peer h-4 w-4 shrink-0 rounded-sm border border-primary-light shadow focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary-light data-[state=checked]:text-foreground-light dark:border-primary-dark dark:data-[state=checked]:bg-primary-dark dark:data-[state=checked]:text-foreground-dark",
- className
+ className,
)}
{...props}
>
diff --git a/src/components/ui/command.tsx b/src/components/ui/command.tsx
index 31aa19a1..33704e39 100644
--- a/src/components/ui/command.tsx
+++ b/src/components/ui/command.tsx
@@ -13,7 +13,7 @@ const Command = forwardRef<
ref={ref}
className={cn(
"flex h-full w-full flex-col overflow-hidden rounded-md bg-background-light text-foreground-light dark:bg-background-dark dark:text-foreground-dark",
- className
+ className,
)}
{...props}
/>
@@ -44,7 +44,7 @@ const CommandInput = forwardRef<
ref={ref}
className={cn(
"flex h-10 w-full rounded-md bg-transparent py-3 text-sm outline-none placeholder:text-secondary-light disabled:cursor-not-allowed disabled:opacity-50 dark:placeholder:text-secondary-dark",
- className
+ className,
)}
{...props}
/>
@@ -61,7 +61,7 @@ const CommandList = forwardRef<
ref={ref}
className={cn(
"max-h-[300px] overflow-y-auto overflow-x-hidden",
- className
+ className,
)}
{...props}
/>
@@ -90,7 +90,7 @@ const CommandGroup = forwardRef<
ref={ref}
className={cn(
"overflow-hidden p-1 text-foreground-light dark:text-foreground-dark [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-primary-light dark:[&_[cmdk-group-heading]]:text-primary-dark",
- className
+ className,
)}
{...props}
/>
@@ -106,7 +106,7 @@ const CommandSeparator = forwardRef<
ref={ref}
className={cn(
"-mx-1 h-px bg-background-light dark:bg-background-dark",
- className
+ className,
)}
{...props}
/>
@@ -121,7 +121,7 @@ const CommandItem = forwardRef<
ref={ref}
className={cn(
"relative flex cursor-pointer select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none hover:bg-primary-light data-[disabled]:pointer-events-none data-[disabled]:opacity-50 dark:hover:bg-primary-dark",
- className
+ className,
)}
{...props}
/>
@@ -137,7 +137,7 @@ const CommandShortcut = ({
diff --git a/src/components/ui/dialog.tsx b/src/components/ui/dialog.tsx
index 80b88eec..f643b9d2 100644
--- a/src/components/ui/dialog.tsx
+++ b/src/components/ui/dialog.tsx
@@ -19,7 +19,7 @@ const DialogOverlay = forwardRef<
ref={ref}
className={cn(
"bg-background-light/80 dark:bg-background-dark/80 fixed inset-0 z-50 backdrop-blur-sm data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",
- className
+ className,
)}
{...props}
/>
@@ -36,7 +36,7 @@ const DialogContent = forwardRef<
ref={ref}
className={cn(
"fixed left-1/2 top-1/2 z-50 grid w-full max-w-lg translate-x-1/2 translate-y-1/2 gap-4 border bg-background-light p-6 shadow-xl duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] dark:bg-background-dark sm:rounded-lg",
- className
+ className,
)}
{...props}
>
@@ -57,7 +57,7 @@ const DialogHeader = ({
@@ -71,7 +71,7 @@ const DialogFooter = ({
@@ -86,7 +86,7 @@ const DialogTitle = forwardRef<
ref={ref}
className={cn(
"text-lg font-semibold leading-none tracking-tight",
- className
+ className,
)}
{...props}
/>
diff --git a/src/components/ui/dropdown-menu.tsx b/src/components/ui/dropdown-menu.tsx
index f578555d..18267f24 100644
--- a/src/components/ui/dropdown-menu.tsx
+++ b/src/components/ui/dropdown-menu.tsx
@@ -30,7 +30,7 @@ const DropdownMenuSubTrigger = forwardRef<
className={cn(
"flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-background-light data-[state=open]:bg-background-light dark:focus:bg-background-dark dark:data-[state=open]:bg-background-dark",
inset && "pl-8",
- className
+ className,
)}
{...props}
>
@@ -49,7 +49,7 @@ const DropdownMenuSubContent = forwardRef<
ref={ref}
className={cn(
"z-50 min-w-[8rem] overflow-hidden rounded-md border bg-background-light p-1 text-foreground-light shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 dark:bg-background-dark dark:text-foreground-dark",
- className
+ className,
)}
{...props}
/>
@@ -68,7 +68,7 @@ const DropdownMenuContent = forwardRef<
className={cn(
"z-50 min-w-[8rem] overflow-hidden rounded-md border bg-background-light p-1 text-foreground-light shadow-md dark:bg-background-dark dark:text-foreground-dark",
"data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",
- className
+ className,
)}
{...props}
/>
@@ -87,7 +87,7 @@ const DropdownMenuItem = forwardRef<
className={cn(
"relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-colors focus:bg-background-light focus:text-foreground-light data-[disabled]:pointer-events-none data-[disabled]:opacity-50 dark:focus:bg-background-dark dark:focus:text-foreground-dark",
inset && "pl-8",
- className
+ className,
)}
{...props}
/>
@@ -102,7 +102,7 @@ const DropdownMenuCheckboxItem = forwardRef<
ref={ref}
className={cn(
"relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-background-light focus:text-secondary-light data-[disabled]:pointer-events-none data-[disabled]:opacity-50 dark:focus:bg-background-dark dark:focus:text-secondary-dark",
- className
+ className,
)}
checked={checked}
{...props}
@@ -126,7 +126,7 @@ const DropdownMenuRadioItem = forwardRef<
ref={ref}
className={cn(
"relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-background-light focus:text-secondary-light data-[disabled]:pointer-events-none data-[disabled]:opacity-50 dark:focus:bg-background-dark dark:focus:text-secondary-dark",
- className
+ className,
)}
{...props}
>
@@ -151,7 +151,7 @@ const DropdownMenuLabel = forwardRef<
className={cn(
"px-2 py-1.5 text-sm font-semibold",
inset && "pl-8",
- className
+ className,
)}
{...props}
/>
@@ -166,7 +166,7 @@ const DropdownMenuSeparator = forwardRef<
ref={ref}
className={cn(
"-mx-1 my-1 h-px bg-background-light bg-opacity-85 dark:bg-background-dark",
- className
+ className,
)}
{...props}
/>
@@ -181,7 +181,7 @@ const DropdownMenuShortcut = ({
diff --git a/src/components/ui/input.tsx b/src/components/ui/input.tsx
index b1bb1c51..21626769 100644
--- a/src/components/ui/input.tsx
+++ b/src/components/ui/input.tsx
@@ -11,13 +11,13 @@ const Input = forwardRef(
type={type}
className={cn(
"flex h-9 w-full rounded-md border border-primary-light bg-transparent px-3 py-1 text-sm shadow-sm transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-secondary-light placeholder:text-opacity-85 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 dark:border-primary-dark dark:placeholder:text-secondary-dark",
- className
+ className,
)}
ref={ref}
{...props}
/>
);
- }
+ },
);
Input.displayName = "Input";
diff --git a/src/components/ui/pagination.tsx b/src/components/ui/pagination.tsx
index 347e648b..5e09c5f2 100644
--- a/src/components/ui/pagination.tsx
+++ b/src/components/ui/pagination.tsx
@@ -32,7 +32,7 @@ PaginationContent.displayName = "PaginationContent";
const PaginationItem = forwardRef>(
({ className, ...props }, ref) => (
- )
+ ),
);
PaginationItem.displayName = "PaginationItem";
@@ -54,7 +54,7 @@ const PaginationLink = ({
variant: isActive ? "outline" : "ghost",
size,
}),
- className
+ className,
)}
{...props}
/>
diff --git a/src/components/ui/popover.tsx b/src/components/ui/popover.tsx
index 1042c6c8..a5332ec6 100644
--- a/src/components/ui/popover.tsx
+++ b/src/components/ui/popover.tsx
@@ -19,7 +19,7 @@ const PopoverContent = forwardRef<
sideOffset={sideOffset}
className={cn(
"z-50 w-72 rounded-md border border-secondary-light bg-background-light p-4 text-foreground-light shadow-md outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 dark:border-secondary-dark dark:bg-background-dark dark:text-foreground-dark",
- className
+ className,
)}
{...props}
/>
diff --git a/src/components/ui/skeleton.tsx b/src/components/ui/skeleton.tsx
index 1ad30d50..4572f3ab 100644
--- a/src/components/ui/skeleton.tsx
+++ b/src/components/ui/skeleton.tsx
@@ -36,7 +36,7 @@ function Skeleton({
className={cn(
"animate-pulse rounded border bg-secondary-light dark:bg-secondary-dark",
sizeClass(),
- className
+ className,
)}
{...props}
/>
diff --git a/src/components/ui/table.tsx b/src/components/ui/table.tsx
index 8d0341d4..2dc5c6ec 100644
--- a/src/components/ui/table.tsx
+++ b/src/components/ui/table.tsx
@@ -43,7 +43,7 @@ const TableFooter = forwardRef<
ref={ref}
className={cn(
"border-t bg-primary-light bg-opacity-55 font-medium dark:bg-primary-dark [&>tr]:last:border-b-0",
- className
+ className,
)}
{...props}
/>
@@ -58,7 +58,7 @@ const TableRow = forwardRef<
ref={ref}
className={cn(
"border-b border-secondary-light transition-colors hover:bg-secondary-light data-[state=selected]:bg-primary-light dark:border-secondary-dark dark:hover:bg-secondary-dark dark:data-[state=selected]:bg-primary-dark",
- className
+ className,
)}
{...props}
/>
@@ -73,7 +73,7 @@ const TableHead = forwardRef<
ref={ref}
className={cn(
"h-10 px-2 text-left align-middle font-medium text-foreground-light opacity-75 dark:text-foreground-dark [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]",
- className
+ className,
)}
{...props}
/>
@@ -88,7 +88,7 @@ const TableCell = forwardRef<
ref={ref}
className={cn(
"p-2 align-middle [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]",
- className
+ className,
)}
{...props}
/>
@@ -103,7 +103,7 @@ const TableCaption = forwardRef<
ref={ref}
className={cn(
"mt-4 text-sm text-foreground-light dark:text-foreground-dark",
- className
+ className,
)}
{...props}
/>
diff --git a/src/components/ui/toast.tsx b/src/components/ui/toast.tsx
index b5355007..e6361ba3 100644
--- a/src/components/ui/toast.tsx
+++ b/src/components/ui/toast.tsx
@@ -14,7 +14,7 @@ const ToastViewport = React.forwardRef<
ref={ref}
className={cn(
"fixed top-0 z-[100] flex max-h-screen w-full flex-col-reverse break-all p-4 sm:bottom-0 sm:right-0 sm:top-auto sm:flex-col md:max-w-fit",
- className
+ className,
)}
{...props}
/>
@@ -33,7 +33,7 @@ const toastVariants = cva(
defaultVariants: {
variant: "default",
},
- }
+ },
);
const Toast = React.forwardRef<
@@ -59,7 +59,7 @@ const ToastAction = React.forwardRef<
ref={ref}
className={cn(
"inline-flex h-8 shrink-0 items-center justify-center rounded border bg-transparent px-3 text-sm font-medium transition-colors hover:bg-secondary-light focus:outline-none focus:ring-1 focus:ring-ring disabled:pointer-events-none disabled:opacity-50 dark:hover:bg-secondary-dark",
- className
+ className,
)}
{...props}
/>
@@ -74,7 +74,7 @@ const ToastClose = React.forwardRef<
ref={ref}
className={cn(
"absolute right-1 top-1 rounded p-1 text-foreground-light opacity-0 transition-opacity focus:opacity-100 focus:outline-none focus:ring-1 group-hover:opacity-100 dark:text-foreground-dark",
- className
+ className,
)}
toast-close=""
{...props}
diff --git a/src/utils/constants/shared.constants.ts b/src/utils/constants/shared.constants.ts
index f2a42e02..1dee094d 100644
--- a/src/utils/constants/shared.constants.ts
+++ b/src/utils/constants/shared.constants.ts
@@ -1,4 +1,4 @@
-import type { Chain } from "@covalenthq/client-sdk";
+import type { Chain, GoldRushResponse } from "@covalenthq/client-sdk";
import { ChainID, ChainName } from "@covalenthq/client-sdk";
export const DEFAULT_ERROR_MESSAGE: string = "Something went wrong!";
@@ -6,6 +6,13 @@ export const DEFAULT_ERROR_MESSAGE: string = "Something went wrong!";
export const DEFAULT_ERROR_NFT: string =
"https://www.datocms-assets.com/86369/1685489960-nft.svg";
+export const FALLBACK_ERROR: GoldRushResponse = {
+ data: null,
+ error: true,
+ error_code: 500,
+ error_message: DEFAULT_ERROR_MESSAGE,
+};
+
export enum ADDRESS_AVATAR_TYPE {
FINGERPRINT = "fingerprint",
EFFIGY = "effigy",
diff --git a/src/utils/functions/actionable-wrapper.ts b/src/utils/functions/actionable-wrapper.ts
index 630a677e..1ff34703 100644
--- a/src/utils/functions/actionable-wrapper.ts
+++ b/src/utils/functions/actionable-wrapper.ts
@@ -5,7 +5,7 @@ export const actionableWrapper = <
T extends keyof JSX.IntrinsicElements | React.ComponentType,
>(
actionable: ActionableType | null,
- children: React.ReactNode
+ children: React.ReactNode,
): React.ReactNode => {
if (!actionable) {
return children;
diff --git a/src/utils/functions/calculate-time-series-group.ts b/src/utils/functions/calculate-time-series-group.ts
index ee555901..4007d121 100644
--- a/src/utils/functions/calculate-time-series-group.ts
+++ b/src/utils/functions/calculate-time-series-group.ts
@@ -1,9 +1,14 @@
import { TIME_SERIES_GROUP } from "../constants/shared.constants";
export const calculateTimeSeriesGroup = (
- now: Date,
- signed_at: Date
+ signed_at: Date | null,
): TIME_SERIES_GROUP => {
+ const now = new Date();
+
+ if (!signed_at) {
+ return TIME_SERIES_GROUP.EARLIER;
+ }
+
const dateObj = signed_at;
const diffInMilliseconds = now.getTime() - dateObj.getTime();
const diffInDays = Math.floor(diffInMilliseconds / (1000 * 60 * 60 * 24));
diff --git a/src/utils/functions/copy-to-clipboard.ts b/src/utils/functions/copy-to-clipboard.ts
index 65fd8b81..d0e38a38 100644
--- a/src/utils/functions/copy-to-clipboard.ts
+++ b/src/utils/functions/copy-to-clipboard.ts
@@ -16,7 +16,7 @@ export const copyToClipboard = async (text: string): Promise => {
textArea.select();
try {
console.warn(
- "document.execCommand is deprecated and might not work in future versions."
+ "document.execCommand is deprecated and might not work in future versions.",
);
document.execCommand("copy");
return true;
diff --git a/src/utils/functions/primary-shades.ts b/src/utils/functions/primary-shades.ts
index 364ec6c4..50f633ec 100644
--- a/src/utils/functions/primary-shades.ts
+++ b/src/utils/functions/primary-shades.ts
@@ -5,7 +5,7 @@ import {
export const primaryShades = (
inputColor: string,
- mode: GoldRushThemeType["mode"]
+ mode: GoldRushThemeType["mode"],
): GoldRushThemePrimaryShades => {
function adjustBrightness(color: string, percent: number): string {
const hex = color.replace(/[^0-9A-F]/gi, "");
diff --git a/src/utils/functions/themed-svg.ts b/src/utils/functions/themed-svg.ts
index dc58470f..7fcef178 100644
--- a/src/utils/functions/themed-svg.ts
+++ b/src/utils/functions/themed-svg.ts
@@ -9,7 +9,7 @@ const svgData = async (src: string): Promise => {
const svg = new DOMParser().parseFromString(
data,
- "image/svg+xml"
+ "image/svg+xml",
).documentElement;
const parserError = svg.getElementsByTagName("parsererror");
@@ -35,7 +35,7 @@ const svgData = async (src: string): Promise => {
export const themedSvg = async (
parentRef: React.RefObject,
src: string | null,
- fallback: string
+ fallback: string,
): Promise => {
const _src = src || "";
diff --git a/src/utils/functions/timestamp-parser.ts b/src/utils/functions/timestamp-parser.ts
index 31b10904..a265f92f 100644
--- a/src/utils/functions/timestamp-parser.ts
+++ b/src/utils/functions/timestamp-parser.ts
@@ -15,7 +15,7 @@ const months: string[] = [
export const timestampParser = (
timestamp: string | Date,
- type: "descriptive" | "DD MMM YY" | "relative" | "YYYY MM DD"
+ type: "descriptive" | "DD MMM YY" | "relative" | "YYYY MM DD",
): string => {
const _unix: Date = new Date(timestamp);
diff --git a/src/utils/functions/truncate.ts b/src/utils/functions/truncate.ts
index dc63c3f6..2c9045b1 100644
--- a/src/utils/functions/truncate.ts
+++ b/src/utils/functions/truncate.ts
@@ -1,7 +1,7 @@
export const truncate = (
text: string | null,
start: number = 6,
- end: number = 4
+ end: number = 4,
): string => {
const _text: string = (text || "")?.trim();
if (_text.length > 15) {
diff --git a/src/utils/hooks/use-debounce.ts b/src/utils/hooks/use-debounce.ts
index 819e8cb2..efffbb6b 100644
--- a/src/utils/hooks/use-debounce.ts
+++ b/src/utils/hooks/use-debounce.ts
@@ -3,7 +3,7 @@ import { useRef, type DependencyList, useEffect } from "react";
export const useDebounce = (
func: (...args: unknown[]) => unknown,
delay: number,
- deps: DependencyList
+ deps: DependencyList,
) => {
const timerRef = useRef();
diff --git a/src/utils/hooks/use-toast.ts b/src/utils/hooks/use-toast.ts
index 966d7152..893617d2 100644
--- a/src/utils/hooks/use-toast.ts
+++ b/src/utils/hooks/use-toast.ts
@@ -81,7 +81,7 @@ export const reducer = (state: State, action: Action): State => {
return {
...state,
toasts: state.toasts.map((t) =>
- t.id === action.toast.id ? { ...t, ...action.toast } : t
+ t.id === action.toast.id ? { ...t, ...action.toast } : t,
),
};
@@ -106,7 +106,7 @@ export const reducer = (state: State, action: Action): State => {
...t,
open: false,
}
- : t
+ : t,
),
};
}
diff --git a/src/utils/option.ts b/src/utils/option.ts
index b82b9d77..e0bf5de3 100644
--- a/src/utils/option.ts
+++ b/src/utils/option.ts
@@ -29,7 +29,6 @@ export const Option = (value: T): Option => {
}
};
-// eslint-disable-next-line no-redeclare
export interface Option {
isDefined: boolean;
isEmpty: boolean;
diff --git a/src/utils/store/GoldRush.tsx b/src/utils/store/GoldRush.tsx
index 82763b73..5cb2882c 100644
--- a/src/utils/store/GoldRush.tsx
+++ b/src/utils/store/GoldRush.tsx
@@ -17,7 +17,7 @@ import {
} from "react";
const GoldRushContext = createContext(
- {} as GoldRushContextType
+ {} as GoldRushContextType,
);
export const GoldRushProvider: React.FC = ({
@@ -30,7 +30,7 @@ export const GoldRushProvider: React.FC = ({
new GoldRushClient(apikey, {
source: "GoldRush Kit",
}),
- [apikey]
+ [apikey],
);
const defaultTheme = useMemo(
@@ -52,7 +52,7 @@ export const GoldRushProvider: React.FC = ({
},
mode: "light",
}),
- []
+ [],
);
const [chains, setChains] = useState(null);
@@ -60,8 +60,8 @@ export const GoldRushProvider: React.FC = ({
const [theme, setTheme] = useState(
defaultsDeep(
JSON.parse(localStorage.getItem("goldrush_theme") || "null") ?? {},
- defaultsDeep(initialTheme, defaultTheme)
- )
+ defaultsDeep(initialTheme, defaultTheme),
+ ),
);
useEffect(() => {
@@ -105,12 +105,12 @@ export const GoldRushProvider: React.FC = ({
if (_type === "primary") {
const shades = primaryShades(
value,
- _mode as GoldRushThemeType["mode"]
+ _mode as GoldRushThemeType["mode"],
);
Object.entries(shades).forEach(([shade, color]) => {
root.style.setProperty(
`--grk-${_type}-${_mode}-${shade}`,
- color
+ color,
);
});
} else {
@@ -124,11 +124,11 @@ export const GoldRushProvider: React.FC = ({
(updateTheme: Partial) => {
const updatedTheme: GoldRushThemeType = defaultsDeep(
updateTheme,
- theme
+ theme,
);
setTheme(updatedTheme);
},
- [theme]
+ [theme],
);
const resetThemeHandler = useCallback(() => {
@@ -157,7 +157,7 @@ export const GoldRushProvider: React.FC = ({
return SEARCH_RESULTS_TYPE.NOT_FOUND;
}
},
- []
+ [],
);
return (
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..ffdb21c7 100644
--- a/src/utils/types/molecules.types.ts
+++ b/src/utils/types/molecules.types.ts
@@ -5,6 +5,7 @@ import {
import { type ActionableType, type TransactionsProps } from "./shared.types";
import { type Option } from "@/utils/option";
import type {
+ GasPricesResponse,
NftApprovalSpender,
TokenSpenderItem,
} from "@covalenthq/client-sdk";
@@ -35,22 +36,22 @@ export interface NFTApprovalListProps {
chain_name: Chain;
address: string;
on_revoke_approval?: (
- spender: NftApprovalSpender,
- contract_address: string
+ spender: NftApprovalSpender | null,
+ contract_address: string | null,
) => 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 {
chain_name: Chain;
address: string;
on_revoke_approval?: (
- spender: TokenSpenderItem,
- token_address: string
+ spender: TokenSpenderItem | null,
+ token_address: string | null,
) => 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 +62,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 {
@@ -91,10 +92,15 @@ export interface GasCardProps {
chain_name: Chain;
}
+export type GasCardData = {
+ erc: GasPricesResponse;
+ native: GasPricesResponse;
+};
+
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 +126,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 +144,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 +152,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 +163,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 +229,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..0264cc06 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 {
@@ -74,7 +74,7 @@ export interface TableListProps extends Partial {
errorMessage: string | null;
customRows?: (
row: Row[],
- defaultRow: (row: Row) => React.ReactNode
+ defaultRow: (row: Row) => React.ReactNode,
) => React.ReactNode[];
}
diff --git a/src/utils/types/store.types.ts b/src/utils/types/store.types.ts
index 7d15dce2..36f47e13 100644
--- a/src/utils/types/store.types.ts
+++ b/src/utils/types/store.types.ts
@@ -52,10 +52,5 @@ export interface GoldRushThemeType {
export interface GoldRushProviderProps {
children: React.ReactNode;
apikey: string;
- /**
- * @deprecated Please use `theme` going forward!
- * This prop will be removed after Aug 30, 2024.
- */
- newTheme?: Partial;
theme?: Partial;
}
diff --git a/tailwind.config.ts b/tailwind.config.ts
index e58e7578..b40ba2ab 100644
--- a/tailwind.config.ts
+++ b/tailwind.config.ts
@@ -85,7 +85,7 @@ const config = {
safelist: [
{
pattern: RegExp(
- /^(bg|text|shadow|border|stroke|ring|fill)-(background|foreground|primary|secondary)-(light|dark)$/
+ /^(bg|text|shadow|border|stroke|ring|fill)-(background|foreground|primary|secondary)-(light|dark)$/,
),
variants: [
"dark",
@@ -97,7 +97,7 @@ const config = {
},
{
pattern: RegExp(
- /^(bg|text|shadow|border|stroke|ring|fill)-(primary)-(light|dark)-(DEFAULT|100|200|300|400|500|600|700|800|900)$/
+ /^(bg|text|shadow|border|stroke|ring|fill)-(primary)-(light|dark)-(DEFAULT|100|200|300|400|500|600|700|800|900)$/,
),
variants: ["dark", "hover", "dark:hover"],
},