@@ -21,7 +21,6 @@ import { Input } from "@/components/ui/input";
2121import { Separator } from "@/components/ui/separator" ;
2222import { Skeleton } from "@/components/ui/skeleton" ;
2323import { Textarea } from "@/components/ui/textarea" ;
24- import { cn } from "@/lib/utils" ;
2524import { zodResolver } from "@hookform/resolvers/zod" ;
2625import { useMutation } from "@tanstack/react-query" ;
2726import { PropertiesFormControl } from "components/contract-pages/forms/properties.shared" ;
@@ -53,6 +52,7 @@ export type MintFormValues = NFTMetadataInputLimited & {
5352 supply : number ;
5453 customImage : string ;
5554 customAnimationUrl : string ;
55+ tokenId ?: string ;
5656} ;
5757
5858function MintableModule ( props : ModuleInstanceProps ) {
@@ -66,6 +66,12 @@ function MintableModule(props: ModuleInstanceProps) {
6666 ) ;
6767
6868 const isErc721 = props . contractInfo . name === "MintableERC721" ;
69+ const isBatchMetadataInstalled = ! ! props . allModuleContractInfo . find (
70+ ( module ) => module . name . includes ( "BatchMetadata" ) ,
71+ ) ;
72+ const isSequentialTokenIdInstalled = ! ! props . allModuleContractInfo . find (
73+ ( module ) => module . name . includes ( "SequentialTokenId" ) ,
74+ ) ;
6975
7076 const mint = useCallback (
7177 async ( values : MintFormValues ) => {
@@ -84,6 +90,7 @@ function MintableModule(props: ModuleInstanceProps) {
8490 contract,
8591 to : values . recipient ,
8692 amount : BigInt ( values . amount ) ,
93+ tokenId : values . tokenId ? BigInt ( values . tokenId ) : undefined ,
8794 nft,
8895 } ) ;
8996
@@ -122,7 +129,9 @@ function MintableModule(props: ModuleInstanceProps) {
122129 updatePrimaryRecipient = { update }
123130 mint = { mint }
124131 isOwnerAccount = { ! ! ownerAccount }
125- showAmount = { ! isErc721 }
132+ isErc721 = { isErc721 }
133+ isBatchMetadataInstalled = { isBatchMetadataInstalled }
134+ isSequentialTokenIdInstalled = { isSequentialTokenIdInstalled }
126135 />
127136 ) ;
128137}
@@ -134,7 +143,9 @@ export function MintableModuleUI(
134143 isOwnerAccount : boolean ;
135144 updatePrimaryRecipient : ( values : UpdateFormValues ) => Promise < void > ;
136145 mint : ( values : MintFormValues ) => Promise < void > ;
137- showAmount : boolean ;
146+ isErc721 : boolean ;
147+ isBatchMetadataInstalled : boolean ;
148+ isSequentialTokenIdInstalled : boolean ;
138149 } ,
139150) {
140151 return (
@@ -154,7 +165,11 @@ export function MintableModuleUI(
154165 { props . isOwnerAccount && (
155166 < MintNFTSection
156167 mint = { props . mint }
157- showAmount = { props . showAmount }
168+ isErc721 = { props . isErc721 }
169+ isBatchMetadataInstalled = { props . isBatchMetadataInstalled }
170+ isSequentialTokenIdInstalled = {
171+ props . isSequentialTokenIdInstalled
172+ }
158173 />
159174 ) }
160175 { ! props . isOwnerAccount && (
@@ -271,7 +286,9 @@ function PrimarySalesSection(props: {
271286
272287function MintNFTSection ( props : {
273288 mint : ( values : MintFormValues ) => Promise < void > ;
274- showAmount : boolean ;
289+ isErc721 : boolean ;
290+ isBatchMetadataInstalled : boolean ;
291+ isSequentialTokenIdInstalled : boolean ;
275292} ) {
276293 const form = useForm < MintFormValues > ( {
277294 values : {
@@ -300,94 +317,91 @@ function MintNFTSection(props: {
300317 < Form { ...form } >
301318 < form onSubmit = { form . handleSubmit ( onSubmit ) } >
302319 < div className = "flex flex-col gap-6" >
303- < div className = "flex flex-col gap-6 lg:flex-row" >
304- { /* Left */ }
305- < div className = "shrink-0 lg:w-[300px]" >
306- < NFTMediaFormGroup form = { form } previewMaxWidth = "300px" />
307- </ div >
308-
309- { /* Right */ }
310- < div className = "flex grow flex-col gap-6" >
311- { /* name */ }
312- < FormField
313- control = { form . control }
314- name = "name"
315- render = { ( { field } ) => (
316- < FormItem >
317- < FormLabel > Name</ FormLabel >
318- < FormControl >
319- < Input { ...field } />
320- </ FormControl >
321-
322- < FormMessage />
323- </ FormItem >
324- ) }
325- />
326-
327- { /* Description */ }
328- < FormField
329- control = { form . control }
330- name = "description"
331- render = { ( { field } ) => (
332- < FormItem >
333- < FormLabel > Description</ FormLabel >
334- < FormControl >
335- < Textarea { ...field } />
336- </ FormControl >
320+ { props . isBatchMetadataInstalled && (
321+ < div className = "flex flex-col gap-6 lg:flex-row" >
322+ { /* Left */ }
323+ < div className = "shrink-0 lg:w-[300px]" >
324+ < NFTMediaFormGroup form = { form } previewMaxWidth = "300px" />
325+ </ div >
326+
327+ { /* Right */ }
328+ < div className = "flex grow flex-col gap-6" >
329+ { /* name */ }
330+ < FormField
331+ control = { form . control }
332+ name = "name"
333+ render = { ( { field } ) => (
334+ < FormItem >
335+ < FormLabel > Name</ FormLabel >
336+ < FormControl >
337+ < Input { ...field } />
338+ </ FormControl >
339+
340+ < FormMessage />
341+ </ FormItem >
342+ ) }
343+ />
337344
338- < FormMessage />
339- </ FormItem >
340- ) }
341- />
345+ { /* Description */ }
346+ < FormField
347+ control = { form . control }
348+ name = "description"
349+ render = { ( { field } ) => (
350+ < FormItem >
351+ < FormLabel > Description</ FormLabel >
352+ < FormControl >
353+ < Textarea { ...field } />
354+ </ FormControl >
355+
356+ < FormMessage />
357+ </ FormItem >
358+ ) }
359+ />
342360
343- { /* TODO - convert to shadcn + tailwind */ }
344- < PropertiesFormControl
345- watch = { form . watch }
346- errors = { form . formState . errors }
347- control = { form . control }
348- register = { form . register }
349- setValue = { form . setValue }
350- />
361+ { /* TODO - convert to shadcn + tailwind */ }
362+ < PropertiesFormControl
363+ watch = { form . watch }
364+ errors = { form . formState . errors }
365+ control = { form . control }
366+ register = { form . register }
367+ setValue = { form . setValue }
368+ />
351369
352- { /* Advanced options */ }
353- < Accordion
354- type = "single"
355- collapsible = {
356- ! (
357- form . formState . errors . background_color ||
358- form . formState . errors . external_url
359- )
360- }
361- >
362- < AccordionItem
363- value = "advanced-options"
364- className = "-mx-1 border-t border-b-0"
370+ { /* Advanced options */ }
371+ < Accordion
372+ type = "single"
373+ collapsible = {
374+ ! (
375+ form . formState . errors . background_color ||
376+ form . formState . errors . external_url
377+ )
378+ }
365379 >
366- < AccordionTrigger className = "px-1" >
367- Advanced Options
368- </ AccordionTrigger >
369- < AccordionContent className = "px-1" >
370- < AdvancedNFTMetadataFormGroup form = { form } />
371- </ AccordionContent >
372- </ AccordionItem >
373- </ Accordion >
380+ < AccordionItem
381+ value = "advanced-options"
382+ className = "-mx-1 border-t border-b-0"
383+ >
384+ < AccordionTrigger className = "px-1" >
385+ Advanced Options
386+ </ AccordionTrigger >
387+ < AccordionContent className = "px-1" >
388+ < AdvancedNFTMetadataFormGroup form = { form } />
389+ </ AccordionContent >
390+ </ AccordionItem >
391+ </ Accordion >
392+ </ div >
374393 </ div >
375- </ div >
394+ ) }
376395
377396 < Separator />
378397
379398 { /* Other options */ }
380- < div
381- className = { cn (
382- "grid gap-4" ,
383- props . showAmount ? "grid-cols-1 lg:grid-cols-2" : "grid-cols-1" ,
384- ) }
385- >
399+ < div className = "flex flex-col gap-4 md:flex-row" >
386400 < FormField
387401 control = { form . control }
388402 name = "recipient"
389403 render = { ( { field } ) => (
390- < FormItem >
404+ < FormItem className = "flex-1" >
391405 < FormLabel > Recipient Address</ FormLabel >
392406 < FormControl >
393407 < Input placeholder = "0x..." { ...field } />
@@ -397,12 +411,12 @@ function MintNFTSection(props: {
397411 ) }
398412 />
399413
400- { props . showAmount && (
414+ { ! props . isErc721 && (
401415 < FormField
402416 control = { form . control }
403417 name = "amount"
404418 render = { ( { field } ) => (
405- < FormItem >
419+ < FormItem className = "flex-1" >
406420 < FormLabel > Amount</ FormLabel >
407421 < FormControl >
408422 < Input { ...field } />
@@ -411,6 +425,21 @@ function MintNFTSection(props: {
411425 ) }
412426 />
413427 ) }
428+
429+ { ! props . isErc721 && ! props . isSequentialTokenIdInstalled && (
430+ < FormField
431+ control = { form . control }
432+ name = "tokenId"
433+ render = { ( { field } ) => (
434+ < FormItem className = "flex-1" >
435+ < FormLabel > Token ID</ FormLabel >
436+ < FormControl >
437+ < Input { ...field } />
438+ </ FormControl >
439+ </ FormItem >
440+ ) }
441+ />
442+ ) }
414443 </ div >
415444
416445 < div className = "flex justify-end" >
0 commit comments