Skip to content

Commit 45c7614

Browse files
committed
[TOOL-4689] Dashboard: Integrate ERC20Asset contract in token creation flow
1 parent 376d184 commit 45c7614

File tree

18 files changed

+429
-358
lines changed

18 files changed

+429
-358
lines changed

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/@/constants/server-envs.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,6 @@ import { isProd } from "./env-utils";
66
const experimental_taintUniqueValue =
77
_experimental_taintUniqueValue || (() => {});
88

9-
// Make sure to taint the server only envs here with experimental_taintUniqueValue ONLY if they contain a UNIQUE sensitive value
10-
// if an env has a generic value that may appear naturally in client components - do not taint it
11-
129
export const DASHBOARD_THIRDWEB_SECRET_KEY =
1310
process.env.DASHBOARD_SECRET_KEY || "";
1411

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export function StepCard(props: {
77
title: string;
88
tracking: {
99
page: string;
10-
contractType: "DropERC20" | "NFTCollection";
10+
contractType: "ERC20Asset" | "NFTCollection";
1111
};
1212
prevButton:
1313
| undefined
@@ -42,7 +42,7 @@ export function StepCard(props: {
4242
{props.children}
4343

4444
{(props.prevButton || props.nextButton) && (
45-
<div className="flex justify-end gap-3 border-t p-6">
45+
<div className="flex justify-end gap-3 border-t p-4 md:p-6">
4646
{props.prevButton && (
4747
<Button
4848
variant="outline"

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { FormFieldSetup } from "@/components/blocks/FormFieldSetup";
44
import { SingleNetworkSelector } from "@/components/blocks/NetworkSelectors";
55
import { Form } from "@/components/ui/form";
66
import { Input } from "@/components/ui/input";
7+
import { Skeleton } from "@/components/ui/skeleton";
78
import { Textarea } from "@/components/ui/textarea";
89
import { ClientOnly } from "components/ClientOnly/ClientOnly";
910
import { FileInput } from "components/shared/FileInput";
@@ -95,7 +96,7 @@ export function NFTCollectionInfoFieldset(props: {
9596
htmlFor="chain"
9697
errorMessage={form.formState.errors.chain?.message}
9798
>
98-
<ClientOnly ssr={null}>
99+
<ClientOnly ssr={<Skeleton className="h-10" />}>
99100
<SingleNetworkSelector
100101
className="bg-background"
101102
client={props.client}

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import {
88
type ThirdwebClient,
99
getAddress,
1010
} from "thirdweb";
11-
import { useActiveAccount } from "thirdweb/react";
11+
import { useActiveAccount, useActiveWalletChain } from "thirdweb/react";
1212
import {
1313
type CreateNFTCollectionFunctions,
1414
type NFTCollectionInfoFormValues,
@@ -148,14 +148,15 @@ export function CreateNFTPageUI(props: {
148148
}
149149

150150
function useNFTCollectionInfoForm() {
151+
const activeChain = useActiveWalletChain();
151152
return useForm<NFTCollectionInfoFormValues>({
152153
resolver: zodResolver(nftCollectionInfoFormSchema),
153-
values: {
154+
defaultValues: {
154155
name: "",
155156
description: "",
156157
symbol: "",
157158
image: undefined,
158-
chain: "1",
159+
chain: activeChain?.id.toString() || "1",
159160
socialUrls: [
160161
{
161162
platform: "Website",

apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/assets/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
socialUrls: socialUrlsSchema,
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
supply: z.string().min(1, "Supply is required"),
2030
saleAllocationPercentage: z.string().refine(
@@ -29,16 +39,13 @@ export const tokenDistributionFormSchema = z.object({
2939
message: "Must be a number between 0 and 100",
3040
},
3141
),
32-
saleTokenAddress: z.string(),
33-
salePrice: z.string().refine(
34-
(value) => {
35-
const number = Number(value);
36-
return !Number.isNaN(number) && number >= 0;
37-
},
38-
{
39-
message: "Must be number larger than or equal to 0",
40-
},
41-
),
42+
directSale: z.object({
43+
priceAmount: priceAmountSchema,
44+
currencyAddress: addressSchema,
45+
}),
46+
publicMarket: z.object({
47+
tradingFees: z.enum(["0.01", "0.05", "0.3", "1"]),
48+
}),
4249
airdropAddresses: z.array(
4350
z.object({
4451
address: addressSchema,
@@ -47,7 +54,7 @@ export const tokenDistributionFormSchema = z.object({
4754
),
4855
// UI states
4956
airdropEnabled: z.boolean(),
50-
saleEnabled: z.boolean(),
57+
saleMode: z.enum(["direct-sale", "public-market", "disabled"]),
5158
});
5259

5360
export type TokenDistributionForm = UseFormReturn<

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export function getTokenDeploymentTrackingData(
1616
category: "custom-contract",
1717
action: "deploy",
1818
label: params.type,
19-
publisherAndContractName: "deployer.thirdweb.eth/DropERC20",
19+
publisherAndContractName: "deployer.thirdweb.eth/ERC20Asset",
2020
chainId: params.chainId,
2121
deploymentType: "asset",
2222
};
@@ -40,7 +40,7 @@ export function getTokenStepTrackingData(
4040
return {
4141
category: "asset",
4242
action: params.action,
43-
contractType: "DropERC20",
43+
contractType: "ERC20Asset",
4444
label: params.status,
4545
chainId: params.chainId,
4646
...(params.status === "error"
@@ -56,7 +56,7 @@ export function getTokenLaunchTrackingData(
5656
params: {
5757
chainId: number;
5858
airdropEnabled: boolean;
59-
saleEnabled: boolean;
59+
saleMode: "disabled" | "direct-sale" | "public-market";
6060
} & (
6161
| {
6262
type: "attempt" | "success";
@@ -71,10 +71,10 @@ export function getTokenLaunchTrackingData(
7171
category: "asset",
7272
action: "launch",
7373
label: params.type,
74-
contractType: "DropERC20",
74+
contractType: "ERC20Asset",
7575
chainId: params.chainId,
7676
airdropEnabled: params.airdropEnabled,
77-
saleEnabled: params.saleEnabled,
77+
saleMode: params.saleMode,
7878
...(params.type === "error"
7979
? {
8080
errorMessage: params.errorMessage,
@@ -87,7 +87,7 @@ export function getTokenLaunchTrackingData(
8787
export function getStepCardTrackingData(params: {
8888
step: string;
8989
click: "prev" | "next";
90-
contractType: "DropERC20" | "NFTCollection";
90+
contractType: "ERC20Asset" | "NFTCollection";
9191
}) {
9292
return {
9393
category: "asset",

0 commit comments

Comments
 (0)