diff --git a/frontend/components/hypercert-create.tsx b/frontend/components/hypercert-create.tsx index 99600560..ff6b65a8 100644 --- a/frontend/components/hypercert-create.tsx +++ b/frontend/components/hypercert-create.tsx @@ -3,7 +3,7 @@ import { parseListFromString } from "../lib/parsing"; import { useConfetti } from "./confetti"; import { useContractModal } from "./contract-interaction-dialog-context"; import { DATE_INDEFINITE, DateIndefinite, FormContext } from "./forms"; -import { formatHypercertData } from "@hypercerts-org/sdk"; +import { TransferRestrictions, formatHypercertData } from "@hypercerts-org/sdk"; import { DataProvider } from "@plasmicapp/loader-nextjs"; import dayjs from "dayjs"; import { Formik, FormikProps } from "formik"; @@ -62,6 +62,7 @@ const DEFAULT_FORM_DATA: HypercertCreateFormData = { backgroundColor: "", backgroundVectorArt: "", metadataProperties: "", + transferRestrictions: TransferRestrictions.FromCreatorOnly, }; interface HypercertCreateFormData { @@ -89,6 +90,7 @@ interface HypercertCreateFormData { backgroundColor: string; backgroundVectorArt: string; metadataProperties: string; + transferRestrictions: TransferRestrictions; } /** @@ -385,9 +387,14 @@ export function HypercertCreateForm(props: HypercertCreateFormProps) { allowlistUrl: values.allowlistUrl, allowlistPercentage: values.allowlistPercentage, deduplicate: values.deduplicateAllowlist, + transferRestrictions: values.transferRestrictions, }); } else { - await mintClaim(metaData.data, DEFAULT_NUM_FRACTIONS); + await mintClaim( + metaData.data, + DEFAULT_NUM_FRACTIONS, + values.transferRestrictions, + ); } } else { toast("Error creating hypercert. Please contact the team.", { diff --git a/frontend/hooks/mintClaim.ts b/frontend/hooks/mintClaim.ts index 55abc6a1..66ef74aa 100644 --- a/frontend/hooks/mintClaim.ts +++ b/frontend/hooks/mintClaim.ts @@ -25,6 +25,7 @@ export const useMintClaim = ({ onComplete }: { onComplete?: () => void }) => { const initializeWrite = async ( metaData: HypercertMetadata, units: number, + transferRestrictions: TransferRestrictions, ) => { setStep("minting"); try { @@ -33,7 +34,7 @@ export const useMintClaim = ({ onComplete }: { onComplete?: () => void }) => { const hash = await client.mintClaim( metaData, BigInt(units), - TransferRestrictions.FromCreatorOnly, + transferRestrictions, ); const receipt = await publicClient?.waitForTransactionReceipt({ @@ -67,10 +68,14 @@ export const useMintClaim = ({ onComplete }: { onComplete?: () => void }) => { }; return { - write: async (metaData: HypercertMetadata, units: number) => { + write: async ( + metaData: HypercertMetadata, + units: number, + transferRestrictions: TransferRestrictions = TransferRestrictions.FromCreatorOnly, + ) => { showModal({ stepDescriptions }); setStep("preparing"); - await initializeWrite(metaData, units); + await initializeWrite(metaData, units, transferRestrictions); }, txPending, readOnly: isLoading || !client || client.readonly, diff --git a/frontend/hooks/mintClaimAllowlist.ts b/frontend/hooks/mintClaimAllowlist.ts index 18273244..a78a0429 100644 --- a/frontend/hooks/mintClaimAllowlist.ts +++ b/frontend/hooks/mintClaimAllowlist.ts @@ -85,6 +85,7 @@ export const useMintClaimAllowlist = ({ allowlistUrl: string, allowlistPercentage: number, deduplicate: boolean, + transferRestrictions: TransferRestrictions, ) => { setStep("validateAllowlist"); @@ -126,7 +127,7 @@ export const useMintClaimAllowlist = ({ _allowlist, metaData, _totalSupply, - TransferRestrictions.FromCreatorOnly, + transferRestrictions, ); const receipt = await publicClient?.waitForTransactionReceipt({ @@ -165,11 +166,13 @@ export const useMintClaimAllowlist = ({ allowlistUrl, allowlistPercentage, deduplicate, + transferRestrictions = TransferRestrictions.FromCreatorOnly, }: { metaData: HypercertMetadata; allowlistUrl: string; allowlistPercentage: number; deduplicate: boolean; + transferRestrictions?: TransferRestrictions; }) => { showModal({ stepDescriptions }); await initializeWrite( @@ -177,6 +180,7 @@ export const useMintClaimAllowlist = ({ allowlistUrl, allowlistPercentage, deduplicate, + transferRestrictions, ); }, txPending, diff --git a/frontend/plasmic-init.ts b/frontend/plasmic-init.ts index 42c167c4..79a54679 100644 --- a/frontend/plasmic-init.ts +++ b/frontend/plasmic-init.ts @@ -222,6 +222,11 @@ PLASMIC.registerComponent(HypercertFetcher, { importPath: "./components/hypercert-metadata-fetcher", }); +/** + * AllowAll: 0, + * DisallowAll: 1, + * FromCreatorOnly: 2, + */ PLASMIC.registerComponent(HypercertCreateForm, { name: "HypercertCreateForm", description: "Create a hypercert", @@ -233,6 +238,11 @@ PLASMIC.registerComponent(HypercertCreateForm, { value: "Placeholder", }, }, + transferRestrictions: { + type: "choice", + options: ["AllowAll", "DisallowAll", "FromCreatorOnly"], + defaultValueHint: "FromCreatorOnly", + }, }, providesData: true, importPath: "./components/hypercert-create",