import {
Button,
Center,
createIcon, HStack,
Icon,
SimpleGrid,
StackDivider,
Text,
VStack
} from "@chakra-ui/react";
import { NATIVE_MINT } from "@solana/spl-token";
import { useWallet } from "@solana/wallet-adapter-react";
import { ITokenWithMetaAndAccount } from "@strata-foundation/spl-token-collective";
import { useSolOwnedAmount } from "../../hooks/bondingPricing";
import { useErrorHandler } from "../../hooks/useErrorHandler";
import { usePriceInUsd } from "../../hooks/usePriceInUsd";
import { useTwWrappedSolMint } from "../../hooks/useTwWrappedSolMint";
import { useUserTokensWithMeta } from "../../hooks/useUserTokensWithMeta";
import React from "react";
import toast from "react-hot-toast";
import { RiCoinLine } from "react-icons/ri";
import { Notification } from "../Notification";
import { Spinner } from "../Spinner";
import { TokenInfo } from "./TokenInfo";
const SolLogoIcon = createIcon({
displayName: "Solana",
viewBox: "0 0 96 96",
path: [
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
],
});
export const Wallet = React.memo(
({
wumLeaderboardLink,
onSelect,
solLink,
onSendClick,
}: {
onSelect: (tokenWithMeta: ITokenWithMetaAndAccount) => void;
solLink: string;
wumLeaderboardLink: string;
onSendClick: () => void;
}) => {
const { publicKey } = useWallet();
const { amount: solOwned } = useSolOwnedAmount(publicKey || undefined);
const solPrice = usePriceInUsd(NATIVE_MINT);
const {
data: tokens,
loading,
error,
} = useUserTokensWithMeta(publicKey || undefined);
const { handleErrors } = useErrorHandler();
handleErrors(error);
const twSol = useTwWrappedSolMint();
return (
}
spacing={4}
w="full"
>
}
>
window.open(solLink, "_blank")}
_hover={{ opacity: "0.5", cursor: "pointer" }}
spacing={1}
flexDir="column"
align="center"
>
{solOwned?.toFixed(2)} SOL
(~${((solPrice || 0) * solOwned).toFixed(2)})
}
>
{loading && (
)}
{!loading &&
tokens
?.filter((t) => !!t.metadata && t.mint?.decimals != 0)
.sort((a, b) =>
twSol && a.account!.mint!.equals(twSol)
? -1
: twSol && b.account!.mint.equals(twSol)
? 1
: a.metadata!.data.name.localeCompare(b.metadata!.data.name)
)
.map((tokenWithMeta) => (
))}
);
}
);