Skip to content

Commit

Permalink
wip: update ts sdk version
Browse files Browse the repository at this point in the history
  • Loading branch information
jagnani73 committed Sep 20, 2024
1 parent 7e18be0 commit 1840d08
Show file tree
Hide file tree
Showing 13 changed files with 77 additions and 62 deletions.
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
4 changes: 4 additions & 0 deletions src/components/Atoms/Address/Address.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ export const Address: React.FC<AddressProps> = ({
avatar = null,
actionable_address = () => null,
}) => {
if (!address) {
return <></>;
}

const [showCopy, setShowCopy] = useState<boolean>(false);
const { toast } = useToast();

Expand Down
2 changes: 1 addition & 1 deletion src/components/Atoms/NFT/NFT.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export const NFT: React.FC<NFTProps> = ({
<TokenAvatar
only_primary
size={GRK_SIZES.EXTRA_SMALL}
chain_color={chain.color_theme.hex}
chain_color={chain.color_theme?.hex}
primary_url={chain?.logo_url}
/>
</div>
Expand Down
4 changes: 4 additions & 0 deletions src/components/Atoms/Timestamp/Timestamp.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ export const Timestamp: React.FC<TimestampProps> = ({
defaultType = "relative",
dynamic = true,
}) => {
if (!timestamp) {
return <></>;
}

const [relativeTime, setRelativeTime] = useState<boolean>(
defaultType === "relative"
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export const AddressActivityDetails: React.FC<AddressActivityDetailsProps> = ({
if (error.error) {
throw error;
}
setMaybeResult(new Some(data.items));
setMaybeResult(new Some(data!.items));
} catch (error: GoldRushResponse<null> | any) {
setErrorMessage(
error?.error_message ?? DEFAULT_ERROR_MESSAGE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export const AddressActivityList: React.FC<AddressActivityListProps> = ({
if (error.error) {
throw error;
}
setMaybeResult(new Some(data.items));
setMaybeResult(new Some(data!.items));
} catch (error: GoldRushResponse<null> | any) {
setErrorMessage(
error?.error_message ?? DEFAULT_ERROR_MESSAGE
Expand Down Expand Up @@ -85,7 +85,7 @@ export const AddressActivityList: React.FC<AddressActivityListProps> = ({
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")}
</div>
Expand Down
35 changes: 21 additions & 14 deletions src/components/Molecules/Address/AddressDetails/AddressDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export const AddressDetails: React.FC<AddressDetailsProps> = ({
if (balancesError.error) {
throw balancesError;
}
const balances = balancesData.items;
const balances = balancesData!.items;
const nativeTokenIndex = balances.findIndex(
(token) => token.native_token
);
Expand Down Expand Up @@ -129,19 +129,19 @@ export const AddressDetails: React.FC<AddressDetailsProps> = ({
}
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}
</>
Expand All @@ -157,7 +157,7 @@ export const AddressDetails: React.FC<AddressDetailsProps> = ({
)
),
subtext: `@${prettifyCurrency(
native.quote_rate
native.quote_rate || 0
)}/${native.contract_ticker_symbol}`,
},
{
Expand Down Expand Up @@ -199,12 +199,12 @@ export const AddressDetails: React.FC<AddressDetailsProps> = ({
GRK_SIZES.EXTRA_EXTRA_SMALL
}
primary_url={
logo_urls.token_logo_url
logo_urls?.token_logo_url
}
chain_color={
selectedChain
?.color_theme
.hex
?.hex
}
/>
</div>
Expand All @@ -219,7 +219,8 @@ export const AddressDetails: React.FC<AddressDetailsProps> = ({
<>
{calculatePrettyBalance(
balance,
contract_decimals,
contract_decimals ||
0,
true
)}{" "}
{
Expand All @@ -241,7 +242,10 @@ export const AddressDetails: React.FC<AddressDetailsProps> = ({
heading: "LATEST TRANSACTION",
content: (
<Address
address={latest_transaction.tx_hash}
address={
latest_transaction?.tx_hash ||
null
}
actionable_address={
actionable_transaction
}
Expand All @@ -250,7 +254,8 @@ export const AddressDetails: React.FC<AddressDetailsProps> = ({
subtext: (
<Timestamp
timestamp={
latest_transaction.block_signed_at
latest_transaction?.block_signed_at ||
null
}
/>
),
Expand All @@ -260,7 +265,8 @@ export const AddressDetails: React.FC<AddressDetailsProps> = ({
content: (
<Address
address={
earliest_transaction.tx_hash
earliest_transaction?.tx_hash ||
null
}
actionable_address={
actionable_transaction
Expand All @@ -270,14 +276,15 @@ export const AddressDetails: React.FC<AddressDetailsProps> = ({
subtext: (
<Timestamp
timestamp={
earliest_transaction.block_signed_at
earliest_transaction?.block_signed_at ||
null
}
/>
),
},
{
heading: "TOTAL COUNT",
content: `${total_count.toLocaleString()} transactions`,
content: `${total_count?.toLocaleString()} transactions`,
},
] as CardDetailProps[]
).map((props) => (
Expand Down
8 changes: 4 additions & 4 deletions src/components/Shared/Transactions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export const Transactions: React.FC<TransactionsProps> = ({
<p>
{actionableWrapper(
actionable_block(row.original.block_height),
row.original.block_height.toLocaleString()
row.original.block_height?.toLocaleString()
)}
</p>
);
Expand Down Expand Up @@ -128,9 +128,9 @@ export const Transactions: React.FC<TransactionsProps> = ({
<p className="text-right">
{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}
</p>
) : (
<p className="text-center">-</p>
Expand All @@ -152,7 +152,7 @@ export const Transactions: React.FC<TransactionsProps> = ({
<p className="text-right">
{calculatePrettyBalance(
row.original.fees_paid,
row.original.gas_metadata.contract_decimals
row.original.gas_metadata?.contract_decimals
)}
</p>
) : (
Expand Down
12 changes: 6 additions & 6 deletions src/utils/types/atoms.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<AddressAvatarProps, "address">;
actionable_address?: (address: string) => ActionableType;
actionable_address?: (address: string | null) => ActionableType;
}

export interface AddressCardProps {
Expand All @@ -22,7 +22,7 @@ export interface AddressCardProps {
avatar: Omit<AddressAvatarProps, "address">;
show_copy_icon?: boolean;
show_qr_code?: boolean;
actionable_address?: (address: string) => ActionableType;
actionable_address?: (address: string | null) => ActionableType;
}

export interface NFTProps {
Expand All @@ -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;
}
Expand All @@ -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 {
Expand Down
Loading

0 comments on commit 1840d08

Please sign in to comment.