Skip to content

Commit cf98aa5

Browse files
committed
created sequential token ID field set
1 parent 04ecaef commit cf98aa5

File tree

3 files changed

+74
-3
lines changed

3 files changed

+74
-3
lines changed

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -248,9 +248,11 @@ export function TransferableModuleUI(
248248
)}
249249

250250
<div className="flex flex-col gap-3">
251-
<p className="text-muted-foreground text-sm">
252-
Accounts that may override the transfer restrictions
253-
</p>
251+
{formFields.fields.length > 0 && (
252+
<p className="text-muted-foreground text-sm">
253+
Accounts that may override the transfer restrictions
254+
</p>
255+
)}
254256

255257
{/* Addresses */}
256258
{formFields.fields.map((fieldItem, index) => (

apps/dashboard/src/components/contract-components/contract-deploy-form/modular-contract-default-modules-fieldset.tsx

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { FormErrorMessage, FormLabel } from "tw-components";
66
import type { CustomContractDeploymentForm } from "./custom-contract";
77
import { PrimarySaleFieldset } from "./primary-sale-fieldset";
88
import { RoyaltyFieldset } from "./royalty-fieldset";
9+
import { SequentialTokenIdFieldset } from "./sequential-token-id-fieldset";
910

1011
export function getModuleInstallParams(mod: FetchDeployMetadataResult) {
1112
return (
@@ -67,6 +68,16 @@ function RenderModule(props: {
6768
<RenderPrimarySaleFieldset module={module} form={form} isTWPublisher />
6869
);
6970
}
71+
72+
if (showSequentialTokenIdFieldset(paramNames)) {
73+
return (
74+
<RenderSequentialTokenIdFieldset
75+
module={module}
76+
form={form}
77+
isTWPublisher
78+
/>
79+
);
80+
}
7081
}
7182

7283
return (
@@ -133,6 +144,26 @@ function RenderPrimarySaleFieldset(prosp: {
133144
);
134145
}
135146

147+
function RenderSequentialTokenIdFieldset(prosp: {
148+
module: FetchDeployMetadataResult;
149+
form: CustomContractDeploymentForm;
150+
isTWPublisher: boolean;
151+
}) {
152+
const { module, form } = prosp;
153+
154+
const startTokenIdPath = `moduleData.${module.name}.startTokenId` as const;
155+
156+
return (
157+
<SequentialTokenIdFieldset
158+
isInvalid={!!form.getFieldState(startTokenIdPath, form.formState).error}
159+
register={form.register(startTokenIdPath)}
160+
errorMessage={
161+
form.getFieldState(startTokenIdPath, form.formState).error?.message
162+
}
163+
/>
164+
);
165+
}
166+
136167
function RenderRoyaltyFieldset(props: {
137168
module: FetchDeployMetadataResult;
138169
form: CustomContractDeploymentForm;
@@ -194,3 +225,7 @@ export function showRoyaltyFieldset(paramNames: string[]) {
194225
export function showPrimarySaleFiedset(paramNames: string[]) {
195226
return paramNames.length === 1 && paramNames.includes("primarySaleRecipient");
196227
}
228+
229+
export function showSequentialTokenIdFieldset(paramNames: string[]) {
230+
return paramNames.length === 1 && paramNames.includes("startTokenId");
231+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import { FormControl } from "@chakra-ui/react";
2+
import { SolidityInput } from "contract-ui/components/solidity-inputs";
3+
import type { UseFormRegisterReturn } from "react-hook-form";
4+
import { FormErrorMessage, FormHelperText, FormLabel } from "tw-components";
5+
import { Fieldset } from "./common";
6+
7+
interface SequentialTokenIdFieldsetProps {
8+
isInvalid: boolean;
9+
register: UseFormRegisterReturn;
10+
errorMessage: string | undefined;
11+
}
12+
13+
export const SequentialTokenIdFieldset: React.FC<
14+
SequentialTokenIdFieldsetProps
15+
> = (props) => {
16+
return (
17+
<Fieldset legend="Sequential Token ID">
18+
<FormControl isRequired isInvalid={props.isInvalid}>
19+
<FormLabel>Start Token ID</FormLabel>
20+
<SolidityInput
21+
solidityType="uint256"
22+
variant="filled"
23+
{...props.register}
24+
/>
25+
26+
<FormErrorMessage>{props.errorMessage}</FormErrorMessage>
27+
28+
<FormHelperText className="!text-sm text-muted-foreground">
29+
The starting token ID for the NFT collection.
30+
</FormHelperText>
31+
</FormControl>
32+
</Fieldset>
33+
);
34+
};

0 commit comments

Comments
 (0)