Skip to content

Commit 5e63cae

Browse files
committed
fixing lint and typecheck errors
1 parent d74d420 commit 5e63cae

File tree

8 files changed

+179
-135
lines changed

8 files changed

+179
-135
lines changed

apps/dashboard/src/app/(dashboard)/(chain)/[chain_id]/[contractAddress]/modules/components/InstalledModulesTable.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ export const InstalledModulesTable = (props: {
2323
installedModules.data || [],
2424
props.contract,
2525
);
26-
console.log("allModuleContractInfo: ", allModuleContractInfo);
2726

2827
const sectionTitle = (
2928
<h2 className="mb-3 font-bold text-2xl tracking-tight">
@@ -54,6 +53,7 @@ export const InstalledModulesTable = (props: {
5453
<ModuleCard
5554
key={moduleAddress}
5655
moduleAddress={moduleAddress}
56+
allModuleContractInfo={allModuleContractInfo?.data || []}
5757
contract={props.contract}
5858
onRemoveModule={props.refetchModules}
5959
ownerAccount={ownerAccount}

apps/dashboard/src/app/(dashboard)/(chain)/[chain_id]/[contractAddress]/modules/components/Mintable.tsx

Lines changed: 111 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ import { Input } from "@/components/ui/input";
2121
import { Separator } from "@/components/ui/separator";
2222
import { Skeleton } from "@/components/ui/skeleton";
2323
import { Textarea } from "@/components/ui/textarea";
24-
import { cn } from "@/lib/utils";
2524
import { zodResolver } from "@hookform/resolvers/zod";
2625
import { useMutation } from "@tanstack/react-query";
2726
import { 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

5858
function 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

272287
function 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">

apps/dashboard/src/app/(dashboard)/(chain)/[chain_id]/[contractAddress]/modules/components/mintable.stories.tsx

Lines changed: 34 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,11 @@ const testAddress1 = "0x1F846F6DAE38E1C88D71EAA191760B15f38B7A37";
3737

3838
function Component() {
3939
const [isOwner, setIsOwner] = useState(true);
40-
const [showAmount, setShowAmount] = useState(false);
40+
const [isErc721, setIsErc721] = useState(false);
41+
const [isBatchMetadataInstalled, setIsBatchMetadataInstalled] =
42+
useState(false);
43+
const [isSequentialTokenIdInstalled, setIsSequentialTokenIdInstalled] =
44+
useState(false);
4145
async function updatePrimaryRecipientStub(values: UpdateFormValues) {
4246
console.log("submitting", values);
4347
await new Promise((resolve) => setTimeout(resolve, 1000));
@@ -78,16 +82,31 @@ function Component() {
7882
/>
7983

8084
<CheckboxWithLabel
81-
value={showAmount}
82-
onChange={setShowAmount}
83-
id="showAmount"
85+
value={isErc721}
86+
onChange={setIsErc721}
87+
id="isErc721"
8488
label="Show Amount Input"
8589
/>
90+
91+
<CheckboxWithLabel
92+
value={isSequentialTokenIdInstalled}
93+
onChange={setIsSequentialTokenIdInstalled}
94+
id="isSequentialTokenIdInstalled"
95+
label="Show Token ID Input"
96+
/>
97+
98+
<CheckboxWithLabel
99+
value={isBatchMetadataInstalled}
100+
onChange={setIsBatchMetadataInstalled}
101+
id="isBatchMetadataInstalled"
102+
label="Show Metadata Input"
103+
/>
86104
</div>
87105

88106
<BadgeContainer label="Empty Primary Sale Recipient">
89107
<MintableModuleUI
90108
contractInfo={contractInfo}
109+
allModuleContractInfo={[]}
91110
moduleAddress="0x0000000000000000000000000000000000000000"
92111
isPending={false}
93112
primarySaleRecipient={""}
@@ -98,13 +117,16 @@ function Component() {
98117
isPending: removeMutation.isPending,
99118
}}
100119
isOwnerAccount={isOwner}
101-
showAmount={showAmount}
120+
isErc721={isErc721}
121+
isSequentialTokenIdInstalled={isSequentialTokenIdInstalled}
122+
isBatchMetadataInstalled={isBatchMetadataInstalled}
102123
/>
103124
</BadgeContainer>
104125

105126
<BadgeContainer label="Filled Primary Sale Recipient">
106127
<MintableModuleUI
107128
contractInfo={contractInfo}
129+
allModuleContractInfo={[]}
108130
moduleAddress="0x0000000000000000000000000000000000000000"
109131
isPending={false}
110132
primarySaleRecipient={testAddress1}
@@ -115,13 +137,16 @@ function Component() {
115137
isPending: removeMutation.isPending,
116138
}}
117139
isOwnerAccount={isOwner}
118-
showAmount={showAmount}
140+
isErc721={isErc721}
141+
isSequentialTokenIdInstalled={isSequentialTokenIdInstalled}
142+
isBatchMetadataInstalled={isBatchMetadataInstalled}
119143
/>
120144
</BadgeContainer>
121145

122146
<BadgeContainer label="Pending">
123147
<MintableModuleUI
124148
contractInfo={contractInfo}
149+
allModuleContractInfo={[]}
125150
moduleAddress="0x0000000000000000000000000000000000000000"
126151
isPending={true}
127152
primarySaleRecipient={testAddress1}
@@ -132,7 +157,9 @@ function Component() {
132157
isPending: removeMutation.isPending,
133158
}}
134159
isOwnerAccount={isOwner}
135-
showAmount={showAmount}
160+
isErc721={isErc721}
161+
isSequentialTokenIdInstalled={isSequentialTokenIdInstalled}
162+
isBatchMetadataInstalled={isBatchMetadataInstalled}
136163
/>
137164
</BadgeContainer>
138165

0 commit comments

Comments
 (0)