Skip to content

Commit d363c19

Browse files
committed
[TOOL-4689] Dashboard: Integrate ERC20Asset contract in token creation flow
1 parent 7266b31 commit d363c19

File tree

14 files changed

+418
-315
lines changed

14 files changed

+418
-315
lines changed

apps/dashboard/src/@/components/contract-components/tables/contract-table.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,7 @@ const contractTypeToAssetTypeRecord: Record<string, string | undefined> = {
300300
DropERC20: "Coin",
301301
DropERC721: "NFT Collection",
302302
DropERC1155: "NFT Collection",
303+
ERC20Asset: "Coin",
303304
};
304305

305306
const NetworkFilterCell = React.memo(function NetworkFilterCell({

apps/dashboard/src/@/components/ui/tabs.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ export function TabButtons(props: {
9898
shadowColor?: string;
9999
tabIconClassName?: string;
100100
hideBottomLine?: boolean;
101+
bottomLineClassName?: string;
101102
}) {
102103
const { containerRef, lineRef, activeTabRef } =
103104
useUnderline<HTMLButtonElement>();
@@ -106,7 +107,12 @@ export function TabButtons(props: {
106107
<div className={cn("relative", props.containerClassName)}>
107108
{/* Bottom line */}
108109
{!props.hideBottomLine && (
109-
<div className="absolute right-0 bottom-0 left-0 h-[1px] bg-border" />
110+
<div
111+
className={cn(
112+
"absolute right-0 bottom-0 left-0 h-[1px] bg-border",
113+
props.bottomLineClassName,
114+
)}
115+
/>
110116
)}
111117

112118
<ScrollShadow

apps/dashboard/src/@/hooks/project-contracts.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export function useAddContractToProject() {
1111
contractAddress: string;
1212
chainId: string;
1313
deploymentType: "asset" | undefined;
14-
contractType: "DropERC20" | "DropERC721" | "DropERC1155" | undefined;
14+
contractType: "ERC20Asset" | "DropERC721" | "DropERC1155" | undefined;
1515
}) => {
1616
const res = await apiServerProxy({
1717
body: JSON.stringify({

apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/tokens/create/_common/step-card.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ export function StepCard(props: {
3535
{props.children}
3636

3737
{(props.prevButton || props.nextButton) && (
38-
<div className="flex justify-end gap-3 border-t p-6">
38+
<div className="flex justify-end gap-3 border-t p-4 md:p-6">
3939
{props.prevButton && (
4040
<Button
4141
className="gap-2"

apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/tokens/create/nft/collection-info/nft-collection-info-fieldset.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { FormFieldSetup } from "@/components/blocks/FormFieldSetup";
99
import { SingleNetworkSelector } from "@/components/blocks/NetworkSelectors";
1010
import { Form } from "@/components/ui/form";
1111
import { Input } from "@/components/ui/input";
12+
import { Skeleton } from "@/components/ui/skeleton";
1213
import { Textarea } from "@/components/ui/textarea";
1314
import { SocialUrlsFieldset } from "../../_common/SocialUrls";
1415
import { StepCard } from "../../_common/step-card";
@@ -94,7 +95,7 @@ export function NFTCollectionInfoFieldset(props: {
9495
isRequired
9596
label="Chain"
9697
>
97-
<ClientOnly ssr={null}>
98+
<ClientOnly ssr={<Skeleton className="h-10" />}>
9899
<SingleNetworkSelector
99100
chainId={Number(form.watch("chain"))}
100101
className="bg-background"

apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/tokens/create/nft/create-nft-page-ui.tsx

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import {
88
NATIVE_TOKEN_ADDRESS,
99
type ThirdwebClient,
1010
} from "thirdweb";
11-
import { useActiveAccount } from "thirdweb/react";
11+
import { useActiveAccount, useActiveWalletChain } from "thirdweb/react";
1212
import { reportAssetCreationStepConfigured } from "@/analytics/report";
1313
import {
1414
type CreateNFTCollectionFunctions,
@@ -160,11 +160,10 @@ export function CreateNFTPageUI(props: {
160160
}
161161

162162
function useNFTCollectionInfoForm() {
163+
const activeChain = useActiveWalletChain();
163164
return useForm<NFTCollectionInfoFormValues>({
164-
resolver: zodResolver(nftCollectionInfoFormSchema),
165-
reValidateMode: "onChange",
166-
values: {
167-
chain: "1",
165+
defaultValues: {
166+
chain: activeChain?.id.toString() || "1",
168167
description: "",
169168
image: undefined,
170169
name: "",
@@ -180,5 +179,7 @@ function useNFTCollectionInfoForm() {
180179
],
181180
symbol: "",
182181
},
182+
resolver: zodResolver(nftCollectionInfoFormSchema),
183+
reValidateMode: "onChange",
183184
});
184185
}

apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/tokens/create/token/_common/form.ts

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,16 @@ export const tokenInfoFormSchema = z.object({
1515
.max(10, "Symbol must be 10 characters or less"),
1616
});
1717

18+
const priceAmountSchema = z.string().refine(
19+
(value) => {
20+
const number = Number(value);
21+
return !Number.isNaN(number) && number >= 0;
22+
},
23+
{
24+
message: "Must be number larger than or equal to 0",
25+
},
26+
);
27+
1828
export const tokenDistributionFormSchema = z.object({
1929
airdropAddresses: z.array(
2030
z.object({
@@ -24,6 +34,13 @@ export const tokenDistributionFormSchema = z.object({
2434
),
2535
// UI states
2636
airdropEnabled: z.boolean(),
37+
directSale: z.object({
38+
currencyAddress: addressSchema,
39+
priceAmount: priceAmountSchema,
40+
}),
41+
publicMarket: z.object({
42+
tradingFees: z.enum(["0.01", "0.05", "0.3", "1"]),
43+
}),
2744
saleAllocationPercentage: z.string().refine(
2845
(value) => {
2946
const number = Number(value);
@@ -36,17 +53,7 @@ export const tokenDistributionFormSchema = z.object({
3653
message: "Must be a number between 0 and 100",
3754
},
3855
),
39-
saleEnabled: z.boolean(),
40-
salePrice: z.string().refine(
41-
(value) => {
42-
const number = Number(value);
43-
return !Number.isNaN(number) && number >= 0;
44-
},
45-
{
46-
message: "Must be number larger than or equal to 0",
47-
},
48-
),
49-
saleTokenAddress: z.string(),
56+
saleMode: z.enum(["direct-sale", "public-market", "disabled"]),
5057
supply: z.string().min(1, "Supply is required"),
5158
});
5259

0 commit comments

Comments
 (0)