* init solana dashboard * some updates * deploying programs works? * solana program page is go * more updates * various updates and improvements * git add maybe? * working state * working minting / nft list * working drop lazy mint + latest nightly * dashboard works * forgot to add things * fix various small things * fix rpc * implement token page + code organization * update SDK * rename accounts to program * implement token mint button * split dashboard into evm vs sol and separate out solana programs * fix caching * upgrade to combined sdk * merge in main * update to latest nightly SDK * tabs for days * lul query client maybe? * remove unused hook * add super basic nft drawer * lots of updates to start on nft drawer etc * add code tab content * fix merge conflicts * pass program address to code tab * some changes * some minor updates * new nft drawer and table * drawer for solana done (v1) * fix a bunch of stuff * fix some tracking * update nightly * add programId to program deploy event * adapt to changes in react lib * upgrade to dev version * Add batch upload to Solana (#539) * First small necessary refactor * Working version * Working version with yalc * Use nightly * Move everything around * Remove unused imports * Fix types * Add state for hasTried * Fix conditions * Add solana * Move selectedReveal to be part of the form * Improve logic * Update dependencies * Make drawer fullscreen * Fix hasFailed logic * Fix types * Make inputs required conditionally * Fix types * Make loading work * Remove repeated code * Remove unused * Pass progress as a prop * Move common files to core-ui * massive cleanup Co-authored-by: Jonas Daniels <[email protected]> * feat(faucet): build solana faucet (#528) * feat(faucet): build solana faucet * chore: update names * fix: type Co-authored-by: Jonas Daniels <[email protected]> * fix: minor stuff Co-authored-by: Jonas Daniels <[email protected]> * fix: feedback * feat: minor improvements * feat: add faq section * refactor: refactor faq * add accordion * minor fix Co-authored-by: Jonas Daniels <[email protected]> * tiny fix * Revert batch upload styles (#541) * Fix typo, fix drawer width * Revert to old batch upload styles * Fix some more styles * Fix progress bar styles * Update to using TWRegistry * [Solana] Add claim conditions to NFT Drop (#542) * Add tab and getter * Working version * Delete unused imports * Currency selector works but I hate it * Add maxClaimable * Fix build issue * Make batch upload work again * Fix claim conditions for devnet * Test fix * Delete console.logs * A lot of solana stuff (#545) * Remove unused banner * Hide Claim Conditions tab for no drops * Add loading state * Remove comment * Add helper text for nft drop supply * Delete log * Add loading state to program list * Add redirect if you don't have any program deploys * Add default instant reveal for Solana * Fix styles * Fix logic * doc fixes * fix(faucet): minor issues (#543) * fix(spacing): fix spacing in faq * feat: some updates from feedback * fix: use linkButton * feat: use fetch * remove test code * fix: err handling * pass err * fix sucecss state * fix: link * some updates * small fixes Co-authored-by: Nacho Iacovino <[email protected]> * update to latest nightly * fix up form and update deps * Add claim button to Solana (#555) * wip * Add claim buttons, fix warning, disable buttons conditioanlly * Use nightly * Delete unused import * Solana hackathon landing (#554) * feat: build hackathon page (#547) * wip: build hackathon page * add some more stuff * feat: responsievness and some minor stuff Co-authored-by: Nacho Iacovino <[email protected]> * First section * Fix PrizeSection * Add link to register now * Add judges and footer * Update startTime for hackathon * Fix Schedule * Add tracking * Add pageId * Prettier? * Prettier again * Prettier you're drunk * This is my life now * Remove unused import * Add og metadata * Update SEO Co-authored-by: Avneesh Agarwal <[email protected]> Co-authored-by: Jonas Daniels <[email protected]> * Add solana landing page (#556) * Add landing page for Solana * Add solana landing page * Add shopify landing * Add shopify * Remove quote * Add meta tags * Add landing page updates * Add links * small cleanups * fix various & pagination on nft table solana * Show unclaimed instead of tokenId for lazy minted tokens * add full install command for solana react * show create cli command in code tab for react * add funds notice for solana * add various things * various updates * various updates * updated some guides and copy based on juan feedback * Fix Solana faucet link * Add disclaimer on how to deploy with Devnet * Small fixes * Update guidelines * Fix currency selector bug * Update hero copy * fix build issues * update to latest * link solana cards * Add partners * update og images for shopify & solana * Add solanathon og:image * copy changes * Update image size * Center sponsors Co-authored-by: Joaquim Verges <[email protected]> Co-authored-by: Nacho Iacovino <[email protected]> Co-authored-by: Avneesh Agarwal <[email protected]> Co-authored-by: Nacho Iacovino <[email protected]> Co-authored-by: Adam Majmudar <[email protected]>
391 lines
13 KiB
TypeScript
391 lines
13 KiB
TypeScript
import { ProgramCurrencySelector } from "./program-currency-selector";
|
|
import {
|
|
Alert,
|
|
AlertDescription,
|
|
AlertIcon,
|
|
AlertTitle,
|
|
Divider,
|
|
Flex,
|
|
FormControl,
|
|
Icon,
|
|
Input,
|
|
Spinner,
|
|
Stack,
|
|
} from "@chakra-ui/react";
|
|
import {
|
|
useClaimConditions,
|
|
useProgram,
|
|
useSetClaimConditions,
|
|
} from "@thirdweb-dev/react/solana";
|
|
import { NFTDropUpdateableConditionsInputSchema } from "@thirdweb-dev/sdk/solana";
|
|
import { TransactionButton } from "components/buttons/TransactionButton";
|
|
import { BasisPointsInput } from "components/inputs/BasisPointsInput";
|
|
import {
|
|
PriceInput,
|
|
QuantityInputWithUnlimited,
|
|
} from "contract-ui/tabs/claim-conditions/components/claim-conditions";
|
|
import { useTrack } from "hooks/analytics/useTrack";
|
|
import { useTxNotifications } from "hooks/useTxNotifications";
|
|
import { useEffect, useMemo, useState } from "react";
|
|
import { useForm } from "react-hook-form";
|
|
import { FiPlus } from "react-icons/fi";
|
|
import {
|
|
Button,
|
|
Card,
|
|
FormErrorMessage,
|
|
FormHelperText,
|
|
FormLabel,
|
|
Heading,
|
|
Text,
|
|
} from "tw-components";
|
|
import { toDateTimeLocal } from "utils/date-utils";
|
|
import { z } from "zod";
|
|
|
|
export const ProgramClaimConditionsTab: React.FC<{ address: string }> = ({
|
|
address,
|
|
}) => {
|
|
return (
|
|
<Stack spacing={8}>
|
|
<Card p={0} position="relative">
|
|
<Flex pt={{ base: 6, md: 10 }} direction="column" gap={8}>
|
|
<Flex
|
|
px={{ base: 6, md: 10 }}
|
|
as="section"
|
|
direction="column"
|
|
gap={4}
|
|
>
|
|
<Flex direction="column">
|
|
<Heading size="title.md">Set Claim Conditions</Heading>
|
|
<Text size="body.md" fontStyle="italic">
|
|
Control when the NFTs get dropped, how much they cost, and more.
|
|
</Text>
|
|
</Flex>
|
|
</Flex>
|
|
<Divider />
|
|
<ClaimConditionsProgramForm address={address} />
|
|
</Flex>
|
|
</Card>
|
|
</Stack>
|
|
);
|
|
};
|
|
|
|
const ClaimConditionsProgramForm: React.FC<{ address: string }> = ({
|
|
address,
|
|
}) => {
|
|
const trackEvent = useTrack();
|
|
const program = useProgram(address, "nft-drop");
|
|
const query = useClaimConditions(program.data);
|
|
const mutation = useSetClaimConditions(program.data);
|
|
const [seeForm, setSeeForm] = useState(query.data?.maxClaimable !== "0");
|
|
|
|
const transformedQueryData = useMemo(() => {
|
|
const data = query.data;
|
|
|
|
if (!data) {
|
|
return undefined;
|
|
}
|
|
|
|
return {
|
|
startTime: data.startTime ? new Date(data.startTime) : new Date(),
|
|
price: data.price.displayValue,
|
|
currencyAddress: data.currencyAddress || "SOLANA_NATIVE_TOKEN",
|
|
primarySaleRecipient: data.primarySaleRecipient,
|
|
sellerFeeBasisPoints: data.sellerFeeBasisPoints,
|
|
maxClaimable: data.maxClaimable,
|
|
};
|
|
}, [query.data]);
|
|
|
|
const {
|
|
register,
|
|
setValue,
|
|
getFieldState,
|
|
formState,
|
|
watch,
|
|
handleSubmit,
|
|
reset,
|
|
} = useForm<z.input<typeof NFTDropUpdateableConditionsInputSchema>>({
|
|
defaultValues: transformedQueryData,
|
|
});
|
|
|
|
useEffect(() => {
|
|
if (query.data && !formState.isDirty) {
|
|
reset(transformedQueryData);
|
|
}
|
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
}, [query.data, formState.isDirty]);
|
|
|
|
const { onSuccess, onError } = useTxNotifications(
|
|
"Saved claim conditions",
|
|
"Failed to save claim conditions",
|
|
);
|
|
|
|
return (
|
|
<>
|
|
{query.isRefetching && (
|
|
<Spinner
|
|
color="primary"
|
|
size="xs"
|
|
position="absolute"
|
|
top={2}
|
|
right={4}
|
|
/>
|
|
)}
|
|
<Flex
|
|
onSubmit={handleSubmit(async (d) => {
|
|
trackEvent({
|
|
category: "nft",
|
|
action: "set-claim-conditions",
|
|
label: "attempt",
|
|
});
|
|
try {
|
|
await mutation.mutateAsync({
|
|
primarySaleRecipient: d.primarySaleRecipient,
|
|
sellerFeeBasisPoints: d.sellerFeeBasisPoints,
|
|
startTime: d.startTime,
|
|
maxClaimable: d.maxClaimable,
|
|
price: d.price,
|
|
...(d.currencyAddress !== "SOLANA_NATIVE_TOKEN" && {
|
|
currencyAddress: d.currencyAddress,
|
|
}),
|
|
});
|
|
trackEvent({
|
|
category: "nft",
|
|
action: "set-claim-conditions",
|
|
label: "success",
|
|
});
|
|
onSuccess();
|
|
} catch (error) {
|
|
trackEvent({
|
|
category: "nft",
|
|
action: "set-claim-conditions",
|
|
label: "error",
|
|
});
|
|
onError(error);
|
|
}
|
|
})}
|
|
direction="column"
|
|
as="form"
|
|
gap={10}
|
|
>
|
|
<Flex direction={"column"} gap={4} px={{ base: 6, md: 10 }}>
|
|
{seeForm ? (
|
|
<Card position="relative">
|
|
<Flex direction="column" gap={8}>
|
|
<Flex
|
|
direction={{
|
|
base: "column",
|
|
md: "row",
|
|
}}
|
|
gap={4}
|
|
>
|
|
<FormControl
|
|
isInvalid={!!getFieldState(`startTime`, formState).error}
|
|
>
|
|
<Heading as={FormLabel} size="label.md">
|
|
When will this drop start?
|
|
</Heading>
|
|
<Input
|
|
type="datetime-local"
|
|
value={toDateTimeLocal(watch("startTime"))}
|
|
onChange={(e) =>
|
|
setValue(`startTime`, new Date(e.target.value))
|
|
}
|
|
/>
|
|
<FormErrorMessage>
|
|
{getFieldState(`startTime`, formState).error?.message}
|
|
</FormErrorMessage>
|
|
<FormHelperText>
|
|
This time is in your local timezone.
|
|
</FormHelperText>
|
|
</FormControl>
|
|
<FormControl
|
|
isInvalid={!!getFieldState(`maxClaimable`, formState).error}
|
|
>
|
|
<Heading as={FormLabel} size="label.md">
|
|
How many total NFTs can be claimed?
|
|
</Heading>
|
|
|
|
<QuantityInputWithUnlimited
|
|
isRequired
|
|
decimals={9}
|
|
value={watch("maxClaimable")?.toString() || "0"}
|
|
onChange={(value) =>
|
|
setValue(`maxClaimable`, value.toString())
|
|
}
|
|
/>
|
|
|
|
<FormErrorMessage>
|
|
{getFieldState(`maxClaimable`, formState).error?.message}
|
|
</FormErrorMessage>
|
|
<FormHelperText>
|
|
This number includes NFTs that have already been claimed.
|
|
</FormHelperText>
|
|
</FormControl>
|
|
</Flex>
|
|
|
|
<Flex
|
|
direction={{
|
|
base: "column",
|
|
md: "row",
|
|
}}
|
|
gap={4}
|
|
>
|
|
<FormControl
|
|
isInvalid={!!getFieldState(`price`, formState).error}
|
|
>
|
|
<Heading as={FormLabel} size="label.md">
|
|
How much do you want to charge to claim each NFT?
|
|
</Heading>
|
|
<PriceInput
|
|
value={parseFloat(watch("price")?.toString() || "0")}
|
|
onChange={(val) => setValue(`price`, val)}
|
|
/>
|
|
<FormErrorMessage>
|
|
{getFieldState(`price`, formState).error?.message}
|
|
</FormErrorMessage>
|
|
</FormControl>
|
|
|
|
<FormControl
|
|
isInvalid={
|
|
!!getFieldState(`currencyAddress`, formState).error
|
|
}
|
|
>
|
|
<Heading
|
|
as={FormLabel}
|
|
size="label.md"
|
|
maxWidth={{ base: "50%", md: "100%" }}
|
|
>
|
|
What currency do you want to use?
|
|
</Heading>
|
|
<ProgramCurrencySelector
|
|
value={watch("currencyAddress") || "SOLANA_NATIVE_TOKEN"}
|
|
onChange={(e) =>
|
|
setValue(`currencyAddress`, e.target.value)
|
|
}
|
|
/>
|
|
{/* <CurrencySelector
|
|
// TODO get native_token_address
|
|
value={currencyAddress || NATIVE_TOKEN_ADDRESS}
|
|
value={watch("currencyAddress") || ""}
|
|
onChange={(e) =>
|
|
setValue(`currencyAddress`, e.target.value)
|
|
}
|
|
/> */}
|
|
<FormErrorMessage>
|
|
{
|
|
getFieldState(`currencyAddress`, formState).error
|
|
?.message
|
|
}
|
|
</FormErrorMessage>
|
|
</FormControl>
|
|
</Flex>
|
|
|
|
<Flex
|
|
gap={4}
|
|
direction={{
|
|
base: "column",
|
|
md: "row",
|
|
}}
|
|
>
|
|
<FormControl
|
|
isInvalid={
|
|
!!getFieldState(`primarySaleRecipient`, formState).error
|
|
}
|
|
>
|
|
<Heading as={FormLabel} size="label.md">
|
|
Primary Sales
|
|
</Heading>
|
|
<Input
|
|
variant="filled"
|
|
{...register("primarySaleRecipient")}
|
|
/>
|
|
<FormHelperText>
|
|
Determine the address that should receive the revenue from
|
|
initial sales of the assets.
|
|
</FormHelperText>
|
|
<FormErrorMessage>
|
|
{
|
|
getFieldState("primarySaleRecipient", formState).error
|
|
?.message
|
|
}
|
|
</FormErrorMessage>
|
|
</FormControl>
|
|
<FormControl
|
|
isInvalid={
|
|
!!getFieldState(`sellerFeeBasisPoints`, formState).error
|
|
}
|
|
>
|
|
<Heading as={FormLabel} size="label.md">
|
|
Royalties
|
|
</Heading>
|
|
<BasisPointsInput
|
|
variant="filled"
|
|
value={watch("sellerFeeBasisPoints")}
|
|
onChange={(value) =>
|
|
setValue("sellerFeeBasisPoints", value, {
|
|
shouldTouch: true,
|
|
})
|
|
}
|
|
/>
|
|
<FormHelperText>
|
|
Determine the address that should receive the revenue from
|
|
royalties earned from secondary sales of the assets.
|
|
</FormHelperText>
|
|
<FormErrorMessage>
|
|
{
|
|
getFieldState("sellerFeeBasisPoints", formState).error
|
|
?.message
|
|
}
|
|
</FormErrorMessage>
|
|
</FormControl>
|
|
</Flex>
|
|
</Flex>
|
|
</Card>
|
|
) : (
|
|
<>
|
|
<Alert status="warning" borderRadius="md">
|
|
<AlertIcon />
|
|
<Flex direction="column">
|
|
<AlertTitle>No claim conditions set.</AlertTitle>
|
|
<AlertDescription>
|
|
Without claim conditions no-one will be able to claim this
|
|
drop.
|
|
</AlertDescription>
|
|
</Flex>
|
|
</Alert>
|
|
|
|
<Button
|
|
colorScheme="purple"
|
|
variant="solid"
|
|
borderRadius="md"
|
|
leftIcon={<Icon as={FiPlus} />}
|
|
onClick={() => setSeeForm(true)}
|
|
isDisabled={mutation.isLoading}
|
|
>
|
|
Add Claim Conditions
|
|
</Button>
|
|
</>
|
|
)}
|
|
</Flex>
|
|
|
|
<Divider />
|
|
<TransactionButton
|
|
ecosystem="solana"
|
|
colorScheme="primary"
|
|
transactionCount={1}
|
|
isDisabled={query.isLoading}
|
|
type="submit"
|
|
isLoading={mutation.isLoading}
|
|
loadingText="Saving..."
|
|
size="md"
|
|
borderRadius="xl"
|
|
borderTopLeftRadius="0"
|
|
borderTopRightRadius="0"
|
|
>
|
|
Save Claim Conditions
|
|
</TransactionButton>
|
|
</Flex>
|
|
</>
|
|
);
|
|
};
|