import React from "react"; import { ICandyMachineState } from "../../../hooks/useCandyMachineInfo"; import { HStack, Text, VStack } from "@chakra-ui/react"; import { NATIVE_MINT } from "@solana/spl-token"; import { PublicKey } from "@solana/web3.js"; import { useMint, useMetaplexTokenMetadata } from "@strata-foundation/react"; import { toNumber } from "@strata-foundation/spl-token-bonding"; import { BigText, BlackBox } from "../LbcInfo"; import * as anchor from "@project-serum/anchor"; export const CandyMachineInfo = ({ candyMachine, itemsRemaining, isWhitelistUser, discountPrice }: ICandyMachineState) => { const { metadata, loading: loadingMeta } = useMetaplexTokenMetadata( candyMachine?.tokenMint ); const ticker = loadingMeta ? "" : metadata?.data.symbol || "SOL"; const targetMint = useMint(candyMachine?.tokenMint || NATIVE_MINT); return ( {isWhitelistUser && discountPrice ? "Discount Price" : "Price"} {isWhitelistUser && discountPrice ? `${ targetMint && discountPrice ? toNumber(discountPrice as anchor.BN, targetMint) : "" } ${ticker}` : candyMachine ? `${ targetMint && candyMachine?.price ? toNumber((discountPrice || candyMachine.price) as anchor.BN, targetMint) : "" } ${ticker}` : ""} Remaining {itemsRemaining} ); };