import type { ThirdwebClient } from "../../../../../../../client/client.js"; import { shortenAddress } from "../../../../../../../utils/address.js"; import { isEcosystemWallet } from "../../../../../../../wallets/ecosystem/is-ecosystem-wallet.js"; import { isSmartWallet } from "../../../../../../../wallets/smart/index.js"; import { fontSize, iconSize, radius, } from "../../../../../../core/design-system/index.js"; import { useConnectedWallets } from "../../../../../../core/hooks/wallets/useConnectedWallets.js"; import { useEnsName, useWalletInfo, } from "../../../../../../core/utils/wallet.js"; import { useProfiles } from "../../../../../hooks/wallets/useProfiles.js"; import { Container } from "../../../../components/basic.js"; import { Skeleton } from "../../../../components/Skeleton.js"; import { Text } from "../../../../components/text.js"; import { WalletImage } from "../../../../components/WalletImage.js"; import { OutlineWalletIcon } from "../../../icons/OutlineWalletIcon.js"; export function WalletRow(props: { client: ThirdwebClient; address: string; iconSize?: keyof typeof iconSize; textSize?: keyof typeof fontSize; label?: string; }) { const { client, address } = props; const connectedWallets = useConnectedWallets(); const profile = useProfiles({ client }); const wallet = connectedWallets.find( (w) => w.getAccount()?.address?.toLowerCase() === address.toLowerCase(), ); const email = wallet && (wallet.id === "inApp" || isEcosystemWallet(wallet) || isSmartWallet(wallet)) ? profile.data?.find((p) => !!p.details.email)?.details.email : undefined; const walletInfo = useWalletInfo(wallet?.id); const ensNameQuery = useEnsName({ address, client, }); const addressOrENS = address ? ensNameQuery.data || shortenAddress(address) : ""; const iconSizeValue = iconSize[props.iconSize || "md"]; return ( {wallet ? ( ) : ( )} {props.label ? ( {props.label} ) : null} {addressOrENS || shortenAddress(props.address)} {profile.isLoading ? ( ) : email || walletInfo?.data?.name ? ( {email || walletInfo?.data?.name} ) : null} ); }