Compare commits

..
Author SHA1 Message Date
Joaquim Vergesandgithub-actions[bot] 75bf09126f Version Packages (#7701)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2025-07-24 13:40:52 -07:00
Jonas Daniels 9d8c7f1f7d Add gateway to possible usage sources (#7700) 2025-07-24 13:39:12 -07:00
MananTank 9dc8f5a637 [TOOL-5111] Playground: Update slugs, add redirects (#7698)
<!--

## title your PR with this format: "[SDK/Dashboard/Portal] Feature/Fix: Concise title for the changes"

If you did not copy the branch name from Linear, paste the issue tag here (format is TEAM-0000):

## Notes for the reviewer

Anything important to call out? Be sure to also clarify these in your comments.

## How to test

Unit tests, playground, etc.

-->

<!-- start pr-codex -->

---

## PR-Codex overview
This PR focuses on renaming and restructuring routes from `/connect` to `/wallets`, alongside adjustments in documentation links and component imports to streamline the application.

### Detailed summary
- Updated redirect paths from `/connect/...` to `/wallets/...`
- Changed documentation links accordingly
- Refactored component imports to match new route structure
- Adjusted breadcrumb links and sidebar navigation items
- Renamed files and folders to reflect the new `/wallets` hierarchy

> ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}`

<!-- end pr-codex -->

<!-- This is an auto-generated comment: release notes by coderabbit.ai -->

## Summary by CodeRabbit

* **New Features**
  * Expanded and reorganized URL redirects for improved navigation, including new paths for wallets, payments, and transactions sections.

* **Refactor**
  * Updated navigation links and internal references to use new URL structures for wallets, payments, and transactions.
  * Simplified import paths and component structures for improved code clarity and maintainability.

* **Documentation**
  * Updated documentation links throughout the app to reflect new URLs and more relevant resources.

* **Style**
  * Minor formatting improvements for code consistency and readability.

* **Chores**
  * Enhanced code comments to clarify the use of array index as React list keys.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2025-07-24 20:20:12 +00:00
Jonas Daniels 48361f92b7 Add custom amount input to credit balance section (#7697) 2025-07-24 12:46:25 -07:00
MananTank 1659ae3754 Dashboard: Migrate Various forms in contract pages from chakra to tailwind (#7690)
<!--

## title your PR with this format: "[SDK/Dashboard/Portal] Feature/Fix: Concise title for the changes"

If you did not copy the branch name from Linear, paste the issue tag here (format is TEAM-0000):

## Notes for the reviewer

Anything important to call out? Be sure to also clarify these in your comments.

## How to test

Unit tests, playground, etc.

-->

<!-- start pr-codex -->

---

## PR-Codex overview
This PR focuses on refactoring the form components in the dashboard's NFT management system to improve structure and usability. It replaces Chakra UI components with custom UI components, enhancing consistency and maintainability.

### Detailed summary
- Refactored `PropertiesFormControl` to utilize custom form components.
- Removed unused imports and consolidated imports from `@chakra-ui/react`.
- Updated form handling to use `FormField`, `FormItem`, and `FormDescription`.
- Enhanced error handling by integrating `FormMessage` for displaying validation messages.
- Replaced `Flex`, `FormControl`, and other Chakra UI components with custom equivalents.
- Updated `LazyMintNftForm`, `NFTMintForm`, and `UpdateNftMetadata` forms to use new structure and components.
- Improved user experience by refining button and input styles and behavior.

> ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}`

<!-- end pr-codex -->

<!-- This is an auto-generated comment: release notes by coderabbit.ai -->

## Summary by CodeRabbit

* **Refactor**
  * Migrated all NFT-related form components from Chakra UI to a custom UI library, updating form controls, buttons, accordions, and input elements.
  * Updated error handling and helper text display to use new form components.
  * Simplified and modernized form structures for minting, lazy minting, metadata updates, and property controls.
  * Removed file upload support and reset functionality from the properties form.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2025-07-24 18:49:38 +00:00
MananTank 88d44aff50 Dashboard: Migrate Batch Upload NFTs from chakra to tailwind, UI improvements (#7689)
<!--

## title your PR with this format: "[SDK/Dashboard/Portal] Feature/Fix: Concise title for the changes"

If you did not copy the branch name from Linear, paste the issue tag here (format is TEAM-0000):

## Notes for the reviewer

Anything important to call out? Be sure to also clarify these in your comments.

## How to test

Unit tests, playground, etc.

-->

<!-- start pr-codex -->

---

## PR-Codex overview
This PR focuses on refactoring and enhancing the `FilePreview` component, improving the upload process for NFTs, and updating various components to utilize the new structure. Several files related to example CSVs were deleted, and new features were added for better file handling.

### Detailed summary
- Deleted example CSV files.
- Added `FilePreview` import in multiple components.
- Enhanced `FilePreview` styling and functionality.
- Updated `DownloadFileButton` to accept additional props.
- Refactored `BatchTable` to improve pagination and display logic.
- Improved `UploadStep` for better user experience during file uploads.
- Introduced `DelayedRevealConfiguration` and `SelectReveal` components for managing NFT reveal types.

> ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}`

<!-- end pr-codex -->

<!-- This is an auto-generated comment: release notes by coderabbit.ai -->
## Summary by CodeRabbit

* **Refactor**
  * Replaced Chakra UI and third-party libraries with a custom UI system across batch upload components for a more unified look and feel.
  * Simplified and restyled batch minting forms, tables, upload steps, and reveal configuration.
  * Updated drag-and-drop functionality to use a dedicated DropZone component.
  * Streamlined table rendering and pagination with manual state management and local UI components.
  * Improved layout, styling, and accessibility for option selection, shuffle toggle, and modal dialogs.
  * Enhanced media preview styling and standardized file preview imports for improved consistency.
  * Added tabbed format selection and enriched instructional content with downloadable CSV/JSON examples in the upload step.
  * Improved submit button placement and added help links for user guidance during batch minting.
* **New Features**
  * Added customizable button variants and styling options to the file download button for better UI flexibility.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2025-07-24 18:17:47 +00:00
greg c63b3497bd Feature: New Payments Overview Page (#7691) 2025-07-24 11:16:42 -07:00
gregandManan Tank 74a21635e4 [Portal] Fix: Broken /connect Links (#7679)
Co-authored-by: Manan Tank <[email protected]>
2025-07-24 11:02:50 -07:00
Joaquim Vergesandgithub-actions[bot] 66b9bf3c6b Version Packages (#7694)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2025-07-24 02:00:52 -07:00
Joaquim Verges cf22c23b45 [SDK] Optimize 4337 signature performance (#7693) 2025-07-24 00:47:45 -07:00
165 changed files with 2567 additions and 2069 deletions
+2 -2
View File
@@ -18,8 +18,8 @@
## Features
- Support for React & React-Native
- First party support for [Embedded Wallets](https://portal.thirdweb.com/connect/embedded-wallet/overview) (social/email login)
- First party support for [Account Abstraction](https://portal.thirdweb.com/connect/account-abstraction/overview)
- First party support for [Embedded Wallets](https://portal.thirdweb.com/wallets) (social/email login)
- First party support for [Account Abstraction](https://portal.thirdweb.com/wallets/sponsor-gas)
- Instant connection to any chain with RPC Edge integration
- Integrated IPFS upload/download
- UI Components for connection, transactions, nft rendering
@@ -1,2 +0,0 @@
name,description,image,animation_url,external_url,background_color,youtube_url,additional,properties,can be,added
Token 0 Name,Token 0 Description,ipfs://ipfsHash/0,ipfs://ipfsHash/0,https://thirdweb.com,#0098EE,,every,row,is a ,property
1 name description image animation_url external_url background_color youtube_url additional properties can be added
2 Token 0 Name Token 0 Description ipfs://ipfsHash/0 ipfs://ipfsHash/0 https://thirdweb.com #0098EE every row is a property
@@ -1,4 +0,0 @@
name,description,image,animation_url,external_url,background_color,youtube_url,additional,properties,can be,added
Token 0 Name,Token 0 Description,0.png,0.mp4,https://thirdweb.com,#0098EE,,every,row,is a ,property
Token 1 Name,Token 1 Description,0.png,0.mp4,https://thirdweb.com,#0098EE,,every,row,is a ,property
Token 2 Name,Token 2 Description,0.png,0.mp4,https://thirdweb.com,#0098EE,,every,row,is a ,property
1 name description image animation_url external_url background_color youtube_url additional properties can be added
2 Token 0 Name Token 0 Description 0.png 0.mp4 https://thirdweb.com #0098EE every row is a property
3 Token 1 Name Token 1 Description 0.png 0.mp4 https://thirdweb.com #0098EE every row is a property
4 Token 2 Name Token 2 Description 0.png 0.mp4 https://thirdweb.com #0098EE every row is a property
@@ -1,2 +0,0 @@
name,description,external_url,background_color,youtube_url,additional,properties,can be,added
Token 0 Name,Token 0 Description,https://thirdweb.com,#0098EE,,every,row,is a ,property
1 name description external_url background_color youtube_url additional properties can be added
2 Token 0 Name Token 0 Description https://thirdweb.com #0098EE every row is a property
+20 -5
View File
@@ -66,15 +66,20 @@ const projectRoute = "/team/:team_slug/:project_slug";
const projectPageRedirects = [
{
destination: `${projectRoute}/universal-bridge/:path*`,
destination: `${projectRoute}/payments/:path*`,
permanent: false,
source: `${projectRoute}/connect/pay/:path*`,
},
{
destination: `${projectRoute}/universal-bridge/:path*`,
destination: `${projectRoute}/payments/:path*`,
permanent: false,
source: `${projectRoute}/connect/universal-bridge/:path*`,
},
{
destination: `${projectRoute}/payments/:path*`,
permanent: false,
source: `${projectRoute}/universal-bridge/:path*`,
},
{
destination: `${projectRoute}/account-abstraction/:path*`,
permanent: false,
@@ -375,12 +380,22 @@ async function redirects() {
permanent: false,
source: "/template/:slug",
},
// redirect /connect/pay to /universal-bridge
// redirect /connect/pay to /payments
{
destination: "/universal-bridge",
permanent: false,
destination: "/payments",
permanent: true,
source: "/connect/pay",
},
{
destination: "/payments",
permanent: true,
source: "/universal-bridge",
},
{
destination: "/payments/:slug",
permanent: true,
source: "/universal-bridge/:slug",
},
// PREVIOUS CAMPAIGNS
{
destination: "/",
+15
View File
@@ -413,3 +413,18 @@ export function reportUpsellShown(properties: UpsellParams) {
export function reportUpsellClicked(properties: UpsellParams) {
posthog.capture("upsell clicked", properties);
}
// ----------------------------
// PAYMENTS
// ----------------------------
/**
* ### Why do we need to report this event?
* - To track conversions on payment overview page
*
* ### Who is responsible for this event?
* @samina
*/
export function reportPaymentCardClick(properties: { id: string }) {
posthog.capture("payment card clicked", properties);
}
@@ -1,23 +1,18 @@
"use client";
import {
Alert,
AlertIcon,
Flex,
FormControl,
Input,
InputGroup,
InputRightElement,
Textarea,
} from "@chakra-ui/react";
import { zodResolver } from "@hookform/resolvers/zod";
import { Button } from "chakra/button";
import { FormErrorMessage, FormHelperText, FormLabel } from "chakra/form";
import { Heading } from "chakra/heading";
import { Text } from "chakra/text";
import { ChevronLeftIcon, EyeIcon, EyeOffIcon } from "lucide-react";
import { useRef, useState } from "react";
import { useDropzone } from "react-dropzone";
import {
ArrowLeftIcon,
ArrowRightIcon,
EyeIcon,
EyeOffIcon,
HelpCircleIcon,
LockKeyholeIcon,
RefreshCcwIcon,
ShuffleIcon,
} from "lucide-react";
import Link from "next/link";
import { useState } from "react";
import { useForm } from "react-hook-form";
import type { ThirdwebClient } from "thirdweb";
import type { CreateDelayedRevealBatchParams } from "thirdweb/extensions/erc721";
@@ -25,12 +20,14 @@ import type { NFTInput } from "thirdweb/utils";
import { z } from "zod";
import { FileInput } from "@/components/blocks/FileInput";
import { TransactionButton } from "@/components/tx-button";
import { Checkbox, CheckboxWithLabel } from "@/components/ui/checkbox";
import { UnderlineLink } from "@/components/ui/UnderlineLink";
import type { ComponentWithChildren } from "@/types/component-with-children";
import { Button } from "@/components/ui/button";
import { Form, FormItem, FormLabel, FormMessage } from "@/components/ui/form";
import { Input } from "@/components/ui/input";
import { Switch } from "@/components/ui/switch";
import { Textarea } from "@/components/ui/textarea";
import { processInputData, shuffleData } from "@/utils/batch";
import { TabButtons } from "../ui/tabs";
import { BatchTable } from "./batch-table";
import { SelectOption } from "./lazy-mint-form/select-option";
import { UploadStep } from "./upload-step";
type DelayedSubmit = {
@@ -44,16 +41,6 @@ type InstantSubmit = {
type SubmitType = DelayedSubmit | InstantSubmit;
interface BatchLazyMintEVMProps {
nextTokenIdToMint: bigint;
canCreateDelayedRevealBatch: boolean;
onSubmit: (formData: SubmitType) => Promise<unknown>;
chainId: number;
client: ThirdwebClient;
}
type BatchLazyMintProps = BatchLazyMintEVMProps;
const BatchLazyMintFormSchema = z
.object({
confirmPassword: z
@@ -73,7 +60,7 @@ const BatchLazyMintFormSchema = z
name: z.string().min(1, "A name is required"),
})
.optional(),
revealType: z.literal("instant").or(z.literal("delayed")).optional(),
revealType: z.literal("instant").or(z.literal("delayed")),
// shared logic
shuffle: z.boolean().default(false),
@@ -91,18 +78,21 @@ function useBatchLazyMintForm() {
return useForm<BatchLazyMintFormType>({
defaultValues: {
metadatas: [],
revealType: undefined,
revealType: "instant",
shuffle: false,
},
resolver: zodResolver(BatchLazyMintFormSchema),
});
}
export const BatchLazyMint: ComponentWithChildren<
BatchLazyMintProps & {
isLoggedIn: boolean;
}
> = (props) => {
export function BatchLazyMint(props: {
nextTokenIdToMint: bigint;
canCreateDelayedRevealBatch: boolean;
onSubmit: (formData: SubmitType) => Promise<unknown>;
chainId: number;
client: ThirdwebClient;
isLoggedIn: boolean;
}) {
const [step, setStep] = useState(0);
const form = useBatchLazyMintForm();
@@ -110,369 +100,415 @@ export const BatchLazyMint: ComponentWithChildren<
const nftMetadatas = form.watch("metadatas");
const hasError = !!form.getFieldState("metadatas", form.formState).error;
const { getRootProps, getInputProps, isDragActive } = useDropzone({
onDrop: async (acceptedFiles) => {
try {
await processInputData(acceptedFiles, (data) =>
form.setValue("metadatas", data),
);
} catch {
form.setError("metadatas", {
message: "Invalid metadata files",
type: "validate",
});
}
if (nftMetadatas.length === 0) {
form.setError("metadatas", {
message: "Invalid metadata files",
type: "validate",
});
}
},
});
const paginationPortalRef = useRef<HTMLDivElement>(null);
return (
<form
className="mt-4 flex w-full flex-col"
onSubmit={form.handleSubmit((data) => {
// first shuffle
const shuffledMetadatas = data.shuffle
? shuffleData(data.metadatas)
: data.metadatas;
<Form {...form}>
<form
className="mt-4 flex w-full flex-col"
onSubmit={form.handleSubmit(async (data) => {
// first shuffle
const shuffledMetadatas = data.shuffle
? shuffleData(data.metadatas)
: data.metadatas;
// check submit is instant
if (data.revealType === "instant") {
return props.onSubmit({
data: { metadatas: shuffledMetadatas },
revealType: "instant",
});
}
// validate password
if (!data.password) {
form.setError("password", {
message: "A password is required for delayed reveal.",
type: "validate",
});
return;
}
// validate placeholder
if (!data.placeHolder?.name) {
form.setError("placeHolder.name", {
message: "A name is required for delayed reveal.",
type: "validate",
});
}
// submit
return props.onSubmit({
data: {
metadata: shuffledMetadatas,
password: data.password,
placeholderMetadata: {
description: data.placeHolder?.description,
image: data.placeHolder?.image,
name: data.placeHolder?.name,
// check submit is instant
if (data.revealType === "instant") {
return props.onSubmit({
data: { metadatas: shuffledMetadatas },
revealType: "instant",
});
}
// validate password
if (!data.password) {
form.setError("password", {
message: "A password is required for delayed reveal.",
type: "validate",
});
return;
}
// validate placeholder
if (!data.placeHolder?.name) {
form.setError("placeHolder.name", {
message: "A name is required for delayed reveal.",
type: "validate",
});
}
// submit
await props.onSubmit({
data: {
metadata: shuffledMetadatas,
password: data.password,
placeholderMetadata: {
description: data.placeHolder?.description,
image: data.placeHolder?.image,
name: data.placeHolder?.name,
},
},
},
revealType: "delayed",
});
})}
>
{step === 0 ? (
<div className="flex flex-col gap-6">
{nftMetadatas.length > 0 ? (
<>
<BatchTable
client={props.client}
data={nftMetadatas}
nextTokenIdToMint={props.nextTokenIdToMint}
portalRef={paginationPortalRef}
/>
<div className="border-border border-t">
<div className="flex flex-col items-center justify-between p-0 md:flex-row md:p-4">
<div ref={paginationPortalRef} />
<div className="mt-4 flex w-full flex-row items-center gap-2 md:mt-0 md:w-auto">
<Button
borderRadius="md"
isDisabled={!hasError}
onClick={() => {
form.reset();
}}
w={{ base: "100%", md: "auto" }}
>
Reset
</Button>
<Button
borderRadius="md"
colorScheme="primary"
onClick={() => setStep(1)}
w={{ base: "100%", md: "auto" }}
>
Next
</Button>
</div>
revealType: "delayed",
});
})}
>
{step === 0 ? (
<div>
{nftMetadatas.length > 0 ? (
<div className="pb-10">
<h2 className="text-2xl font-semibold tracking-tight mb-4">
Upload NFTs
</h2>
<BatchTable
client={props.client}
data={nftMetadatas}
nextTokenIdToMint={props.nextTokenIdToMint}
/>
<div className="mt-5 flex justify-end gap-4">
<Button
className="w-full md:w-auto gap-2"
disabled={!hasError}
onClick={() => {
form.reset();
}}
variant="outline"
>
<RefreshCcwIcon className="size-4" />
Reset
</Button>
<Button
className="w-full md:w-auto gap-2"
onClick={() => setStep(1)}
>
Next <ArrowRightIcon className="size-4" />
</Button>
</div>
</div>
</>
) : (
<UploadStep
getInputProps={getInputProps}
getRootProps={getRootProps}
hasFailed={hasError}
isDragActive={isDragActive}
/>
)}
</div>
) : (
<>
<Flex align="center" justify="space-between" mb={2} py={4} w="100%">
<div className="flex flex-row items-center gap-2">
) : (
<UploadStep
hasFailed={hasError}
reset={() => {
form.reset();
}}
onDrop={async (acceptedFiles) => {
try {
await processInputData(acceptedFiles, (data) =>
form.setValue("metadatas", data),
);
} catch {
form.setError("metadatas", {
message: "Invalid metadata files",
type: "validate",
});
}
if (nftMetadatas.length === 0) {
form.setError("metadatas", {
message: "Invalid metadata files",
type: "validate",
});
}
}}
/>
)}
</div>
) : (
<div className="container px-0 max-w-4xl pb-14">
<div className="flex mb-3">
<Button
className="text-muted-foreground"
className="gap-2 -translate-x-3 text-muted-foreground"
size="sm"
onClick={() => setStep(0)}
variant="ghost"
>
<ChevronLeftIcon className="size-5 cursor-pointer" />
<ArrowLeftIcon className="size-4" />
Back
</Button>
<Heading className="my-auto" size="title.md">
When will you reveal your NFTs?
</Heading>
</div>
</Flex>
<SelectReveal
canCreateDelayedRevealBatch={props.canCreateDelayedRevealBatch}
client={props.client}
form={form}
/>
{form.watch("revealType") && (
<>
<CheckboxWithLabel>
<Checkbox
checked={form.watch("shuffle")}
className="mt-3"
onCheckedChange={(val) => form.setValue("shuffle", !!val)}
/>
<div className="flex flex-col items-center gap-1 md:flex-row">
<p>Shuffle the order of the NFTs before uploading.</p>
<em>This is an off-chain operation and is not provable.</em>
</div>
</CheckboxWithLabel>
<div className="w-full md:w-[61%]">
<TransactionButton
className="mt-4 w-full"
client={props.client}
disabled={!nftMetadatas.length}
isLoggedIn={props.isLoggedIn}
isPending={form.formState.isSubmitting}
transactionCount={1}
txChainID={props.chainId}
type="submit"
>
{form.formState.isSubmitting
? `Uploading ${nftMetadatas.length} NFTs`
: `Upload ${nftMetadatas.length} NFTs`}
</TransactionButton>
{props.children}
</div>
<Text mt={2} size="body.sm">
<UnderlineLink
className="text-primary-500"
href="https://support.thirdweb.com/dashboard/n5evQ4EfEjEifczEQaZ1hL/batch-upload-troubleshooting/5WMQFqfaUTU1C8NM8FtJ2X"
rel="noopener noreferrer"
target="_blank"
>
Experiencing issues uploading your files?
</UnderlineLink>
</Text>
</>
)}
</>
)}
</form>
);
};
interface SelectRevealProps {
<h2 className="text-2xl font-semibold tracking-tight mb-4">
Upload NFTs
</h2>
<SelectReveal
canCreateDelayedRevealBatch={props.canCreateDelayedRevealBatch}
client={props.client}
form={form}
/>
<div className="h-4" />
<div className="space-y-6">
{form.watch("revealType") === "delayed" && (
<DelayedRevealConfiguration client={props.client} form={form} />
)}
{/* shuffle */}
<ShuffleNFTsCard
isShuffleEnabled={form.watch("shuffle")}
onShuffleChange={(val) => form.setValue("shuffle", val)}
/>
<div className="space-y-3">
<div className="flex justify-end">
<TransactionButton
client={props.client}
disabled={!nftMetadatas.length}
isLoggedIn={props.isLoggedIn}
isPending={form.formState.isSubmitting}
transactionCount={1}
txChainID={props.chainId}
type="submit"
>
{form.formState.isSubmitting
? `Uploading ${nftMetadatas.length} NFTs`
: `Upload ${nftMetadatas.length} NFTs`}
</TransactionButton>
</div>
<div className="flex justify-end">
<Link
className="text-sm flex items-center gap-2 text-muted-foreground hover:text-foreground"
href="https://portal.thirdweb.com/knowledge-base/troubleshoot/contracts/batch-upload"
rel="noopener noreferrer"
target="_blank"
>
<HelpCircleIcon className="size-4" />
Experiencing issues uploading your files?
</Link>
</div>
</div>
</div>
</div>
)}
</form>
</Form>
);
}
function ShuffleNFTsCard(props: {
isShuffleEnabled: boolean;
onShuffleChange: (val: boolean) => void;
}) {
return (
<div className="px-4 lg:px-6 py-8 border rounded-lg bg-card relative">
<div className="flex mb-3">
<div className="p-2 rounded-full border bg-card">
<ShuffleIcon className="size-4 text-muted-foreground" />
</div>
</div>
<h3 className="font-semibold text-lg mb-0.5 tracking-tight">
Shuffle NFTs
</h3>
<p className="text-sm text-muted-foreground">
Shuffle the order of the NFTs before uploading. This is an off-chain
operation and is not provable
</p>
<Switch
checked={props.isShuffleEnabled}
onCheckedChange={(val) => props.onShuffleChange(!!val)}
className="absolute right-4 top-4 lg:right-6 lg:top-8"
/>
</div>
);
}
function SelectReveal(props: {
form: ReturnType<typeof useBatchLazyMintForm>;
canCreateDelayedRevealBatch: boolean;
client: ThirdwebClient;
}) {
const { form, canCreateDelayedRevealBatch } = props;
return (
<div>
{canCreateDelayedRevealBatch && (
<TabButtons
containerClassName="mb-8"
tabClassName="!text-sm"
tabs={[
{
name: "Reveal upon mint",
onClick: () => {
form.setValue("revealType", "instant");
// reset all fields related to delayed reveal
form.resetField("password");
form.resetField("confirmPassword");
form.resetField("placeHolder");
},
isActive: form.watch("revealType") === "instant",
},
{
name: "Delayed Reveal",
onClick: () => form.setValue("revealType", "delayed"),
isActive: form.watch("revealType") === "delayed",
},
]}
/>
)}
{form.watch("revealType") === "instant" && (
<div>
<h2 className="font-semibold text-xl mb-1 tracking-tight leading-none">
Reveal upon mint
</h2>
<p className="text-muted-foreground text-sm">
Collectors will immediately see the final NFT when they complete the
minting
</p>
</div>
)}
{form.watch("revealType") === "delayed" && (
<div>
<h2 className="font-semibold text-xl mb-1 tracking-tight leading-none">
Delayed Reveal
</h2>
<p className="text-muted-foreground text-sm">
Collectors will mint your placeholder image, then you reveal at a
later time
</p>
</div>
)}
</div>
);
}
const SelectReveal: React.FC<SelectRevealProps> = ({
form,
client,
canCreateDelayedRevealBatch,
}) => {
function DelayedRevealConfiguration(props: {
form: ReturnType<typeof useBatchLazyMintForm>;
client: ThirdwebClient;
}) {
const { form, client } = props;
const [show, setShow] = useState(false);
const imageUrl = form.watch("placeHolder.image");
return (
<Flex flexDir="column">
<Flex
flexDir={{ base: "column", md: "row" }}
gap={{ base: 3, md: 6 }}
mb={6}
>
<SelectOption
description="Collectors will immediately see the final NFT when they complete the minting"
isActive={form.watch("revealType") === "instant"}
name="Reveal upon mint"
onClick={() => form.setValue("revealType", "instant")}
/>
<SelectOption
description="Collectors will mint your placeholder image, then you reveal at a later time"
disabled={!canCreateDelayedRevealBatch}
disabledText="This contract doesn't implement Delayed Reveal"
isActive={form.watch("revealType") === "delayed"}
name="Delayed Reveal"
onClick={() => form.setValue("revealType", "delayed")}
/>
</Flex>
<div className="flex flex-col gap-3">
{form.watch("revealType") === "delayed" && (
<>
<Heading size="title.sm">Let&apos;s set a password</Heading>
<Alert borderRadius="lg" status="warning">
<AlertIcon />
You&apos;ll need this password to reveal your NFTs. Please save it
somewhere safe.
</Alert>
<div className="space-y-6">
{/* password */}
<div className="border px-4 lg:px-6 py-8 rounded-lg bg-card">
<div className="flex mb-3">
<div className="p-2 rounded-full border bg-card">
<LockKeyholeIcon className="size-4 text-muted-foreground" />
</div>
</div>
<h3 className="font-semibold text-lg mb-0.5 tracking-tight">
Set password
</h3>
<p className="text-sm text-muted-foreground mb-4">
You'll need this password to reveal your NFTs. Please save it
somewhere safe
</p>
<Flex
flexDir={{ base: "column", md: "row" }}
gap={{ base: 4, md: 0 }}
>
<FormControl
isInvalid={
!!form.getFieldState("password", form.formState).error
}
isRequired
mr={4}
<div className="space-y-5">
{/* select password */}
<FormItem className="space-y-1">
<FormLabel>Password</FormLabel>
<div className="relative max-w-md">
<Input
{...form.register("password")}
className="pr-10"
type={show ? "text" : "password"}
/>
<Button
variant="ghost"
className="absolute right-3 top-1/2 -translate-y-1/2 p-2 h-auto text-muted-foreground"
onClick={() => setShow(!show)}
>
<FormLabel>Password</FormLabel>
<InputGroup>
<Input
{...form.register("password")}
placeholder="Choose password"
type={show ? "text" : "password"}
/>
<InputRightElement cursor="pointer">
{show ? (
<EyeIcon
className="size-3"
onClick={() => setShow(!show)}
/>
) : (
<EyeOffIcon
className="size-3"
onClick={() => setShow(!show)}
/>
)}
</InputRightElement>
</InputGroup>
<FormErrorMessage>
{
form.getFieldState("password", form.formState).error
?.message
}
</FormErrorMessage>
</FormControl>
<FormControl
isInvalid={
!!form.getFieldState("confirmPassword", form.formState).error
}
isRequired
>
<FormLabel>Confirm password</FormLabel>
<Input
{...form.register("confirmPassword")}
placeholder="Confirm password"
type="password"
/>
<FormErrorMessage>
{
form.getFieldState("confirmPassword", form.formState).error
?.message
}
</FormErrorMessage>
</FormControl>
</Flex>
<div className="flex flex-col gap-5">
<Heading size="title.sm">Placeholder</Heading>
<FormControl
isInvalid={
!!form.getFieldState("placeHolder.image", form.formState)
.error
}
>
<FormLabel>Image</FormLabel>
<div className="w-auto md:w-[350px]">
<FileInput
accept={{ "image/*": [] }}
className="rounded border border-border transition-all duration-200"
client={client}
setValue={(file) =>
form.setValue("placeHolder.image", file)
}
showUploadButton
value={imageUrl}
/>
</div>
<FormHelperText>
You can optionally upload an image as the placeholder.
</FormHelperText>
<FormErrorMessage>
{
form.getFieldState("placeHolder.image", form.formState)
.error?.message
}
</FormErrorMessage>
</FormControl>
<FormControl
isInvalid={
!!form.getFieldState("placeHolder.name", form.formState).error
}
isRequired
>
<FormLabel>Name</FormLabel>
<Input
{...form.register("placeHolder.name")}
placeholder="eg. My NFT (Coming soon)"
/>
<FormErrorMessage>
{
form.getFieldState("placeHolder.name", form.formState).error
?.message
}
</FormErrorMessage>
</FormControl>
<FormControl
isInvalid={
!!form.getFieldState("placeHolder.name", form.formState).error
}
>
<FormLabel>Description</FormLabel>
<Textarea
{...form.register("placeHolder.description")}
placeholder="eg. Reveal on July 15th!"
/>
<FormErrorMessage>
{
form.getFieldState(
"placeHolder.description",
form.formState,
).error?.message
}
</FormErrorMessage>
</FormControl>
{show ? (
<EyeIcon className="size-4" />
) : (
<EyeOffIcon className="size-4" />
)}
</Button>
</div>
</>
)}
<FormMessage>
{form.getFieldState("password", form.formState).error?.message}
</FormMessage>
</FormItem>
{/* confirm password */}
<FormItem className="space-y-1">
<FormLabel>Confirm password</FormLabel>
<div className="relative max-w-md">
<Input
{...form.register("confirmPassword")}
className="pr-10"
type="password"
/>
</div>
<FormMessage>
{
form.getFieldState("confirmPassword", form.formState).error
?.message
}
</FormMessage>
</FormItem>
</div>
</div>
</Flex>
{/* placeholder */}
<div className="border px-4 lg:px-6 py-8 rounded-lg bg-card">
<div className="flex mb-3">
<div className="p-2 rounded-full border bg-card">
<EyeIcon className="size-4 text-muted-foreground" />
</div>
</div>
<h3 className="font-semibold text-lg tracking-tight mb-0.5">
Set placeholder metadata
</h3>
<p className="text-sm text-muted-foreground mb-4">
The placeholder metadata will be displayed for all NFTs until you
reveal your NFTs
</p>
<div className="flex flex-col lg:flex-row gap-5">
<FormItem className="w-[200px]">
<FormLabel>Image</FormLabel>
<FileInput
accept={{ "image/*": [] }}
className="rounded border bg-background transition-all duration-200 "
client={client}
setValue={(file) => form.setValue("placeHolder.image", file)}
value={imageUrl}
/>
<FormMessage>
{
form.getFieldState("placeHolder.image", form.formState).error
?.message
}
</FormMessage>
</FormItem>
<div className="grow space-y-5 flex flex-col">
<FormItem>
<FormLabel>Name</FormLabel>
<Input
className="max-w-sm"
{...form.register("placeHolder.name")}
placeholder="My NFT (Coming soon)"
/>
<FormMessage>
{
form.getFieldState("placeHolder.name", form.formState).error
?.message
}
</FormMessage>
</FormItem>
<FormItem className="grow flex flex-col">
<FormLabel>Description</FormLabel>
<Textarea
{...form.register("placeHolder.description")}
className="grow"
placeholder="Reveal on July 15th!"
/>
<FormMessage>
{
form.getFieldState("placeHolder.description", form.formState)
.error?.message
}
</FormMessage>
</FormItem>
</div>
</div>
</div>
</div>
);
};
}
@@ -1,237 +1,183 @@
/** biome-ignore-all lint/nursery/noNestedComponentDefinitions: FIXME */
import { FilePreview } from "@app/team/[team_slug]/[project_slug]/(sidebar)/tokens/create/_common/file-preview";
import {
Flex,
IconButton,
Portal,
Select,
Table,
TableContainer,
Tbody,
Td,
Th,
Thead,
Tr,
} from "@chakra-ui/react";
import {
ChevronFirstIcon,
ChevronLastIcon,
ChevronLeftIcon,
ChevronRightIcon,
} from "lucide-react";
import { useMemo } from "react";
import { type Column, usePagination, useTable } from "react-table";
import { useState } from "react";
import type { ThirdwebClient } from "thirdweb";
import type { NFTInput } from "thirdweb/utils";
import { FilePreview } from "@/components/blocks/file-preview";
import { PaginationButtons } from "@/components/blocks/pagination-buttons";
import { CodeClient } from "@/components/ui/code/code.client";
import {
Table,
TableBody,
TableCell,
TableContainer,
TableHead,
TableHeader,
TableRow,
} from "@/components/ui/table";
import { ToolTipLabel } from "@/components/ui/tooltip";
interface BatchTableProps {
type BatchTableProps = {
data: NFTInput[];
portalRef: React.RefObject<HTMLDivElement | null>;
nextTokenIdToMint?: bigint;
client: ThirdwebClient;
}
};
export const BatchTable: React.FC<BatchTableProps> = ({
export function BatchTable({
data,
portalRef,
nextTokenIdToMint,
client,
}) => {
const columns = useMemo(() => {
let cols: Column<NFTInput>[] = [];
if (nextTokenIdToMint !== undefined) {
cols = cols.concat({
accessor: (_row, index) => String(nextTokenIdToMint + BigInt(index)),
Header: "Token ID",
});
}
}: BatchTableProps) {
const [currentPage, setCurrentPage] = useState(1);
const pageSize = 10;
cols = cols.concat([
{
accessor: (row) => row.image,
Cell: ({ cell: { value } }: { cell: { value?: string } }) => (
<FilePreview
className="size-24 shrink-0 rounded-lg object-contain"
client={client}
srcOrFile={value}
/>
),
Header: "Image",
},
{
accessor: (row) => row.animation_url,
Cell: ({ cell: { value } }: { cell: { value?: string } }) => (
<FilePreview
className="size-24 shrink-0 rounded-lg"
client={client}
srcOrFile={value}
/>
),
Header: "Animation Url",
},
{ accessor: (row) => row.name, Header: "Name" },
{
accessor: (row) => (
<ToolTipLabel label={row.description}>
<p className="line-clamp-6 whitespace-pre-wrap">
{row.description}
</p>
</ToolTipLabel>
),
Header: "Description",
},
{
accessor: (row) => row.attributes || row.properties,
// biome-ignore lint/suspicious/noExplicitAny: FIXME
Cell: ({ cell }: { cell: any }) =>
cell.value ? (
<CodeClient
code={JSON.stringify(cell.value || {}, null, 2)}
lang="json"
scrollableClassName="max-w-[300px]"
/>
) : null,
Header: "Attributes",
},
{ accessor: (row) => row.external_url, Header: "External URL" },
{ accessor: (row) => row.background_color, Header: "Background Color" },
]);
return cols;
}, [nextTokenIdToMint, client]);
const totalPages = Math.ceil(data.length / pageSize);
const startIndex = (currentPage - 1) * pageSize;
const endIndex = startIndex + pageSize;
const currentData = data.slice(startIndex, endIndex);
const {
getTableProps,
getTableBodyProps,
headerGroups,
prepareRow,
// Instead of using 'rows', we'll use page,
page,
// which has only the rows for the active page
const handlePageChange = (page: number) => {
setCurrentPage(page);
};
// The rest of these things are super handy, too ;)
canPreviousPage,
canNextPage,
pageOptions,
pageCount,
gotoPage,
nextPage,
previousPage,
setPageSize,
state: { pageIndex, pageSize },
} = useTable(
{
columns,
data,
initialState: {
pageIndex: 0,
pageSize: 50,
},
},
// will be fixed with @tanstack/react-table v8
// eslint-disable-next-line react-compiler/react-compiler
usePagination,
);
const showTokenId = nextTokenIdToMint !== undefined;
const showExternalUrl = data.some((row) => row.external_url);
const showBackgroundColor = data.some((row) => row.background_color);
const showAnimationUrl = data.some((row) => row.animation_url);
const showDescription = data.some((row) => row.description);
const showAttributes = data.some((row) => row.attributes || row.properties);
const showPagination = totalPages > 1;
// Render the UI for your table
return (
<Flex flexGrow={1} overflow="auto">
<TableContainer className="w-full" maxW="100%">
<Table {...getTableProps()}>
<Thead>
{headerGroups.map((headerGroup, index) => (
// biome-ignore lint/suspicious/noArrayIndexKey: FIXME
<Tr {...headerGroup.getHeaderGroupProps()} key={index}>
{headerGroup.headers.map((column, i) => (
// biome-ignore lint/suspicious/noArrayIndexKey: FIXME
<Th {...column.getHeaderProps()} border="none" key={i}>
<p className="text-muted-foreground">
{column.render("Header")}
</p>
</Th>
))}
</Tr>
))}
</Thead>
<Tbody {...getTableBodyProps()}>
{page.map((row, rowIndex) => {
prepareRow(row);
<div className="rounded-lg border bg-card">
<TableContainer className="border-0">
<Table>
<TableHeader>
<TableRow>
{showTokenId && <TableHead>Token ID</TableHead>}
<TableHead>Image</TableHead>
{showAnimationUrl && <TableHead>Animation Url</TableHead>}
<TableHead>Name</TableHead>
{showDescription && (
<TableHead className="min-w-[300px]">Description</TableHead>
)}
{showAttributes && <TableHead>Attributes</TableHead>}
{showExternalUrl && <TableHead>External URL</TableHead>}
{showBackgroundColor && <TableHead>Background Color</TableHead>}
</TableRow>
</TableHeader>
<TableBody>
{currentData.map((row, rowIndex) => {
const actualIndex = startIndex + rowIndex;
return (
<Tr
{...row.getRowProps()}
_last={{ borderBottomWidth: 0 }}
borderBottomWidth={1}
// biome-ignore lint/suspicious/noArrayIndexKey: FIXME
key={rowIndex}
<TableRow
className="border-b last:border-b-0"
key={actualIndex}
>
{row.cells.map((cell, cellIndex) => {
return (
<Td
{...cell.getCellProps()}
borderBottomWidth="inherit"
borderColor="borderColor"
// biome-ignore lint/suspicious/noArrayIndexKey: FIXME
key={cellIndex}
>
{cell.render("Cell")}
</Td>
);
})}
</Tr>
{/* Token ID */}
{showTokenId && (
<TableCell>
{String(nextTokenIdToMint + BigInt(actualIndex))}
</TableCell>
)}
{/* Image */}
<TableCell className="min-w-36">
<FilePreview
className="size-36 shrink-0 rounded-lg object-contain"
client={client}
srcOrFile={
typeof row.image === "string" ||
row.image instanceof File
? row.image
: undefined
}
/>
</TableCell>
{/* Animation Url */}
{showAnimationUrl && (
<TableCell className="min-w-36">
<FilePreview
className="size-36 shrink-0 rounded-lg"
client={client}
srcOrFile={
typeof row.animation_url === "string" ||
row.animation_url instanceof File
? row.animation_url
: undefined
}
/>
</TableCell>
)}
{/* Name */}
<TableCell>{row.name}</TableCell>
{/* Description */}
{showDescription && (
<TableCell className="max-w-xs">
<p className="whitespace-pre-wrap">{row.description}</p>
</TableCell>
)}
{/* Attributes */}
{showAttributes && (
<TableCell>
{row.attributes || row.properties ? (
<CodeClient
code={JSON.stringify(
row.attributes || row.properties || {},
null,
2,
)}
lang="json"
scrollableClassName="max-w-[300px] max-h-[400px]"
className="bg-background [&>*]:text-xs"
/>
) : null}
</TableCell>
)}
{/* External URL */}
{showExternalUrl && (
<TableCell>
{typeof row.external_url === "string" ? (
<ToolTipLabel label={row.external_url}>
<span>
{row.external_url.slice(0, 20) +
(row.external_url.length > 20 ? "..." : "")}
</span>
</ToolTipLabel>
) : row.external_url instanceof File ? (
<FilePreview
client={client}
srcOrFile={row.external_url}
/>
) : null}
</TableCell>
)}
{/* Background Color */}
{showBackgroundColor && (
<TableCell>{row.background_color}</TableCell>
)}
</TableRow>
);
})}
</Tbody>
</TableBody>
</Table>
</TableContainer>
<Portal containerRef={portalRef}>
<div className="flex w-full items-center justify-center">
<div className="flex flex-row items-center gap-2">
<IconButton
aria-label="first page"
icon={<ChevronFirstIcon className="size-4" />}
isDisabled={!canPreviousPage}
onClick={() => gotoPage(0)}
/>
<IconButton
aria-label="previous page"
icon={<ChevronLeftIcon className="size-4" />}
isDisabled={!canPreviousPage}
onClick={() => previousPage()}
/>
<p className="whitespace-nowrap">
Page <strong>{pageIndex + 1}</strong> of{" "}
<strong>{pageOptions.length}</strong>
</p>
<IconButton
aria-label="next page"
icon={<ChevronRightIcon className="size-4" />}
isDisabled={!canNextPage}
onClick={() => nextPage()}
/>
<IconButton
aria-label="last page"
icon={<ChevronLastIcon className="size-4" />}
isDisabled={!canNextPage}
onClick={() => gotoPage(pageCount - 1)}
/>
<Select
onChange={(e) => {
setPageSize(Number.parseInt(e.target.value as string, 10));
}}
value={pageSize}
>
<option value="25">25</option>
<option value="50">50</option>
<option value="100">100</option>
<option value="250">250</option>
<option value="500">500</option>
</Select>
</div>
{showPagination && (
<div className="border-t py-5">
<PaginationButtons
activePage={currentPage}
totalPages={totalPages}
onPageClick={handlePageChange}
/>
</div>
</Portal>
</Flex>
)}
</div>
);
};
}
@@ -42,18 +42,18 @@ export const SelectOption: React.FC<SelectOptionProps> = ({
disabled
? "pointer-events-none cursor-not-allowed bg-muted"
: "cursor-pointer",
isActive && "border-primary",
isActive && "bg-muted/50 border-active-border",
className,
)}
onClick={onClick}
{...divProps}
>
<div className="flex flex-row justify-between">
<div className="flex flex-row items-start">
<div className="mt-0.5 mr-2.5 flex h-4 w-4 items-center justify-center rounded-full border border-inverted text-inverted">
<div className="flex flex-row items-start gap-4">
<div className="flex size-5 shrink-0 items-center justify-center rounded-full border border-inverted text-inverted">
{isActive && <div className="h-2 w-2 rounded-full bg-inverted" />}
</div>
<div className="ml-4 flex flex-col gap-2 self-start">
<div>
<h4
className={cn(
"font-semibold text-sm",
@@ -62,7 +62,11 @@ export const SelectOption: React.FC<SelectOptionProps> = ({
>
{name}
</h4>
{description && <p className="mt-1 text-sm">{description}</p>}
{description && (
<p className="mt-1 text-sm text-muted-foreground">
{description}
</p>
)}
</div>
</div>
{infoText && (
@@ -1,137 +1,333 @@
import { UploadIcon } from "lucide-react";
import { ArrowDownToLineIcon } from "lucide-react";
import { useState } from "react";
import { Button } from "@/components/ui/button";
import { CodeClient } from "@/components/ui/code/code.client";
import { InlineCode } from "@/components/ui/inline-code";
import { UnorderedList } from "@/components/ui/List/List";
import { cn } from "@/lib/utils";
import { TabButtons } from "@/components/ui/tabs";
import { handleDownload } from "../../../app/(app)/team/[team_slug]/[project_slug]/(sidebar)/tokens/create/_common/download-file-button";
import { DropZone } from "../blocks/drop-zone/drop-zone";
interface UploadStepProps {
// biome-ignore lint/suspicious/noExplicitAny: FIXME
getRootProps: any;
// biome-ignore lint/suspicious/noExplicitAny: FIXME
getInputProps: any;
hasFailed: boolean;
isDragActive: boolean;
onDrop: (acceptedFiles: File[]) => void;
reset: () => void;
}
export const UploadStep: React.FC<UploadStepProps> = ({
getRootProps,
hasFailed,
isDragActive,
getInputProps,
}) => {
export function UploadStep(props: UploadStepProps) {
const [tab, setTab] = useState<"csv" | "json">("csv");
return (
<div className="flex flex-col items-center gap-8 md:flex-row">
<div className="relative aspect-square w-full md:w-1/2">
<div
className={cn(
"flex h-full cursor-pointer rounded-md border border-border hover:border-blue-500",
hasFailed ? "bg-red-200" : "bg-background",
)}
{...getRootProps()}
>
<input {...getInputProps()} />
<div className="m-auto flex flex-col p-6">
<UploadIcon
className={cn(
"mx-auto mb-2 size-8",
hasFailed ? "text-red-500" : "text-gray-600",
)}
<div className="container px-0 max-w-3xl">
<h2 className="text-2xl font-semibold tracking-tight mb-4">
Upload NFTs
</h2>
<DropZone
className="w-full py-24"
onDrop={props.onDrop}
isError={props.hasFailed}
title={props.hasFailed ? "Invalid files" : "Upload files"}
description={
props.hasFailed
? "Make sure the uploaded files follow the requirements mentioned below"
: "Drag and drop the files or folder"
}
resetButton={{
label: "Reset",
onClick: props.reset,
}}
accept={undefined}
/>
<div className="h-8" />
<div className="w-full">
<TabButtons
tabs={[
{
isActive: tab === "csv",
name: "CSV",
onClick: () => setTab("csv"),
},
{
isActive: tab === "json",
name: "JSON",
onClick: () => setTab("json"),
},
]}
/>
<div className="h-6" />
<div className="space-y-8">
<Section title="Uploading Files">
<p>
Make sure to drag and drop the {tab === "csv" ? "CSV" : "JSON"}{" "}
and the assets at the same time or upload a folder with all the
files in it.
</p>
<p>
Asset names <em>must</em> be sequential 0,1,2,3...n.[extension].
It doesn't matter at what number you begin. Example: 131.png,
132.png etc.
</p>
<p>
Images and other file types can be used in combination. They both
have to follow the asset naming convention above. Example: 0.png
and 0.mp4, 1.png and 1.glb etc.
</p>
</Section>
<Section title={`${tab === "csv" ? "CSV" : "JSON"} File Format`}>
<p>
The {tab === "csv" ? "CSV" : "JSON"} file must have a{" "}
<InlineCode code="name" /> {tab === "csv" ? "column" : "property"}
, which defines the name of the NFT
</p>
<p>
Other optional {tab === "csv" ? "columns" : "properties"} are{" "}
<InlineCode code="description" />,{" "}
<InlineCode code="background_color" />,{" "}
<InlineCode code="external_url" />,{" "}
<InlineCode code="animation_url" />,{" "}
{tab === "json" && (
<>
,
<InlineCode code="attributes" />
</>
)}{" "}
and <InlineCode code="supply" />
{". "}
{tab === "csv" &&
"All other columns will be treated as Attributes. For example: See 'eyes', 'nose' below."}
</p>
<ExampleCode
code={tab === "csv" ? csv_example_basic : json_example_basic}
fileNameWithExtension={
tab === "csv" ? "example.csv" : "example.json"
}
lang={tab === "csv" ? "csv" : "json"}
/>
{isDragActive ? (
<p className="text-center text-muted-foreground">
Drop the files here
</p>
) : (
<p
className={cn(
"text-center leading-[1.2]",
hasFailed ? "text-red-500" : "text-muted-foreground",
)}
>
{hasFailed
? `No valid CSV or JSON file found. Please make sure your NFT metadata includes at least a "name" field and try again.`
: "Drag & Drop files or folders here, or click to select files"}
</p>
)}
</div>
</Section>
<Section title="Map your assets to NFTs">
<p>
If you want to map your media files to your NFTs, you can add the
name of your files to the <InlineCode code="image" /> and{" "}
<InlineCode code="animation_url" />{" "}
{tab === "csv" ? "columns" : "properties"}.{" "}
<ExampleCode
code={
tab === "csv"
? csv_with_image_number_example
: json_with_image_number_example
}
fileNameWithExtension={
tab === "csv"
? "example-with-maps.csv"
: "example-with-maps.json"
}
lang={tab === "csv" ? "csv" : "json"}
/>
</p>
</Section>
<Section title="Using asset links instead of uploading assets">
<p>
When uploading files, assets will be uploaded and pinned to IPFS
automatically. If you already have the files uploaded elsewhere,
you can specify the IPFS or HTTP(s) links in the{" "}
<InlineCode code="image" /> and/or{" "}
<InlineCode code="animation_url" />{" "}
{tab === "csv" ? "columns" : "properties"}. instead of uploading
the assets and just upload a single{" "}
{tab === "csv" ? "CSV" : "JSON"} file.
<ExampleCode
code={
tab === "csv"
? csv_with_image_link_example
: json_with_image_link_example
}
fileNameWithExtension={
tab === "csv"
? "example-with-ipfs.csv"
: "example-with-ipfs.json"
}
lang={tab === "csv" ? "csv" : "json"}
/>
</p>
</Section>
</div>
</div>
<div className="flex w-full flex-col gap-2 md:w-1/2">
<p className="text-lg">Requirements</p>
<UnorderedList>
<li>
Files <em>must</em> contain one .csv or .json file with metadata. -{" "}
<a
className="text-link-foreground hover:text-foreground"
download
href="/assets/examples/example.csv"
>
Download example.csv
</a>
.{" "}
<a
className="text-link-foreground hover:text-foreground"
download
href="/assets/examples/example.json"
>
Download example.json
</a>
.
</li>
<li>
The csv <em>must</em> have a <InlineCode code="name" /> column,
which defines the name of the NFT.
</li>
<li>
Asset names <em>must</em> be sequential 0,1,2,3...n.[extension]. It
doesn&apos;t matter at what number you begin. (Example:{" "}
<InlineCode code="131.png" />, <InlineCode code="132.png" />
).
</li>
<li>
Make sure to drag and drop the CSV/JSON and the images{" "}
<strong>at the same time</strong>.
</li>
</UnorderedList>
<p className="mt-4 text-lg">Options</p>
<UnorderedList>
<li>
Images and other file types can be used in combination.
<br />
<small>
They both have to follow the asset naming convention above.
(Example: <InlineCode code="0.png" /> and{" "}
<InlineCode code="0.mp4" />,<InlineCode code="1.png" /> and{" "}
<InlineCode code="1.glb" />, etc.)
</small>
</li>
<li>
When uploading files, we will upload them and pin them to IPFS
automatically for you. If you already have the files uploaded, you
can add an <InlineCode code="image" /> and/or
<InlineCode code="animation_url" /> column and add the IPFS hashes
there.{" "}
<a
className="text-link-foreground hover:text-foreground"
download
href="/assets/examples/example-with-ipfs.csv"
>
Download example.csv
</a>
</li>
<li>
If you want to make your media files map to your NFTs, you can add
the name of your files to the <InlineCode code="image" /> and
<InlineCode code="animation_url" /> column.{" "}
<a
className="text-link-foreground hover:text-foreground"
download
href="/assets/examples/example-with-maps.csv"
>
Download example.csv
</a>
</li>
</UnorderedList>
</div>
</div>
);
};
}
function Section(props: { title: string; children: React.ReactNode }) {
return (
<section>
<h2 className="mb-1 font-medium text-base text-foreground">
{props.title}
</h2>
<div className="space-y-1.5 text-muted-foreground leading-relaxed">
{props.children}
</div>
</section>
);
}
function ExampleCode(props: {
code: string;
lang: "csv" | "json";
fileNameWithExtension: string;
}) {
return (
<div className="!my-3 relative">
<CodeClient
code={props.code}
lang={props.lang}
scrollableClassName="max-h-[300px] bg-card"
/>
<Button
className="absolute top-3.5 right-14 mt-[1px] h-auto bg-background p-2"
onClick={() => {
handleDownload({
fileContent: props.code,
fileFormat: props.lang === "csv" ? "text/csv" : "application/json",
fileNameWithExtension: props.fileNameWithExtension,
});
}}
size="sm"
variant="outline"
>
<ArrowDownToLineIcon className="size-3" />
</Button>
</div>
);
}
const csv_example_basic = `\
name,description,background_color,eyes,nose
Token 0 Name,Token 0 Description,#0098EE,red,green
Token 1 Name,Token 1 Description,#0098EE,blue,yellow`;
const json_example_basic = `\
[
{
"name": "Token 0 Name",
"description": "Token 0 Description",
"background_color": "#0098EE",
"attributes": [
{
"trait_type": "eyes",
"value": "red"
},
{
"trait_type": "nose",
"value": "green"
}
]
},
{
"name": "Token 1 Name",
"description": "Token 1 Description",
"background_color": "#0098EE",
"attributes": [
{
"trait_type": "eyes",
"value": "blue"
},
{
"trait_type": "nose",
"value": "yellow"
}
]
}
]`;
const csv_with_image_link_example = `\
name,description,image,animation_url,background_color,eyes,nose
Token 0 Name,Token 0 Description,ipfs://ipfsHash/0,ipfs://ipfsHash/0,#0098EE,red,green
Token 1 Name,Token 1 Description,ipfs://ipfsHash/1,ipfs://ipfsHash/1,#0098EE,blue,yellow`;
const json_with_image_link_example = `\
[
{
"name": "Token 0 Name",
"description": "Token 0 Description",
"image": "ipfs://ipfsHash/0",
"animation_url": "ipfs://ipfsHash/0",
"attributes": [
{
"trait_type": "eyes",
"value": "red"
},
{
"trait_type": "nose",
"value": "green"
}
]
},
{
"name": "Token 1 Name",
"description": "Token 1 Description",
"image": "ipfs://ipfsHash/1",
"animation_url": "ipfs://ipfsHash/1",
"attributes": [
{
"trait_type": "eyes",
"value": "blue"
},
{
"trait_type": "nose",
"value": "yellow"
}
]
}
]`;
const csv_with_image_number_example = `\
name,description,image,animation_url,background_color,eyes,nose
Token 0 Name,Token 0 Description,0.png,0.mp4,#0098EE,red,green
Token 1 Name,Token 1 Description,1.png,1.mp4,#0098EE,blue,yellow`;
const json_with_image_number_example = `\
[
{
"name": "Token 0 Name",
"description": "Token 0 Description",
"image": "0.png",
"animation_url": "0.mp4",
"attributes": [
{
"trait_type": "eyes",
"value": "red"
},
{
"trait_type": "nose",
"value": "green"
}
]
},
{
"name": "Token 1 Name",
"description": "Token 1 Description",
"image": "1.png",
"animation_url": "1.mp4",
"attributes": [
{
"trait_type": "eyes",
"value": "blue"
},
{
"trait_type": "nose",
"value": "yellow"
}
]
}
]`;
@@ -1,4 +1,3 @@
import { FilePreview } from "@app/team/[team_slug]/[project_slug]/(sidebar)/tokens/create/_common/file-preview";
import { FilePlusIcon, UploadIcon } from "lucide-react";
import { useCallback, useEffect, useRef } from "react";
import {
@@ -8,6 +7,7 @@ import {
useDropzone,
} from "react-dropzone";
import type { ThirdwebClient } from "thirdweb";
import { FilePreview } from "@/components/blocks/file-preview";
import { Button } from "@/components/ui/button";
import { cn } from "@/lib/utils";
@@ -37,7 +37,12 @@ export function FilePreview(props: {
if (!objectUrl) {
return (
<div className={cn("flex items-center justify-center", props.className)}>
<div
className={cn(
"flex items-center justify-center bg-accent",
props.className,
)}
>
<ImageOffIcon className="size-6 text-muted-foreground" />
</div>
);
@@ -56,7 +61,10 @@ export function FilePreview(props: {
return (
<MediaRenderer
className={cn(props.className, "[&>div]:!bg-muted")}
className={cn(
props.className,
"[&>div]:!bg-accent [&_a]:!text-muted-foreground [&_a]:!no-underline [&_svg]:!size-6 [&_svg]:!text-muted-foreground relative overflow-hidden",
)}
client={props.client}
src={objectUrl}
/>
@@ -1,15 +1,4 @@
import {
Flex,
FormControl,
IconButton,
Input,
InputGroup,
InputRightElement,
Tooltip,
} from "@chakra-ui/react";
import { Button } from "chakra/button";
import { FormErrorMessage, FormLabel } from "chakra/form";
import { BanIcon, PlusIcon, TrashIcon, UploadIcon, XIcon } from "lucide-react";
import { PlusIcon, TrashIcon, XIcon } from "lucide-react";
import { useEffect } from "react";
import {
type ArrayPath,
@@ -25,7 +14,16 @@ import {
type WatchObserver,
} from "react-hook-form";
import type { ThirdwebClient } from "thirdweb";
import { FileInput } from "@/components/blocks/FileInput";
import { Button } from "@/components/ui/button";
import {
FormControl,
FormField,
FormItem,
FormLabel,
FormMessage,
} from "@/components/ui/form";
import { Input } from "@/components/ui/input";
import { cn } from "@/lib/utils";
type OptionalPropertiesInput = {
[key: string]: string | number;
@@ -46,17 +44,15 @@ interface IPropertiesFormControlProps<
client: ThirdwebClient;
}
export const PropertiesFormControl = <
export function PropertiesFormControl<
TFieldValues extends IPropertyFieldValues,
>({
control,
register,
watch,
errors,
setValue,
client,
}: React.PropsWithChildren<IPropertiesFormControlProps<TFieldValues>>) => {
const { fields, append, remove, replace } = useFieldArray({
}: React.PropsWithChildren<IPropertiesFormControlProps<TFieldValues>>) {
const { fields, append, remove } = useFieldArray({
control,
name: "attributes" as ArrayPath<TFieldValues>,
});
@@ -72,19 +68,7 @@ export const PropertiesFormControl = <
return (
<div className="flex flex-col gap-4">
<Flex align="center" direction="row" justify="space-between">
<FormLabel m={0}>Attributes</FormLabel>
<Button
colorScheme="red"
// biome-ignore lint/suspicious/noExplicitAny: FIXME
onClick={() => replace([{ trait_type: "", value: "" } as any])}
rightIcon={<BanIcon className="size-4" />}
size="xs"
variant="outline"
>
Reset
</Button>
</Flex>
<FormLabel>Attributes</FormLabel>
{fields.map((field, index) => {
// biome-ignore lint/suspicious/noExplicitAny: FIXME
const keyError = (errors as any)?.attributes?.[index]?.trait_type
@@ -92,102 +76,108 @@ export const PropertiesFormControl = <
// biome-ignore lint/suspicious/noExplicitAny: FIXME
const valueError = (errors as any)?.attributes?.[index]?.value
?.message as string | undefined;
const isInvalid = !!(keyError || valueError);
const _isInvalid = !!(keyError || valueError);
return (
<div className="flex flex-row items-center gap-2" key={field.id}>
<FormControl
className="flex flex-row items-start gap-3"
isInvalid={isInvalid}
>
<FormControl isInvalid={!!keyError}>
<Input
{...register(
`attributes.${index}.trait_type` as Path<TFieldValues>,
)}
placeholder="trait_type"
/>
<FormErrorMessage>{keyError}</FormErrorMessage>
</FormControl>
<FormControl isInvalid={!!valueError}>
{watch(
`attributes.${index}.value` as unknown as WatchObserver<TFieldValues>,
) instanceof File ? (
<InputGroup>
<Input
isDisabled
value={
watch(`attributes.${index}.value` as Path<TFieldValues>)
.name
}
/>
<InputRightElement>
<TrashIcon
className="size-4 cursor-pointer text-red-300 hover:text-red-200"
onClick={() =>
setValue(
`attributes.${index}.value` as Path<TFieldValues>,
"" as PathValue<TFieldValues, Path<TFieldValues>>,
)
}
<div className="flex flex-row items-start gap-3 flex-1">
<FormField
control={control}
name={`attributes.${index}.trait_type` as Path<TFieldValues>}
render={({ field: traitField }) => (
<FormItem className="flex-1">
<FormControl>
<Input
{...traitField}
placeholder="trait_type"
className={cn(
"bg-card",
keyError && "border-destructive",
)}
/>
</InputRightElement>
</InputGroup>
) : (
<InputGroup>
<Input
{...register(
`attributes.${index}.value` as Path<TFieldValues>,
)}
placeholder="value"
/>
<InputRightElement>
<Tooltip label="Upload file" shouldWrapChildren>
<FileInput
client={client}
setValue={(file) => {
setValue(
`attributes.${index}.value` as Path<TFieldValues>,
file as PathValue<
TFieldValues,
Path<TFieldValues>
>,
);
}}
>
<UploadIcon className="size-4 text-muted-foreground" />
</FileInput>
</Tooltip>
</InputRightElement>
</InputGroup>
</FormControl>
{keyError && <FormMessage>{keyError}</FormMessage>}
</FormItem>
)}
<FormErrorMessage>{valueError}</FormErrorMessage>
</FormControl>
</FormControl>
<IconButton
aria-label="remove key value pair"
colorScheme="red"
icon={<XIcon />}
/>
<FormField
control={control}
name={`attributes.${index}.value` as Path<TFieldValues>}
render={({ field: valueField }) => (
<FormItem className="flex-1">
<FormControl>
{watch(
`attributes.${index}.value` as unknown as WatchObserver<TFieldValues>,
) instanceof File ? (
<div className="relative">
<Input
disabled
value={
watch(
`attributes.${index}.value` as Path<TFieldValues>,
).name
}
className="pr-10 bg-card"
/>
<Button
type="button"
variant="ghost"
size="sm"
className="absolute right-0 top-0 h-full px-3 hover:bg-transparent"
onClick={() =>
setValue(
`attributes.${index}.value` as Path<TFieldValues>,
"" as PathValue<
TFieldValues,
Path<TFieldValues>
>,
)
}
>
<TrashIcon className="size-4 text-muted-foreground hover:text-destructive" />
</Button>
</div>
) : (
<div className="relative">
<Input
{...valueField}
placeholder="value"
className={`pr-10 bg-card ${valueError ? "border-destructive" : ""}`}
/>
</div>
)}
</FormControl>
{valueError && <FormMessage>{valueError}</FormMessage>}
</FormItem>
)}
/>
</div>
<Button
type="button"
variant="outline"
size="sm"
className="rounded-full p-0 size-10 bg-card"
onClick={() => remove(index)}
size="xs"
variant="ghost"
/>
>
<XIcon className="size-4" />
</Button>
</div>
);
})}
<div className="flex flex-row gap-2">
<Button
colorScheme="purple"
leftIcon={<PlusIcon className="size-5" />}
className="rounded-full"
onClick={() =>
// biome-ignore lint/suspicious/noExplicitAny: FIXME
append({ trait_type: undefined, value: undefined } as any)
}
size="sm"
>
<PlusIcon className="size-4 mr-2" />
Add Row
</Button>
</div>
</div>
);
};
}
@@ -1,18 +1,5 @@
"use client";
import {
Accordion,
AccordionButton,
AccordionIcon,
AccordionItem,
AccordionPanel,
FormControl,
Input,
Textarea,
} from "@chakra-ui/react";
import { Button } from "chakra/button";
import { FormErrorMessage, FormHelperText, FormLabel } from "chakra/form";
import { Heading } from "chakra/heading";
import { type Dispatch, type SetStateAction, useMemo } from "react";
import { useForm } from "react-hook-form";
import { toast } from "sonner";
@@ -31,6 +18,24 @@ import { OpenSeaPropertyBadge } from "@/components/badges/opensea";
import { FileInput } from "@/components/blocks/FileInput";
import { PropertiesFormControl } from "@/components/contracts/properties.shared";
import { TransactionButton } from "@/components/tx-button";
import {
Accordion,
AccordionContent,
AccordionItem,
AccordionTrigger,
} from "@/components/ui/accordion";
import { Button } from "@/components/ui/button";
import {
Form,
FormControl,
FormDescription,
FormField,
FormItem,
FormLabel,
FormMessage,
} from "@/components/ui/form";
import { Input } from "@/components/ui/input";
import { Textarea } from "@/components/ui/textarea";
import { useTxNotifications } from "@/hooks/useTxNotifications";
import type { NFTMetadataInputLimited } from "@/types/modified-types";
import { parseAttributes } from "@/utils/parseAttributes";
@@ -53,13 +58,13 @@ type UpdateNftMetadataForm = {
isLoggedIn: boolean;
};
export const UpdateNftMetadata: React.FC<UpdateNftMetadataForm> = ({
export function UpdateNftMetadata({
contract,
nft,
useUpdateMetadata,
setOpen,
isLoggedIn,
}) => {
}: UpdateNftMetadataForm) {
const address = useActiveAccount()?.address;
const transformedQueryData = useMemo(() => {
@@ -90,7 +95,7 @@ export const UpdateNftMetadata: React.FC<UpdateNftMetadataForm> = ({
register,
watch,
handleSubmit,
formState: { errors, isDirty },
formState: { errors },
} = form;
const setFile = (file: File) => {
@@ -112,229 +117,304 @@ export const UpdateNftMetadata: React.FC<UpdateNftMetadataForm> = ({
);
return (
<form
className="flex flex-col gap-6"
id={UPDATE_METADATA_FORM_ID}
onSubmit={handleSubmit(async (data) => {
if (!address) {
toast.error("Please connect your wallet to update metadata.");
return;
}
<Form {...form}>
<form
className="flex flex-col gap-6"
id={UPDATE_METADATA_FORM_ID}
onSubmit={handleSubmit(async (data) => {
if (!address) {
toast.error("Please connect your wallet to update metadata.");
return;
}
try {
const newMetadata = parseAttributes({
...data,
animation_url: data.animation_url || nft.metadata.animation_url,
image: data.image || nft.metadata.image,
});
try {
const newMetadata = parseAttributes({
...data,
animation_url: data.animation_url || nft.metadata.animation_url,
image: data.image || nft.metadata.image,
});
const transaction = useUpdateMetadata
? // For Drop contracts, we need to call the `updateBatchBaseURI` method
nft.type === "ERC721"
? updateMetadata721({
contract,
newMetadata,
targetTokenId: BigInt(nft.id),
})
: updateMetadata1155({
contract,
newMetadata,
targetTokenId: BigInt(nft.id),
})
: // For Collection contracts, we need to call the `setTokenURI` method
nft.type === "ERC721"
? updateTokenURI721({
contract,
newMetadata,
tokenId: BigInt(nft.id),
})
: updateTokenURI1155({
contract,
newMetadata,
tokenId: BigInt(nft.id),
});
await sendAndConfirmTx.mutateAsync(transaction, {
onError: (error) => {
console.error(error);
},
onSuccess: () => {
setOpen(false);
},
});
const transaction = useUpdateMetadata
? // For Drop contracts, we need to call the `updateBatchBaseURI` method
nft.type === "ERC721"
? updateMetadata721({
contract,
newMetadata,
targetTokenId: BigInt(nft.id),
})
: updateMetadata1155({
contract,
newMetadata,
targetTokenId: BigInt(nft.id),
})
: // For Collection contracts, we need to call the `setTokenURI` method
nft.type === "ERC721"
? updateTokenURI721({
contract,
newMetadata,
tokenId: BigInt(nft.id),
})
: updateTokenURI1155({
contract,
newMetadata,
tokenId: BigInt(nft.id),
});
await sendAndConfirmTx.mutateAsync(transaction, {
onError: (error) => {
console.error(error);
},
onSuccess: () => {
setOpen(false);
},
});
updateMetadataNotifications.onSuccess();
} catch (err) {
console.error(err);
updateMetadataNotifications.onError(err);
}
})}
>
<FormControl isInvalid={!!errors.name} isRequired>
<FormLabel>Name</FormLabel>
<Input autoFocus {...register("name")} />
<FormErrorMessage>{errors?.name?.message}</FormErrorMessage>
</FormControl>
<FormControl isInvalid={!!mediaFileError}>
<FormLabel>Media</FormLabel>
<div className="flex flex-row flex-wrap gap-3">
<FileInput
className="shrink-0 rounded border border-border transition-all duration-200"
client={contract.client}
helperText={nft?.metadata ? "New Media" : "Media"}
previewMaxWidth="200px"
selectOrUpload="Upload"
setValue={setFile}
showPreview
showUploadButton
value={media}
/>
</div>
<FormHelperText>
You can upload image, audio, video, html, text, pdf, and 3d model
files here.
</FormHelperText>
<FormErrorMessage>
{mediaFileError?.message as unknown as string}
</FormErrorMessage>
</FormControl>
{showCoverImageUpload && (
<FormControl isInvalid={!!errors.image}>
<FormLabel>Cover Image</FormLabel>
<FileInput
accept={{ "image/*": [] }}
className="rounded border border-border transition-all"
client={contract.client}
previewMaxWidth="200px"
setValue={(file) => setValue("image", file)}
showUploadButton
value={image}
/>
<FormHelperText>
You can optionally upload an image as the cover of your NFT.
</FormHelperText>
<FormErrorMessage>
{errors?.image?.message as unknown as string}
</FormErrorMessage>
</FormControl>
)}
<FormControl isInvalid={!!errors.description}>
<FormLabel>Description</FormLabel>
<Textarea {...register("description")} />
<FormErrorMessage>{errors?.description?.message}</FormErrorMessage>
</FormControl>
<PropertiesFormControl
client={contract.client}
control={control}
// biome-ignore lint/suspicious/noExplicitAny: FIXME
errors={errors as any}
register={register}
setValue={setValue}
watch={watch}
/>
<Accordion
allowToggle={!(errors.background_color || errors.external_url)}
index={errors.background_color || errors.external_url ? [0] : undefined}
updateMetadataNotifications.onSuccess();
} catch (err) {
console.error(err);
updateMetadataNotifications.onError(err);
}
})}
>
<AccordionItem>
<AccordionButton justifyContent="space-between" px={0}>
<Heading size="subtitle.md">Advanced Options</Heading>
<AccordionIcon />
</AccordionButton>
<AccordionPanel className="!px-0 flex flex-col gap-6">
<FormControl isInvalid={!!errors.background_color}>
<FormLabel>
Background Color <OpenSeaPropertyBadge />
</FormLabel>
<Input max="6" {...register("background_color")} />
<FormHelperText>
Must be a six-character hexadecimal with a pre-pended #.
</FormHelperText>
<FormErrorMessage>
{errors?.background_color?.message}
</FormErrorMessage>
</FormControl>
{!(external_url instanceof File) && (
<FormControl isInvalid={!!errors.external_url}>
<FormLabel>
External URL <OpenSeaPropertyBadge />
</FormLabel>
<Input {...register("external_url")} />
<FormHelperText>
This is the URL that will appear below the asset&apos;s image
on OpenSea and will allow users to leave OpenSea and view the
item on your site.
</FormHelperText>
<FormErrorMessage>
{errors?.external_url?.message as unknown as string}
</FormErrorMessage>
<FormField
control={control}
name="name"
render={({ field }) => (
<FormItem>
<FormLabel>Name</FormLabel>
<FormControl>
<Input autoFocus {...field} className="bg-card" />
</FormControl>
)}
<FormMessage />
</FormItem>
)}
/>
{!(image instanceof File) && (
<FormControl isInvalid={!!errors.image}>
<FormLabel>Image URL</FormLabel>
<Input
onChange={(e) => {
setValue("image", e.target.value);
}}
value={typeof image === "string" ? image : ""}
/>
<FormHelperText>
If you already have your NFT image pre-uploaded to a URL, you
can specify it here instead of uploading the media file
</FormHelperText>
<FormErrorMessage>{errors?.image?.message}</FormErrorMessage>
</FormControl>
)}
<FormItem>
<FormLabel>Media</FormLabel>
<div className="flex flex-row flex-wrap gap-3">
<FileInput
className="shrink-0 rounded border border-border transition-all duration-200"
client={contract.client}
helperText={nft?.metadata ? "New Media" : "Media"}
previewMaxWidth="200px"
selectOrUpload="Upload"
setValue={setFile}
showPreview
showUploadButton
value={media}
/>
</div>
<FormDescription>
You can upload image, audio, video, html, text, pdf, and 3d model
files here.
</FormDescription>
{mediaFileError && (
<FormMessage>
{mediaFileError.message as unknown as string}
</FormMessage>
)}
</FormItem>
{!(animation_url instanceof File) && (
<FormControl isInvalid={!!errors.animation_url}>
<FormLabel>Animation URL</FormLabel>
<Input
onChange={(e) => {
setValue("animation_url", e.target.value);
}}
value={typeof animation_url === "string" ? animation_url : ""}
/>
<FormHelperText>
If you already have your NFT Animation URL pre-uploaded to a
URL, you can specify it here instead of uploading the media
file
</FormHelperText>
<FormErrorMessage>
{errors?.animation_url?.message}
</FormErrorMessage>
</FormControl>
{showCoverImageUpload && (
<FormField
control={control}
name="image"
render={() => (
<FormItem>
<FormLabel>Cover Image</FormLabel>
<FormControl>
<FileInput
accept={{ "image/*": [] }}
className="rounded border border-border transition-all"
client={contract.client}
previewMaxWidth="200px"
setValue={(file) => {
setValue("image", file);
}}
showUploadButton
value={image}
/>
</FormControl>
<FormDescription>
You can optionally upload an image as the cover of your NFT.
</FormDescription>
<FormMessage />
</FormItem>
)}
</AccordionPanel>
</AccordionItem>
</Accordion>
<div className="mt-8 flex flex-row justify-end gap-3">
<Button
isDisabled={sendAndConfirmTx.isPending}
onClick={() => setOpen(false)}
variant="outline"
>
Cancel
</Button>
<TransactionButton
/>
)}
<FormField
control={control}
name="description"
render={({ field }) => (
<FormItem>
<FormLabel>Description</FormLabel>
<FormControl>
<Textarea {...field} className="bg-card" />
</FormControl>
<FormMessage />
</FormItem>
)}
/>
<PropertiesFormControl
client={contract.client}
disabled={!isDirty}
form={UPDATE_METADATA_FORM_ID}
isLoggedIn={isLoggedIn}
isPending={sendAndConfirmTx.isPending}
transactionCount={1}
txChainID={contract.chain.id}
type="submit"
control={control}
// biome-ignore lint/suspicious/noExplicitAny: FIXME
errors={errors as any}
register={register}
setValue={setValue}
watch={watch}
/>
<Accordion
type="single"
className="-mx-1 border-t border-border"
collapsible
defaultValue={
errors.background_color || errors.external_url
? "advanced"
: undefined
}
>
Update NFT
</TransactionButton>
</div>
</form>
<AccordionItem value="advanced">
<AccordionTrigger className="justify-between px-1">
<h3 className="text-base font-medium">Advanced Options</h3>
</AccordionTrigger>
<AccordionContent className="flex flex-col gap-6 px-1">
<FormField
control={control}
name="background_color"
render={({ field }) => (
<FormItem>
<FormLabel>
Background Color <OpenSeaPropertyBadge />
</FormLabel>
<FormControl>
<Input max="6" {...field} className="bg-card" />
</FormControl>
<FormDescription>
Must be a six-character hexadecimal with a pre-pended #.
</FormDescription>
<FormMessage />
</FormItem>
)}
/>
{!(external_url instanceof File) && (
<FormField
control={control}
name="external_url"
render={({ field }) => (
<FormItem>
<FormLabel>
External URL <OpenSeaPropertyBadge />
</FormLabel>
<FormControl>
<Input
{...field}
className="bg-card"
value={
typeof field.value === "string" ? field.value : ""
}
/>
</FormControl>
<FormDescription>
This is the URL that will appear below the asset&apos;s
image on OpenSea and will allow users to leave OpenSea
and view the item on your site.
</FormDescription>
<FormMessage />
</FormItem>
)}
/>
)}
{!(image instanceof File) && (
<FormField
control={control}
name="image"
render={({ field }) => (
<FormItem>
<FormLabel>Image URL</FormLabel>
<FormControl>
<Input
{...field}
onChange={(e) => {
setValue("image", e.target.value);
}}
value={typeof image === "string" ? image : ""}
className="bg-card"
/>
</FormControl>
<FormDescription>
If you already have your NFT image pre-uploaded to a
URL, you can specify it here instead of uploading the
media file
</FormDescription>
<FormMessage />
</FormItem>
)}
/>
)}
{!(animation_url instanceof File) && (
<FormField
control={control}
name="animation_url"
render={({ field }) => (
<FormItem>
<FormLabel>Animation URL</FormLabel>
<FormControl>
<Input
{...field}
onChange={(e) => {
setValue("animation_url", e.target.value);
}}
value={
typeof animation_url === "string"
? animation_url
: ""
}
className="bg-card"
/>
</FormControl>
<FormDescription>
If you already have your NFT Animation URL pre-uploaded
to a URL, you can specify it here instead of uploading
the media file
</FormDescription>
<FormMessage />
</FormItem>
)}
/>
)}
</AccordionContent>
</AccordionItem>
</Accordion>
<div className="mt-8 flex flex-row justify-end gap-3">
<Button
disabled={sendAndConfirmTx.isPending}
onClick={() => setOpen(false)}
variant="outline"
>
Cancel
</Button>
<TransactionButton
client={contract.client}
form={UPDATE_METADATA_FORM_ID}
isLoggedIn={isLoggedIn}
isPending={sendAndConfirmTx.isPending}
transactionCount={1}
txChainID={contract.chain.id}
type="submit"
>
Update NFT
</TransactionButton>
</div>
</form>
</Form>
);
};
}
@@ -60,59 +60,61 @@ export const BatchLazyMintButton: React.FC<BatchLazyMintButtonProps> = ({
Batch Upload
</Button>
</SheetTrigger>
<SheetContent className="min-w-full overflow-y-auto">
<SheetHeader>
<SheetTitle className="text-left">Upload NFTs</SheetTitle>
<SheetContent className="!w-full !max-w-full overflow-y-auto p-0">
<SheetHeader className="sr-only">
<SheetTitle>Upload NFTs</SheetTitle>
</SheetHeader>
<BatchLazyMint
canCreateDelayedRevealBatch={canCreateDelayedRevealBatch}
chainId={contract.chain.id}
client={contract.client}
isLoggedIn={isLoggedIn}
nextTokenIdToMint={nextTokenIdToMintQuery.data || 0n}
onSubmit={async ({ revealType, data }) => {
try {
const tx = (() => {
switch (true) {
// lazy mint erc721
case revealType === "instant" && isErc721: {
return ERC721Ext.lazyMint({
contract,
nfts: data.metadatas,
});
<div className="p-4 lg:p-6">
<BatchLazyMint
canCreateDelayedRevealBatch={canCreateDelayedRevealBatch}
chainId={contract.chain.id}
client={contract.client}
isLoggedIn={isLoggedIn}
nextTokenIdToMint={nextTokenIdToMintQuery.data || 0n}
onSubmit={async ({ revealType, data }) => {
try {
const tx = (() => {
switch (true) {
// lazy mint erc721
case revealType === "instant" && isErc721: {
return ERC721Ext.lazyMint({
contract,
nfts: data.metadatas,
});
}
// lazy mint erc1155
case revealType === "instant" && !isErc721: {
return ERC1155Ext.lazyMint({
contract,
nfts: data.metadatas,
});
}
// delayed reveal erc721
case revealType === "delayed": {
return ERC721Ext.createDelayedRevealBatch({
contract,
metadata: data.metadata,
password: data.password,
placeholderMetadata: data.placeholderMetadata,
});
}
default: {
throw new Error("Invalid reveal type");
}
}
// lazy mint erc1155
case revealType === "instant" && !isErc721: {
return ERC1155Ext.lazyMint({
contract,
nfts: data.metadatas,
});
}
// delayed reveal erc721
case revealType === "delayed": {
return ERC721Ext.createDelayedRevealBatch({
contract,
metadata: data.metadata,
password: data.password,
placeholderMetadata: data.placeholderMetadata,
});
}
default: {
throw new Error("Invalid reveal type");
}
}
})();
})();
await sendTxMutation.mutateAsync(tx);
await sendTxMutation.mutateAsync(tx);
txNotifications.onSuccess();
setOpen(false);
} catch (error) {
console.error(error);
txNotifications.onError(error);
}
}}
/>
txNotifications.onSuccess();
setOpen(false);
} catch (error) {
console.error(error);
txNotifications.onError(error);
}
}}
/>
</div>
</SheetContent>
</Sheet>
</MinterOnly>
@@ -1,18 +1,5 @@
"use client";
import {
Accordion,
AccordionButton,
AccordionIcon,
AccordionItem,
AccordionPanel,
Divider,
FormControl,
Input,
Textarea,
} from "@chakra-ui/react";
import { FormErrorMessage, FormHelperText, FormLabel } from "chakra/form";
import { Heading } from "chakra/heading";
import type { Dispatch, SetStateAction } from "react";
import { useForm } from "react-hook-form";
import { toast } from "sonner";
@@ -24,7 +11,24 @@ import { OpenSeaPropertyBadge } from "@/components/badges/opensea";
import { FileInput } from "@/components/blocks/FileInput";
import { PropertiesFormControl } from "@/components/contracts/properties.shared";
import { TransactionButton } from "@/components/tx-button";
import {
Accordion,
AccordionContent,
AccordionItem,
AccordionTrigger,
} from "@/components/ui/accordion";
import { Button } from "@/components/ui/button";
import {
Form,
FormControl,
FormDescription,
FormField,
FormItem,
FormLabel,
FormMessage,
} from "@/components/ui/form";
import { Input } from "@/components/ui/input";
import { Textarea } from "@/components/ui/textarea";
import { useTxNotifications } from "@/hooks/useTxNotifications";
import type { NFTMetadataInputLimited } from "@/types/modified-types";
import { parseAttributes } from "@/utils/parseAttributes";
@@ -42,12 +46,12 @@ type LazyMintNftFormParams = {
isLoggedIn: boolean;
};
export const LazyMintNftForm: React.FC<LazyMintNftFormParams> = ({
export function LazyMintNftForm({
contract,
isErc721,
setOpen,
isLoggedIn,
}) => {
}: LazyMintNftFormParams) {
const address = useActiveAccount()?.address;
const sendAndConfirmTx = useSendAndConfirmTransaction();
@@ -81,7 +85,7 @@ export const LazyMintNftForm: React.FC<LazyMintNftFormParams> = ({
);
return (
<>
<Form {...form}>
<form
className="mt-6 flex flex-col gap-6"
id={LAZY_MINT_FORM_ID}
@@ -112,16 +116,21 @@ export const LazyMintNftForm: React.FC<LazyMintNftFormParams> = ({
}
})}
>
<div className="flex flex-col gap-2">
<Heading size="subtitle.md">Metadata </Heading>
<Divider />
</div>
<FormControl isInvalid={!!errors.name} isRequired>
<FormLabel>Name</FormLabel>
<Input autoFocus {...register("name")} />
<FormErrorMessage>{errors?.name?.message}</FormErrorMessage>
</FormControl>
<FormControl isInvalid={!!mediaFileError}>
<FormField
control={control}
name="name"
render={({ field }) => (
<FormItem>
<FormLabel>Name</FormLabel>
<FormControl>
<Input autoFocus {...field} className="bg-card" />
</FormControl>
<FormMessage />
</FormItem>
)}
/>
<FormItem>
<FormLabel>Media</FormLabel>
<div>
<FileInput
@@ -136,39 +145,58 @@ export const LazyMintNftForm: React.FC<LazyMintNftFormParams> = ({
value={media}
/>
</div>
<FormHelperText>
<FormDescription>
You can upload image, audio, video, html, text, pdf, and 3d model
files here.
</FormHelperText>
<FormErrorMessage>
{mediaFileError?.message as unknown as string}
</FormErrorMessage>
</FormControl>
</FormDescription>
{mediaFileError && (
<FormMessage>
{mediaFileError.message as unknown as string}
</FormMessage>
)}
</FormItem>
{showCoverImageUpload && (
<FormControl isInvalid={!!errors.image}>
<FormLabel>Cover Image</FormLabel>
<FileInput
accept={{ "image/*": [] }}
className="rounded border border-border transition-all"
client={contract.client}
previewMaxWidth="200px"
setValue={(file) => setValue("image", file)}
showUploadButton
value={image}
/>
<FormHelperText>
You can optionally upload an image as the cover of your NFT.
</FormHelperText>
<FormErrorMessage>
{errors?.image?.message as unknown as string}
</FormErrorMessage>
</FormControl>
<FormField
control={control}
name="image"
render={({ field }) => (
<FormItem>
<FormLabel>Cover Image</FormLabel>
<FormControl>
<FileInput
accept={{ "image/*": [] }}
className="rounded-lg bg-card border border-border transition-all"
client={contract.client}
previewMaxWidth="200px"
setValue={(file) => setValue("image", file)}
showUploadButton
value={image}
/>
</FormControl>
<FormDescription>
You can optionally upload an image as the cover of your NFT.
</FormDescription>
<FormMessage />
</FormItem>
)}
/>
)}
<FormControl isInvalid={!!errors.description}>
<FormLabel>Description</FormLabel>
<Textarea {...register("description")} />
<FormErrorMessage>{errors?.description?.message}</FormErrorMessage>
</FormControl>
<FormField
control={control}
name="description"
render={({ field }) => (
<FormItem>
<FormLabel>Description</FormLabel>
<FormControl>
<Textarea {...field} className="bg-card" />
</FormControl>
<FormMessage />
</FormItem>
)}
/>
<PropertiesFormControl
client={contract.client}
control={control}
@@ -178,112 +206,156 @@ export const LazyMintNftForm: React.FC<LazyMintNftFormParams> = ({
setValue={setValue}
watch={watch}
/>
<Accordion
allowToggle={!(errors.background_color || errors.external_url)}
index={
errors.background_color || errors.external_url ? [0] : undefined
type="single"
collapsible
className="-mx-1 border-t border-border"
defaultValue={
errors.background_color || errors.external_url
? "advanced"
: undefined
}
>
<AccordionItem>
<AccordionButton justifyContent="space-between" px={0}>
<Heading size="subtitle.md">Advanced Options</Heading>
<AccordionIcon />
</AccordionButton>
<AccordionPanel className="!px-0 flex flex-col gap-6">
<FormControl isInvalid={!!errors.background_color}>
<FormLabel>
Background Color <OpenSeaPropertyBadge />
</FormLabel>
<Input max="6" {...register("background_color")} />
<FormHelperText>
Must be a six-character hexadecimal with a pre-pended #.
</FormHelperText>
<FormErrorMessage>
{errors?.background_color?.message}
</FormErrorMessage>
</FormControl>
<AccordionItem value="advanced">
<AccordionTrigger className="justify-between px-1">
<h3 className="text-base font-medium">Advanced Options</h3>
</AccordionTrigger>
<AccordionContent className="flex flex-col gap-6 px-1">
<FormField
control={control}
name="background_color"
render={({ field }) => (
<FormItem>
<FormLabel>
Background Color <OpenSeaPropertyBadge />
</FormLabel>
<FormControl>
<Input max="6" {...field} className="bg-card" />
</FormControl>
<FormDescription>
Must be a six-character hexadecimal with a pre-pended #.
</FormDescription>
<FormMessage />
</FormItem>
)}
/>
{!(external_url instanceof File) && (
<FormControl isInvalid={!!errors.external_url}>
<FormLabel>
External URL <OpenSeaPropertyBadge />
</FormLabel>
<Input {...register("external_url")} />
<FormHelperText>
This is the URL that will appear below the asset&apos;s
image on OpenSea and will allow users to leave OpenSea and
view the item on your site.
</FormHelperText>
<FormErrorMessage>
{errors?.external_url?.message as unknown as string}
</FormErrorMessage>
</FormControl>
<FormField
control={control}
name="external_url"
render={({ field }) => (
<FormItem>
<FormLabel>
External URL <OpenSeaPropertyBadge />
</FormLabel>
<FormControl>
<Input
{...field}
className="bg-card"
value={
typeof field.value === "string" ? field.value : ""
}
/>
</FormControl>
<FormDescription>
This is the URL that will appear below the asset&apos;s
image on OpenSea and will allow users to leave OpenSea
and view the item on your site.
</FormDescription>
<FormMessage />
</FormItem>
)}
/>
)}
{!(image instanceof File) && (
<FormControl isInvalid={!!errors.image}>
<FormLabel>Image URL</FormLabel>
<Input
{...register("image")}
onChange={(e) => {
setValue("image", e.target.value);
}}
value={image}
/>
<FormHelperText>
If you already have your NFT image pre-uploaded to a URL,
you can specify it here instead of uploading the media file
</FormHelperText>
<FormErrorMessage>{errors?.image?.message}</FormErrorMessage>
</FormControl>
<FormField
control={control}
name="image"
render={({ field }) => (
<FormItem>
<FormLabel>Image URL</FormLabel>
<FormControl>
<Input
{...field}
onChange={(e) => {
setValue("image", e.target.value);
}}
value={typeof image === "string" ? image : ""}
className="bg-card"
/>
</FormControl>
<FormDescription>
If you already have your NFT image pre-uploaded to a
URL, you can specify it here instead of uploading the
media file
</FormDescription>
<FormMessage />
</FormItem>
)}
/>
)}
{!(animation_url instanceof File) && (
<FormControl isInvalid={!!errors.animation_url}>
<FormLabel>Animation URL</FormLabel>
<Input
{...register("animation_url")}
onChange={(e) => {
setValue("animation_url", e.target.value);
}}
value={animation_url}
/>
<FormHelperText>
If you already have your NFT Animation URL pre-uploaded to a
URL, you can specify it here instead of uploading the media
file
</FormHelperText>
<FormErrorMessage>
{errors?.animation_url?.message}
</FormErrorMessage>
</FormControl>
<FormField
control={control}
name="animation_url"
render={({ field }) => (
<FormItem>
<FormLabel>Animation URL</FormLabel>
<FormControl>
<Input
{...field}
onChange={(e) => {
setValue("animation_url", e.target.value);
}}
value={
typeof animation_url === "string"
? animation_url
: ""
}
className="bg-card"
/>
</FormControl>
<FormDescription>
If you already have your NFT Animation URL pre-uploaded
to a URL, you can specify it here instead of uploading
the media file
</FormDescription>
<FormMessage />
</FormItem>
)}
/>
)}
</AccordionPanel>
</AccordionContent>
</AccordionItem>
</Accordion>
<div className="mt-8 flex flex-row justify-end gap-3">
<Button
className="mr-3"
disabled={sendAndConfirmTx.isPending}
onClick={() => setOpen(false)}
variant="outline"
>
Cancel
</Button>
<TransactionButton
client={contract.client}
disabled={!isDirty}
form={LAZY_MINT_FORM_ID}
isLoggedIn={isLoggedIn}
isPending={sendAndConfirmTx.isPending}
transactionCount={1}
txChainID={contract.chain.id}
type="submit"
>
Lazy Mint NFT
</TransactionButton>
</div>
</form>
<div className="mt-8 flex flex-row justify-end gap-3">
<Button
className="mr-3"
disabled={sendAndConfirmTx.isPending}
onClick={() => setOpen(false)}
variant="outline"
>
Cancel
</Button>
<TransactionButton
client={contract.client}
disabled={!isDirty}
form={LAZY_MINT_FORM_ID}
isLoggedIn={isLoggedIn}
isPending={sendAndConfirmTx.isPending}
transactionCount={1}
txChainID={contract.chain.id}
type="submit"
>
Lazy Mint NFT
</TransactionButton>
</div>
</>
</Form>
);
};
}
@@ -1,19 +1,5 @@
"use client";
import {
Accordion,
AccordionButton,
AccordionIcon,
AccordionItem,
AccordionPanel,
Divider,
FormControl,
Input,
Textarea,
} from "@chakra-ui/react";
import { Button } from "chakra/button";
import { FormErrorMessage, FormHelperText, FormLabel } from "chakra/form";
import { Heading } from "chakra/heading";
import type { Dispatch, SetStateAction } from "react";
import { useForm } from "react-hook-form";
import { toast } from "sonner";
@@ -25,6 +11,24 @@ import { OpenSeaPropertyBadge } from "@/components/badges/opensea";
import { FileInput } from "@/components/blocks/FileInput";
import { PropertiesFormControl } from "@/components/contracts/properties.shared";
import { TransactionButton } from "@/components/tx-button";
import {
Accordion,
AccordionContent,
AccordionItem,
AccordionTrigger,
} from "@/components/ui/accordion";
import { Button } from "@/components/ui/button";
import {
Form,
FormControl,
FormDescription,
FormField,
FormItem,
FormLabel,
FormMessage,
} from "@/components/ui/form";
import { Input } from "@/components/ui/input";
import { Textarea } from "@/components/ui/textarea";
import { useTxNotifications } from "@/hooks/useTxNotifications";
import type { NFTMetadataInputLimited } from "@/types/modified-types";
import { parseAttributes } from "@/utils/parseAttributes";
@@ -42,12 +46,12 @@ type NFTMintForm = {
isLoggedIn: boolean;
};
export const NFTMintForm: React.FC<NFTMintForm> = ({
export function NFTMintForm({
contract,
isErc721,
setOpen,
isLoggedIn,
}) => {
}: NFTMintForm) {
const address = useActiveAccount()?.address;
const form = useForm<
NFTMetadataInputLimited & {
@@ -84,7 +88,7 @@ export const NFTMintForm: React.FC<NFTMintForm> = ({
);
return (
<>
<Form {...form}>
<form
className="mt-6 flex flex-col gap-6"
id={MINT_FORM_ID}
@@ -126,16 +130,21 @@ export const NFTMintForm: React.FC<NFTMintForm> = ({
}
})}
>
<div className="flex flex-col gap-2">
<Heading size="subtitle.md">Metadata xx</Heading>
<Divider />
</div>
<FormControl isInvalid={!!errors.name} isRequired>
<FormLabel>Name</FormLabel>
<Input autoFocus {...register("name")} />
<FormErrorMessage>{errors?.name?.message}</FormErrorMessage>
</FormControl>
<FormControl isInvalid={!!mediaFileError}>
<FormField
control={control}
name="name"
render={({ field }) => (
<FormItem>
<FormLabel>Name</FormLabel>
<FormControl>
<Input autoFocus {...field} className="bg-card" />
</FormControl>
<FormMessage />
</FormItem>
)}
/>
<FormItem>
<FormLabel>Media</FormLabel>
<div>
<FileInput
@@ -150,51 +159,80 @@ export const NFTMintForm: React.FC<NFTMintForm> = ({
value={media}
/>
</div>
<FormHelperText>
<FormDescription>
You can upload image, audio, video, html, text, pdf, and 3d model
files here.
</FormHelperText>
<FormErrorMessage>
{mediaFileError?.message as unknown as string}
</FormErrorMessage>
</FormControl>
</FormDescription>
{mediaFileError && (
<FormMessage>
{mediaFileError.message as unknown as string}
</FormMessage>
)}
</FormItem>
{showCoverImageUpload && (
<FormControl isInvalid={!!errors.image}>
<FormLabel>Cover Image</FormLabel>
<FileInput
accept={{ "image/*": [] }}
className="shrink-0 rounded border border-border transition-all"
client={contract.client}
previewMaxWidth="200px"
setValue={(file) => setValue("image", file)}
showUploadButton
value={image}
/>
<FormHelperText>
You can optionally upload an image as the cover of your NFT.
</FormHelperText>
<FormErrorMessage>
{errors?.image?.message as unknown as string}
</FormErrorMessage>
</FormControl>
<FormField
control={control}
name="image"
render={() => (
<FormItem>
<FormLabel>Cover Image</FormLabel>
<FormControl>
<FileInput
accept={{ "image/*": [] }}
className="shrink-0 rounded border border-border transition-all"
client={contract.client}
previewMaxWidth="200px"
setValue={(file) => setValue("image", file)}
showUploadButton
value={image}
/>
</FormControl>
<FormDescription>
You can optionally upload an image as the cover of your NFT.
</FormDescription>
<FormMessage />
</FormItem>
)}
/>
)}
<FormControl isInvalid={!!errors.description}>
<FormLabel>Description</FormLabel>
<Textarea {...register("description")} />
<FormErrorMessage>{errors?.description?.message}</FormErrorMessage>
</FormControl>
<FormField
control={control}
name="description"
render={({ field }) => (
<FormItem>
<FormLabel>Description</FormLabel>
<FormControl>
<Textarea {...field} className="bg-card" />
</FormControl>
<FormMessage />
</FormItem>
)}
/>
{!isErc721 && (
<FormControl isInvalid={!!errors.supply} isRequired>
<FormLabel>Initial Supply</FormLabel>
<Input
pattern="[0-9]"
step="1"
type="number"
{...register("supply")}
/>
<FormErrorMessage>{errors?.supply?.message}</FormErrorMessage>
</FormControl>
<FormField
control={control}
name="supply"
render={({ field }) => (
<FormItem>
<FormLabel>Initial Supply</FormLabel>
<FormControl>
<Input
pattern="[0-9]"
step="1"
type="number"
{...field}
className="bg-card"
/>
</FormControl>
<FormMessage />
</FormItem>
)}
/>
)}
<PropertiesFormControl
client={contract.client}
control={control}
@@ -204,109 +242,154 @@ export const NFTMintForm: React.FC<NFTMintForm> = ({
setValue={setValue}
watch={watch}
/>
<Accordion
allowToggle={!(errors.background_color || errors.external_url)}
index={
errors.background_color || errors.external_url ? [0] : undefined
type="single"
className="-mx-1 border-t border-border"
collapsible
defaultValue={
errors.background_color || errors.external_url
? "advanced"
: undefined
}
>
<AccordionItem>
<AccordionButton justifyContent="space-between" px={0}>
<Heading size="subtitle.md">Advanced Options</Heading>
<AccordionIcon />
</AccordionButton>
<AccordionPanel className="!px-0 flex flex-col gap-6">
<FormControl isInvalid={!!errors.background_color}>
<FormLabel>
Background Color <OpenSeaPropertyBadge />
</FormLabel>
<Input max="6" {...register("background_color")} />
<FormHelperText>
Must be a six-character hexadecimal with a pre-pended #.
</FormHelperText>
<FormErrorMessage>
{errors?.background_color?.message}
</FormErrorMessage>
</FormControl>
<AccordionItem value="advanced">
<AccordionTrigger className="justify-between px-1">
<h3 className="text-base font-medium">Advanced Options</h3>
</AccordionTrigger>
<AccordionContent>
<div className="flex flex-col gap-6 px-1">
<FormField
control={control}
name="background_color"
render={({ field }) => (
<FormItem>
<FormLabel>
Background Color <OpenSeaPropertyBadge />
</FormLabel>
<FormControl>
<Input max="6" {...field} className="bg-card" />
</FormControl>
<FormDescription>
Must be a six-character hexadecimal with a pre-pended #.
</FormDescription>
<FormMessage />
</FormItem>
)}
/>
{!(external_url instanceof File) && (
<FormControl isInvalid={!!errors.external_url}>
<FormLabel>
External URL <OpenSeaPropertyBadge />
</FormLabel>
<Input {...register("external_url")} />
<FormHelperText>
This is the URL that will appear below the asset&apos;s
image on OpenSea and will allow users to leave OpenSea and
view the item on your site.
</FormHelperText>
<FormErrorMessage>
{errors?.external_url?.message as unknown as string}
</FormErrorMessage>
</FormControl>
)}
{!(image instanceof File) && (
<FormControl isInvalid={!!errors.image}>
<FormLabel>Image URL</FormLabel>
<Input
onChange={(e) => {
setValue("image", e.target.value);
}}
value={image}
{!(external_url instanceof File) && (
<FormField
control={control}
name="external_url"
render={({ field }) => (
<FormItem>
<FormLabel>
External URL <OpenSeaPropertyBadge />
</FormLabel>
<FormControl>
<Input
{...field}
className="bg-card"
value={
typeof field.value === "string" ? field.value : ""
}
/>
</FormControl>
<FormDescription>
This is the URL that will appear below the
asset&apos;s image on OpenSea and will allow users to
leave OpenSea and view the item on your site.
</FormDescription>
<FormMessage />
</FormItem>
)}
/>
<FormHelperText>
If you already have your NFT image pre-uploaded to a URL,
you can specify it here instead of uploading the asset
</FormHelperText>
<FormErrorMessage>{errors?.image?.message}</FormErrorMessage>
</FormControl>
)}
)}
{!(animation_url instanceof File) && (
<FormControl isInvalid={!!errors.animation_url}>
<FormLabel>Animation URL</FormLabel>
<Input
onChange={(e) => {
setValue("animation_url", e.target.value);
}}
value={animation_url}
{!(image instanceof File) && (
<FormField
control={control}
name="image"
render={({ field }) => (
<FormItem>
<FormLabel>Image URL</FormLabel>
<FormControl>
<Input
{...field}
onChange={(e) => {
setValue("image", e.target.value);
}}
value={image}
className="bg-card"
/>
</FormControl>
<FormDescription>
If you already have your NFT image pre-uploaded to a
URL, you can specify it here instead of uploading the
asset
</FormDescription>
<FormMessage />
</FormItem>
)}
/>
<FormHelperText>
If you already have your NFT Animation URL pre-uploaded to a
URL, you can specify it here instead of uploading the asset
</FormHelperText>
<FormErrorMessage>
{errors?.animation_url?.message}
</FormErrorMessage>
</FormControl>
)}
</AccordionPanel>
)}
{!(animation_url instanceof File) && (
<FormField
control={control}
name="animation_url"
render={({ field }) => (
<FormItem>
<FormLabel>Animation URL</FormLabel>
<FormControl>
<Input
{...field}
onChange={(e) => {
setValue("animation_url", e.target.value);
}}
value={animation_url}
className="bg-card"
/>
</FormControl>
<FormDescription>
If you already have your NFT Animation URL
pre-uploaded to a URL, you can specify it here instead
of uploading the asset
</FormDescription>
<FormMessage />
</FormItem>
)}
/>
)}
</div>
</AccordionContent>
</AccordionItem>
</Accordion>
<div className="mt-8 flex flex-row justify-end gap-3">
<Button
disabled={sendAndConfirmTx.isPending}
className="mr-3"
onClick={() => setOpen(false)}
variant="outline"
>
Cancel
</Button>
<TransactionButton
client={contract.client}
disabled={!isDirty}
form={MINT_FORM_ID}
isLoggedIn={isLoggedIn}
isPending={sendAndConfirmTx.isPending}
transactionCount={1}
txChainID={contract.chain.id}
type="submit"
>
Mint NFT
</TransactionButton>
</div>
</form>
<div className="mt-8 flex flex-row justify-end gap-3">
<Button
isDisabled={sendAndConfirmTx.isPending}
mr={3}
onClick={() => setOpen(false)}
variant="outline"
>
Cancel
</Button>
<TransactionButton
client={contract.client}
disabled={!isDirty}
form={MINT_FORM_ID}
isLoggedIn={isLoggedIn}
isPending={sendAndConfirmTx.isPending}
transactionCount={1}
txChainID={contract.chain.id}
type="submit"
>
Mint NFT
</TransactionButton>
</div>
</>
</Form>
);
};
}
@@ -11,6 +11,7 @@ import {
CardHeader,
CardTitle,
} from "@/components/ui/card";
import { Input } from "@/components/ui/input";
import { Label } from "@/components/ui/label";
import { RadioGroup, RadioGroupItem } from "@/components/ui/radio-group";
import { Separator } from "@/components/ui/separator";
@@ -39,6 +40,12 @@ export function CreditBalanceSection({
const [selectedAmount, setSelectedAmount] = useState<string>(
predefinedAmounts[0].value,
);
const [customAmount, setCustomAmount] = useState<string>("");
const isSelectedAmountValid =
selectedAmount !== "" &&
Number.isInteger(Number(selectedAmount)) &&
Number(selectedAmount) > 0;
return (
<Card className="w-full">
@@ -74,7 +81,10 @@ export function CreditBalanceSection({
<Label className="font-medium text-base">Select Amount</Label>
<RadioGroup
className="grid grid-cols-4 gap-3"
onValueChange={setSelectedAmount}
onValueChange={(value) => {
setSelectedAmount(value);
setCustomAmount("");
}}
value={selectedAmount}
>
{predefinedAmounts.map((amount) => (
@@ -95,6 +105,30 @@ export function CreditBalanceSection({
</div>
))}
</RadioGroup>
{/* Custom Amount Input */}
<div className="space-y-2">
<Label className="font-medium text-base" htmlFor="customAmount">
Or enter custom amount
</Label>
<Input
id="customAmount"
type="number"
inputMode="numeric"
pattern="[0-9]*"
min={1}
step={1}
value={customAmount}
placeholder="Custom amount"
onChange={(e) => {
const val = e.target.value.replace(/^0+/, "");
if (/^\d*$/.test(val)) {
setCustomAmount(val);
setSelectedAmount(val);
}
}}
/>
</div>
</div>
{/* Top-up Summary and Button */}
@@ -125,7 +159,7 @@ export function CreditBalanceSection({
<Button
asChild
className="w-full"
disabled={!isOwnerAccount}
disabled={!isOwnerAccount || !isSelectedAmountValid}
size="lg"
>
<a
@@ -254,7 +254,7 @@ function ProductsSection(props: { teamSlug: string; projectSlug: string }) {
{
description:
"Bridge, swap, and purchase cryptocurrencies with any fiat options or tokens via cross-chain routing",
href: `/team/${props.teamSlug}/${props.projectSlug}/universal-bridge`,
href: `/team/${props.teamSlug}/${props.projectSlug}/payments`,
icon: PayIcon,
title: "Payments",
},
@@ -79,7 +79,7 @@ export function ProjectSidebarLayout(props: {
group: "Monetize",
links: [
{
href: `${layoutPath}/universal-bridge`,
href: `${layoutPath}/payments`,
icon: PayIcon,
label: "Payments",
},
@@ -13,7 +13,7 @@ import {
TableHeader,
TableRow,
} from "@/components/ui/table";
import { CardHeading } from "../../universal-bridge/components/common";
import { CardHeading } from "../../payments/components/common";
export function TopInsightChainsTable(props: {
data: InsightChainStats[];
@@ -13,7 +13,7 @@ import {
TableHeader,
TableRow,
} from "@/components/ui/table";
import { CardHeading } from "../../universal-bridge/components/common";
import { CardHeading } from "../../payments/components/common";
export function TopInsightEndpointsTable(props: {
data: InsightEndpointStats[];
@@ -423,7 +423,7 @@ function AppHighlightsCard({
emptyContent: (
<EmptyStateContent
description="Your app hasn't collected any fees yet."
link={`/team/${params.team_slug}/${params.project_slug}/connect/universal-bridge/settings`}
link={`/team/${params.team_slug}/${params.project_slug}/payments/settings`}
metric="Fees"
/>
),
@@ -5,8 +5,8 @@ import { getAuthToken } from "@/api/auth-token";
import { getProject } from "@/api/projects";
import { getClientThirdwebClient } from "@/constants/thirdweb-client.client";
import { loginRedirect } from "@/utils/redirects";
import { PayAnalytics } from "./components/PayAnalytics";
import { getUniversalBridgeFiltersFromSearchParams } from "./components/time";
import { PayAnalytics } from "../components/PayAnalytics";
import { getUniversalBridgeFiltersFromSearchParams } from "../components/time";
export default async function Page(props: {
params: Promise<{
@@ -24,9 +24,7 @@ export default async function Page(props: {
const project = await getProject(params.team_slug, params.project_slug);
if (!authToken) {
loginRedirect(
`/team/${params.team_slug}/${params.project_slug}/universal-bridge`,
);
loginRedirect(`/team/${params.team_slug}/${params.project_slug}/payments`);
}
if (!project) {
@@ -70,7 +68,7 @@ export default async function Page(props: {
</div>
<a
className="inline-flex items-center gap-2 rounded-md bg-green-600 px-4 py-2 font-medium text-sm text-white transition-all hover:bg-green-600/90 hover:shadow-sm"
href="https://portal.thirdweb.com/pay"
href="https://portal.thirdweb.com/payments"
rel="noopener noreferrer"
target="_blank"
>
@@ -8,7 +8,7 @@ import { TabButtons } from "@/components/ui/tabs";
type Tab = "embed" | "sdk" | "api";
export function PayEmbedFTUX(props: {
export function BuyWidgetFTUX(props: {
clientId: string;
codeExamples: {
embed: React.ReactNode;
@@ -21,7 +21,7 @@ export function PayEmbedFTUX(props: {
<div className="rounded-lg border bg-card">
<div className="border-b border-dashed p-4">
<h2 className="font-semibold text-lg tracking-tight">
Start Monetizing Your App
Setup Payments to View Analytics
</h2>
</div>
@@ -56,7 +56,7 @@ export function PayEmbedFTUX(props: {
<Button asChild size="sm" variant="outline">
<Link
className="gap-2"
href="https://portal.thirdweb.com/pay"
href="https://portal.thirdweb.com/payments"
rel="noopener noreferrer"
target="_blank"
>
@@ -0,0 +1,37 @@
"use client";
import Link from "next/link";
import { reportPaymentCardClick } from "@/analytics/report";
import { Button } from "@/components/ui/button";
import { Card } from "@/components/ui/card";
export function FeatureCard(props: {
title: string;
description: string;
icon: React.ReactNode;
id: string;
link: { href: string; label: string; target?: string };
}) {
return (
<Card className="p-4 flex flex-col items-start gap-4">
<div className="text-muted-foreground rounded-full border bg-background size-12 flex items-center justify-center">
{props.icon}
</div>
<div className="flex flex-col gap-0.5">
<h3 className="font-semibold">{props.title}</h3>
<p className="text-muted-foreground text-sm">{props.description}</p>
</div>
<Button
onClick={() => reportPaymentCardClick({ id: props.id })}
size="sm"
variant="default"
className="h-8"
asChild
>
<Link href={props.link.href} target={props.link.target}>
{props.link.label}
</Link>
</Button>
</Card>
);
}
@@ -7,10 +7,10 @@ import {
import type { Range } from "@/components/analytics/date-range-selector";
import { CodeServer } from "@/components/ui/code/code.server";
import { Skeleton } from "@/components/ui/skeleton";
import { BuyWidgetFTUX } from "./BuyWidgetFTUX";
import { apiCode, embedCode, sdkCode } from "./code-examples";
import { PayAnalyticsFilter } from "./PayAnalyticsFilter";
import { PayCustomersTable } from "./PayCustomersTable";
import { PayEmbedFTUX } from "./PayEmbedFTUX";
import { PaymentHistory } from "./PaymentHistory";
import { PaymentsSuccessRate } from "./PaymentsSuccessRate";
import { PayNewCustomers } from "./PayNewCustomers";
@@ -67,7 +67,7 @@ export async function PayAnalytics(props: {
if (!hasVolume && !hasWallet) {
return (
<PayEmbedFTUX
<BuyWidgetFTUX
clientId={props.projectClientId}
codeExamples={
{
@@ -18,7 +18,7 @@ export default async function Layout(props: {
redirect(`/team/${params.team_slug}`);
}
const payLayoutPath = `/team/${params.team_slug}/${params.project_slug}/universal-bridge`;
const payLayoutPath = `/team/${params.team_slug}/${params.project_slug}/payments`;
return (
<div className="flex grow flex-col">
@@ -32,7 +32,7 @@ export default async function Layout(props: {
cryptocurrencies and execute transactions with any fiat options or
tokens via cross-chain routing.{" "}
<UnderlineLink
href="https://portal.thirdweb.com/pay"
href="https://portal.thirdweb.com/payments"
rel="noopener noreferrer"
target="_blank"
>
@@ -45,10 +45,15 @@ export default async function Layout(props: {
<TabPathLinks
className="w-full"
links={[
{
exactMatch: true,
name: "Overview",
path: `${payLayoutPath}`,
},
{
exactMatch: true,
name: "Analytics",
path: payLayoutPath,
path: `${payLayoutPath}/analytics`,
},
{
name: "Webhooks",
@@ -0,0 +1,134 @@
import {
ArrowLeftRightIcon,
ArrowUpRightIcon,
BadgeDollarSignIcon,
BellDotIcon,
CoinsIcon,
HammerIcon,
LinkIcon,
} from "lucide-react";
import { redirect } from "next/navigation";
import { ResponsiveSearchParamsProvider } from "responsive-rsc";
import { getAuthToken } from "@/api/auth-token";
import { getProject } from "@/api/projects";
import { loginRedirect } from "@/utils/redirects";
import { FeatureCard } from "./components/FeatureCard.client";
export default async function Page(props: {
params: Promise<{
team_slug: string;
project_slug: string;
}>;
searchParams: Promise<{
from?: string | undefined | string[];
to?: string | undefined | string[];
interval?: string | undefined | string[];
}>;
}) {
const [params, authToken] = await Promise.all([props.params, getAuthToken()]);
const project = await getProject(params.team_slug, params.project_slug);
if (!authToken) {
loginRedirect(`/team/${params.team_slug}/${params.project_slug}/payments`);
}
if (!project) {
redirect(`/team/${params.team_slug}`);
}
const searchParams = await props.searchParams;
return (
<ResponsiveSearchParamsProvider value={searchParams}>
<div>
<div className="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-6">
<FeatureCard
title="Earn Fees"
description="Setup fees to earn any time a user swaps or bridges funds."
icon={<BadgeDollarSignIcon className="size-5" />}
id="earn_fees"
link={{
href: `/team/${params.team_slug}/${params.project_slug}/payments/settings`,
label: "Configure",
}}
/>
<FeatureCard
title="Create Payment Links"
description="Create shareable URLs to receive any token in seconds."
icon={<LinkIcon className="size-5" />}
id="create_payment_links"
link={{
href: `/pay`,
label: "Create",
}}
/>
<FeatureCard
title="Sell Your Token"
description="Allow users to swap from any token to your token from your app."
icon={<ArrowLeftRightIcon className="size-5" />}
id="sell_your_token"
link={{
href: `/team/${params.team_slug}/${params.project_slug}/tokens`,
label: "Launch Token",
}}
/>
<FeatureCard
title="Get Notified"
description="Create Webhooks to get notified on each purchase or transaction."
icon={<BellDotIcon className="size-5" />}
id="get_notified"
link={{
href: `/team/${params.team_slug}/${params.project_slug}/payments/webhooks`,
label: "Setup",
}}
/>
<FeatureCard
title="Sell Products"
description="Sell physical or digital products with an easy-to-configure component."
icon={<CoinsIcon className="size-5" />}
id="sell_products"
link={{
href: "https://portal.thirdweb.com/payments/products",
label: "Get Started",
target: "_blank",
}}
/>
<FeatureCard
title="Customize Your Experience"
description="Fully customizable backend API to create your own branded flows."
icon={<HammerIcon className="size-5" />}
id="customize_your_experience"
link={{
href: "https://payments.thirdweb.com/reference",
label: "Docs",
target: "_blank",
}}
/>
</div>
<div className="h-10" />
<div className="relative overflow-hidden rounded-lg border-2 border-green-500/20 bg-gradient-to-br from-card/80 to-card/50 p-4 shadow-[inset_0_1px_2px_0_rgba(0,0,0,0.02)]">
<div className="absolute inset-0 bg-gradient-to-br from-green-500/5 to-transparent" />
<div className="relative flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between">
<div className="flex flex-col gap-1">
<h3 className="font-medium text-lg">Get Started with Payments</h3>
<p className="text-muted-foreground text-sm">
Simple, instant, and secure payments across any token and chain.
</p>
</div>
<a
className="inline-flex items-center gap-2 rounded-md bg-green-600 px-4 py-2 font-medium text-sm text-white transition-all hover:bg-green-600/90 hover:shadow-sm"
href="https://portal.thirdweb.com/payments"
rel="noopener noreferrer"
target="_blank"
>
Learn More
<ArrowUpRightIcon className="size-4" />
</a>
</div>
</div>
</div>
</ResponsiveSearchParamsProvider>
);
}
@@ -1,5 +1,5 @@
import { PayConfig } from "@app/team/[team_slug]/[project_slug]/(sidebar)/universal-bridge/settings/PayConfig";
import { RouteDiscovery } from "@app/team/[team_slug]/[project_slug]/(sidebar)/universal-bridge/settings/RouteDiscovery";
import { PayConfig } from "@app/team/[team_slug]/[project_slug]/(sidebar)/payments/settings/PayConfig";
import { RouteDiscovery } from "@app/team/[team_slug]/[project_slug]/(sidebar)/payments/settings/RouteDiscovery";
import { redirect } from "next/navigation";
import { getAuthToken } from "@/api/auth-token";
import { getProject } from "@/api/projects";
@@ -23,9 +23,7 @@ export default async function Page(props: {
]);
if (!authToken) {
loginRedirect(
`/team/${team_slug}/${project_slug}/universal-bridge/settings`,
);
loginRedirect(`/team/${team_slug}/${project_slug}/payments/settings`);
}
if (!team) {
@@ -15,7 +15,7 @@ import {
TableHeader,
TableRow,
} from "@/components/ui/table";
import { CardHeading } from "../../universal-bridge/components/common";
import { CardHeading } from "../../payments/components/common";
export function TopRPCMethodsTable(props: {
data: RpcMethodStats[];
@@ -223,7 +223,7 @@ export function ProjectGeneralSettingsPageUI(props: {
aaConfig: `${projectLayout}/account-abstraction/settings`,
afterDeleteRedirectTo: `/team/${props.teamSlug}`,
inAppConfig: `${projectLayout}/wallets/settings`,
payConfig: `${projectLayout}/universal-bridge/settings`,
payConfig: `${projectLayout}/payments/settings`,
};
const { project } = props;
@@ -1,5 +1,6 @@
import { ArrowDownToLineIcon } from "lucide-react";
import { Button } from "@/components/ui/button";
import { cn } from "@/lib/utils";
export function handleDownload(params: {
fileContent: string;
@@ -22,10 +23,14 @@ export function DownloadFileButton(props: {
fileNameWithExtension: string;
fileFormat: "text/csv" | "application/json";
label: string;
variant?: "default" | "outline";
className?: string;
iconClassName?: string;
}) {
return (
<Button
className="gap-2"
className={cn("gap-2", props.className)}
variant={props.variant}
onClick={() => {
handleDownload({
fileContent: props.fileContent,
@@ -35,7 +40,7 @@ export function DownloadFileButton(props: {
}}
size="sm"
>
<ArrowDownToLineIcon className="size-4" />
<ArrowDownToLineIcon className={cn("size-4", props.iconClassName)} />
{props.label}
</Button>
);
@@ -19,6 +19,7 @@ import {
reportAssetCreationSuccessful,
} from "@/analytics/report";
import type { Team } from "@/api/team";
import { FilePreview } from "@/components/blocks/file-preview";
import { GatedSwitch } from "@/components/blocks/GatedSwitch";
import type { MultiStepState } from "@/components/blocks/multi-step-status/multi-step-status";
import { MultiStepStatus } from "@/components/blocks/multi-step-status/multi-step-status";
@@ -36,7 +37,6 @@ import {
import { Skeleton } from "@/components/ui/skeleton";
import { parseError } from "@/utils/errorParser";
import { ChainOverview } from "../../_common/chain-overview";
import { FilePreview } from "../../_common/file-preview";
import { StepCard } from "../../_common/step-card";
import { StorageErrorPlanUpsell } from "../../_common/storage-error-upsell";
import type {
@@ -14,6 +14,7 @@ import {
} from "thirdweb";
import { MediaRenderer } from "thirdweb/react";
import { DropZone } from "@/components/blocks/drop-zone/drop-zone";
import { FilePreview } from "@/components/blocks/file-preview";
import { PaginationButtons } from "@/components/blocks/pagination-buttons";
import { TokenSelector } from "@/components/blocks/TokenSelector";
import { Badge } from "@/components/ui/badge";
@@ -32,7 +33,6 @@ import {
TableRow,
} from "@/components/ui/table";
import { resolveSchemeWithErrorHandler } from "@/utils/resolveSchemeWithErrorHandler";
import { FilePreview } from "../../../_common/file-preview";
import { nftWithPriceSchema } from "../schema";
import { BatchUploadInstructions } from "./batch-upload-instructions";
import {
@@ -13,6 +13,7 @@ import {
reportAssetCreationSuccessful,
} from "@/analytics/report";
import type { Team } from "@/api/team";
import { FilePreview } from "@/components/blocks/file-preview";
import { GatedSwitch } from "@/components/blocks/GatedSwitch";
import {
type MultiStepState,
@@ -30,7 +31,6 @@ import {
import { useAllChainsData } from "@/hooks/chains/allChains";
import { parseError } from "@/utils/errorParser";
import { ChainOverview } from "../../_common/chain-overview";
import { FilePreview } from "../../_common/file-preview";
import { StepCard } from "../../_common/step-card";
import { StorageErrorPlanUpsell } from "../../_common/storage-error-upsell";
import type { CreateAssetFormValues } from "../_common/form";
@@ -49,7 +49,7 @@ export default async function WebhooksLayout(props: {
},
{
name: "Payments",
path: `/team/${params.team_slug}/${params.project_slug}/webhooks/universal-bridge`,
path: `/team/${params.team_slug}/${params.project_slug}/payments/webhooks`,
},
]}
scrollableClassName="container max-w-7xl"
@@ -63,7 +63,7 @@ export default async function WebhooksLayout(props: {
},
{
name: "Payments",
path: `/team/${params.team_slug}/${params.project_slug}/webhooks/universal-bridge`,
path: `/team/${params.team_slug}/${params.project_slug}/payments/webhooks`,
},
]}
scrollableClassName="container max-w-7xl"
@@ -1,7 +1,7 @@
import { redirect } from "next/navigation";
import { getProject } from "@/api/projects";
import { UnderlineLink } from "@/components/ui/UnderlineLink";
import { PayWebhooksPage } from "../../universal-bridge/webhooks/components/webhooks.client";
import { PayWebhooksPage } from "../../payments/webhooks/components/webhooks.client";
export default async function Page(props: {
params: Promise<{
+49 -4
View File
@@ -57,14 +57,59 @@ const nextConfig = {
async redirects() {
return [
{
destination: "/connect/sign-in/button",
source: "/connect/pay",
destination: "/payments/ui-components",
permanent: false,
source: "/connect/sign-in",
},
{
destination: "/connect/account-abstraction/connect",
source: "/connect/pay/:path*",
destination: "/payments/:path*",
permanent: false,
},
{
source: "/connect/ui",
destination: "/wallets/headless/account-components",
permanent: false,
},
{
source: "/connect/ui/nft",
destination: "/wallets/headless/nft-components",
permanent: false,
},
{
source: "/connect/ui/token",
destination: "/wallets/headless/token-components",
permanent: false,
},
{
source: "/connect/ui/chain",
destination: "/wallets/headless/chain-components",
permanent: false,
},
{
source: "/connect/ui/wallet",
destination: "/wallets/headless/wallet-components",
permanent: false,
},
{
source: "/connect/:path*",
destination: "/wallets/:path*",
permanent: false,
},
{
source: "/engine/airdrop",
destination: "/transactions/airdrop-tokens",
permanent: false,
},
{
source: "/engine/minting",
destination: "/transactions/mint-tokens",
permanent: false,
},
{
source: "/engine/webhooks",
destination: "/transactions/webhooks",
permanent: false,
source: "/connect/account-abstraction",
},
];
},
+25 -25
View File
@@ -6,74 +6,74 @@ const staticSidebarLinks: SidebarLink[] = [
isCollapsible: false,
links: [
{
href: "/connect/sign-in/button",
href: "/wallets/sign-in/button",
name: "ConnectButton",
},
{
href: "/connect/sign-in/embed",
href: "/wallets/sign-in/embed",
name: "ConnectEmbed",
},
{
href: "/connect/sign-in/headless",
href: "/wallets/sign-in/headless",
name: "Headless Connect",
},
{
href: "/connect/in-app-wallet",
href: "/wallets/in-app-wallet",
name: "In-App Wallets",
},
{
href: "/connect/in-app-wallet/ecosystem",
href: "/wallets/in-app-wallet/ecosystem",
name: "Ecosystem Wallets",
},
{
href: "/connect/account-abstraction/sponsor",
href: "/wallets/account-abstraction/sponsor",
name: "EIP-4337",
},
{
href: "/connect/account-abstraction/7702",
href: "/wallets/account-abstraction/7702",
name: "EIP-7702",
},
{
href: "/connect/account-abstraction/5792",
href: "/wallets/account-abstraction/5792",
name: "EIP-5792",
},
{
href: "/connect/account-abstraction/native-aa",
href: "/wallets/account-abstraction/native-aa",
name: "Native AA (zkSync)",
},
{
href: "/connect/auth",
href: "/wallets/auth",
name: "Auth",
},
{
href: "/connect/social",
href: "/wallets/social",
name: "Social",
},
{
href: "/connect/blockchain-api",
href: "/wallets/blockchain-api",
name: "Blockchain API",
},
{
expanded: false,
links: [
{
href: "/connect/ui",
href: "/wallets/headless/account-components",
name: "Account",
},
{
href: "/connect/ui/nft",
href: "/wallets/headless/nft-components",
name: "NFT",
},
{
href: "/connect/ui/token",
href: "/wallets/headless/token-components",
name: "Token",
},
{
href: "/connect/ui/chain",
href: "/wallets/headless/chain-components",
name: "Chain",
},
{
href: "/connect/ui/wallet",
href: "/wallets/headless/wallet-components",
name: "Wallet",
},
],
@@ -89,23 +89,23 @@ const universalBridgeSidebarLinks: SidebarLink = {
isCollapsible: false,
links: [
{
href: "/connect/pay",
href: "/payments/ui-components",
name: "UI Component",
},
{
href: "/connect/pay/fund-wallet",
href: "/payments/fund-wallet",
name: "Buy Crypto",
},
{
href: "/connect/pay/commerce",
href: "/payments/commerce",
name: "Checkout",
},
{
href: "/connect/pay/transactions",
href: "/payments/transactions",
name: "Transactions",
},
{
href: "/connect/pay/backend",
href: "/payments/backend",
name: "Backend API",
},
],
@@ -117,15 +117,15 @@ const engineSidebarLinks: SidebarLink = {
isCollapsible: false,
links: [
{
href: "/engine/airdrop",
href: "/transactions/airdrop-tokens",
name: "Airdrop",
},
{
href: "/engine/minting",
href: "/transactions/mint-tokens",
name: "Mint NFTs",
},
{
href: "/engine/webhooks",
href: "/transactions/webhooks",
name: "Webhooks",
},
],
+1 -1
View File
@@ -1,5 +1,5 @@
import { redirect } from "next/navigation";
export default function Page() {
redirect("/connect/sign-in/button");
redirect("/wallets/sign-in/button");
}
@@ -1,5 +1,5 @@
import type React from "react";
import { PageHeader } from "../../../../components/blocks/APIHeader";
import { PageHeader } from "../../../components/blocks/APIHeader";
export default function Layout(props: { children: React.ReactNode }) {
return (
@@ -8,7 +8,7 @@ export default function Layout(props: { children: React.ReactNode }) {
description={
<>HTTP API to bridge, swap and onramp to and from any currency</>
}
docsLink="https://portal.thirdweb.com/connect/pay/overview?utm_source=playground"
docsLink="https://portal.thirdweb.com/payments?utm_source=playground"
title="Payments API"
/>
@@ -38,7 +38,7 @@ export default async function Page() {
}
return {
description: pathObj.get?.description || "",
link: `/connect/pay/backend/reference?route=${pathName}`,
link: `/payments/backend/reference?route=${pathName}`,
name: pathName,
};
})}
@@ -6,9 +6,9 @@ import {
BreadcrumbList,
BreadcrumbSeparator,
} from "@/components/ui/breadcrumb";
import { THIRDWEB_CLIENT } from "../../../../../lib/client";
import { isProd } from "../../../../../lib/env";
import { BlueprintPlayground } from "../../../../insight/[blueprint_slug]/blueprint-playground.client";
import { THIRDWEB_CLIENT } from "../../../../lib/client";
import { isProd } from "../../../../lib/env";
import { BlueprintPlayground } from "../../../insight/[blueprint_slug]/blueprint-playground.client";
import { getBridgePaths } from "../utils";
export default async function Page(props: {
@@ -20,7 +20,7 @@ export default async function Page(props: {
// invalid url
if (!params.route) {
redirect("/connect/pay/backend");
redirect("/payments/backend");
}
const thirdwebDomain = !isProd ? "thirdweb-dev" : "thirdweb";
@@ -31,7 +31,7 @@ export default async function Page(props: {
// invalid url
if (!pathMetadata) {
redirect("/connect/pay/backend");
redirect("/payments/backend");
}
const title = pathMetadata.summary || "";
@@ -46,7 +46,7 @@ export default async function Page(props: {
)}
<BlueprintPlayground
backLink={"/connect/pay/backend"}
backLink={"/payments/backend"}
clientId={THIRDWEB_CLIENT.clientId}
domain={domain}
key={params.route}
@@ -63,9 +63,7 @@ function Breadcrumbs() {
<Breadcrumb>
<BreadcrumbList>
<BreadcrumbItem>
<BreadcrumbLink href="/connect/pay/backend">
Payments API
</BreadcrumbLink>
<BreadcrumbLink href="/payments/backend">Payments API</BreadcrumbLink>
</BreadcrumbItem>
<BreadcrumbSeparator />
</BreadcrumbList>
@@ -1,5 +1,5 @@
import type { OpenAPIV3 } from "openapi-types";
import { isProd } from "../../../../lib/env";
import { isProd } from "../../../lib/env";
export async function getBridgePaths() {
const thirdwebDomain = !isProd ? "thirdweb-dev" : "thirdweb";
@@ -21,7 +21,7 @@ export default function Page() {
Let your users pay for any service with fiat or crypto on any chain.
</>
}
docsLink="https://portal.thirdweb.com/connect/pay/get-started?utm_source=playground"
docsLink="https://portal.thirdweb.com/payments?utm_source=playground"
title="Commerce payments with fiat or crypto"
>
<BuyMerch />
@@ -1,10 +1,8 @@
import { lazy, Suspense } from "react";
import { CodeLoading } from "../../../../components/code/code.client";
import { CodeLoading } from "../../../components/code/code.client";
import type { BridgeComponentsPlaygroundOptions } from "./types";
const CodeClient = lazy(
() => import("../../../../components/code/code.client"),
);
const CodeClient = lazy(() => import("../../../components/code/code.client"));
export function CodeGen(props: { options: BridgeComponentsPlaygroundOptions }) {
return (
@@ -27,8 +27,8 @@ import {
import { TokenSelector } from "@/components/ui/TokenSelector";
import { THIRDWEB_CLIENT } from "@/lib/client";
import type { TokenMetadata } from "@/lib/types";
import { CollapsibleSection } from "../../sign-in/components/CollapsibleSection";
import { ColorFormGroup } from "../../sign-in/components/ColorFormGroup";
import { CollapsibleSection } from "../../wallets/sign-in/components/CollapsibleSection";
import { ColorFormGroup } from "../../wallets/sign-in/components/ColorFormGroup";
import type { BridgeComponentsPlaygroundOptions } from "../components/types";
export function LeftSection(props: {
@@ -545,7 +545,7 @@ export function LeftSection(props: {
<Link
className="inline-flex items-center gap-2 text-muted-foreground hover:text-foreground"
href="https://portal.thirdweb.com/connect/account-abstraction/overview?utm_source=playground"
href="https://portal.thirdweb.com/wallets/sponsor-gas?utm_source=playground"
target="_blank"
>
Learn more about Account Abstraction
@@ -12,9 +12,9 @@ import {
TransactionWidget,
useActiveAccount,
} from "thirdweb/react";
import { Button } from "../../../../components/ui/button";
import { THIRDWEB_CLIENT } from "../../../../lib/client";
import { cn } from "../../../../lib/utils";
import { Button } from "../../../components/ui/button";
import { THIRDWEB_CLIENT } from "../../../lib/client";
import { cn } from "../../../lib/utils";
import { CodeGen } from "../components/CodeGen";
import type { BridgeComponentsPlaygroundOptions } from "../components/types";
@@ -22,7 +22,7 @@ export default function Page() {
and generate revenue for each user transaction.
</>
}
docsLink="https://portal.thirdweb.com/connect/pay/get-started?utm_source=playground"
docsLink="https://portal.thirdweb.com/wallets/sponsor-gas?utm_source=playground"
title="The easiest way for users to fund their wallets"
>
<StyledPayWidget />

Before

Width:  |  Height:  |  Size: 388 KiB

After

Width:  |  Height:  |  Size: 388 KiB

@@ -26,7 +26,7 @@ export default function Page() {
any chain.
</>
}
docsLink="https://portal.thirdweb.com/connect/pay/get-started?utm_source=playground"
docsLink="https://portal.thirdweb.com/wallets/sponsor-gas?utm_source=playground"
title="Onchain transactions with fiat or crypto"
>
<BuyOnchainAsset />
@@ -2,7 +2,7 @@ import type { Metadata } from "next";
import ThirdwebProvider from "@/components/thirdweb-provider";
import { metadataBase } from "@/lib/constants";
import { PageLayout } from "../../../components/blocks/APIHeader";
import PayEmbedPlayground from "./embed/page";
import PayEmbedPlayground from "../embed/page";
export const metadata: Metadata = {
description:
@@ -23,7 +23,7 @@ export default function Page(props: {
and generate revenue for each user transaction.
</>
}
docsLink="https://portal.thirdweb.com/connect/pay/get-started?utm_source=playground"
docsLink="https://portal.thirdweb.com/payments?utm_source=playground"
title="Payments UI component"
>
<PayEmbedPlayground searchParams={props.searchParams} />
@@ -1,4 +1,4 @@
import { EngineAirdropPreview } from "@/app/engine/airdrop/_components/airdrop-preview";
import { EngineAirdropPreview } from "@/app/transactions/airdrop-tokens/_components/airdrop-preview";
import ThirdwebProvider from "@/components/thirdweb-provider";
import { PageLayout } from "../../../components/blocks/APIHeader";
import { AirdropCode } from "./_components/airdrop-code";
@@ -1,4 +1,4 @@
import { EngineMintPreview } from "@/app/engine/minting/_components/mint-preview";
import { EngineMintPreview } from "@/app/transactions/mint-tokens/_components/mint-preview";
import ThirdwebProvider from "@/components/thirdweb-provider";
import { PageLayout } from "../../../components/blocks/APIHeader";
import { MintCode } from "./_components/mint-code";
@@ -1,4 +1,4 @@
import { EngineWebhooksPreview } from "@/app/engine/webhooks/_components/webhooks-preview";
import { EngineWebhooksPreview } from "@/app/transactions/webhooks/_components/webhooks-preview";
import ThirdwebProvider from "@/components/thirdweb-provider";
import { PageLayout } from "../../../components/blocks/APIHeader";
@@ -12,7 +12,7 @@ export default function Page() {
transaction or backend wallet events.
</>
}
docsLink="https://portal.thirdweb.com/engine/features/webhooks?utm_source=playground"
docsLink="https://portal.thirdweb.com/engine/v2/features/webhooks?utm_source=playground"
title="Webhooks"
>
<EngineWebhooksPreview />
@@ -23,7 +23,7 @@ export default function Page() {
connected wallet.
</>
}
docsLink="https://portal.thirdweb.com/connect/account-abstraction/overview?utm_source=playground"
docsLink="https://portal.thirdweb.com/wallets/sponsor-gas?utm_source=playground"
title="EIP-5792 Wallet Capabilities"
>
<div className="flex flex-col gap-14">
@@ -37,9 +37,8 @@ export default function Page() {
function Eip5792GetCapabilities() {
return (
<>
<CodeExample
code={`\
<CodeExample
code={`\
import { useCapabilities } from "thirdweb/react";
function App() {
@@ -52,53 +51,52 @@ function App() {
return <div>Capabilities: {JSON.stringify(capabilities)}</div>;
}
`}
header={{
description:
"Get the capabilities of the connected wallet using the useCapabilities hook",
title: "Getting the wallet capabilities",
}}
lang="tsx"
preview={<Eip5792GetCapabilitiesPreview />}
/>
</>
header={{
description:
"Get the capabilities of the connected wallet using the useCapabilities hook",
title: "Getting the wallet capabilities",
}}
lang="tsx"
preview={<Eip5792GetCapabilitiesPreview />}
/>
);
}
function Eip5792SendCalls() {
return (
<>
<CodeExample
code={`\
const code = `\
import { useSendCalls, useWaitForCallsReceipt } from "thirdweb/react";
function App() {
const { mutate: sendCalls, isPending, data } = useSendCalls();
const { data: receipt, isLoading: isConfirming } = useWaitForCallsReceipt(data);
const { mutate: sendCalls, isPending, data } = useSendCalls();
const { data: receipt, isLoading: isConfirming } = useWaitForCallsReceipt(data);
const handleClick = async () => {
sendCalls({
calls: [firstTransaction, secondTransaction],
});
};
const handleClick = async () => {
sendCalls({
calls: [firstTransaction, secondTransaction],
});
};
return (
<>
<button onClick={handleClick}>Send calls</button>
{isPending && <p>Sending...</p>}
{isConfirming && <p>Confirming...</p>}
{receipt && <p>Confirmed! {receipt?.receipts?.[0]?.transactionHash}</p>}
</>
);
}
`;
function Eip5792SendCalls() {
return (
<>
<button onClick={handleClick}>Send calls</button>
{isPending && <p>Sending...</p>}
{isConfirming && <p>Confirming...</p>}
{receipt && <p>Confirmed! {receipt?.receipts?.[0]?.transactionHash}</p>}
</>
);
}
`}
header={{
description:
"Send batched calls to the connected wallet using the useSendCalls hook",
title: "Sending calls to the wallet",
}}
lang="tsx"
preview={<Eip5792SendCallsPreview />}
/>
</>
<CodeExample
code={code}
header={{
description:
"Send batched calls to the connected wallet using the useSendCalls hook",
title: "Sending calls to the wallet",
}}
lang="tsx"
preview={<Eip5792SendCallsPreview />}
/>
);
}
@@ -22,7 +22,7 @@ export default function Page() {
account with no code changes.
</>
}
docsLink="https://portal.thirdweb.com/connect/account-abstraction/overview?utm_source=playground"
docsLink="https://portal.thirdweb.com/wallets/sponsor-gas?utm_source=playground"
title="EIP-7702 Smart Accounts"
>
<Eip7702SmartAccount />
@@ -33,9 +33,8 @@ export default function Page() {
function Eip7702SmartAccount() {
return (
<>
<CodeExample
code={`\
<CodeExample
code={`\
import { claimTo } from "thirdweb/extensions/erc1155";
import { TransactionButton } from "thirdweb/react";
@@ -72,14 +71,13 @@ function App() {
</>
);
}`}
header={{
description:
"In-app wallets can be turned into EIP-7702 smart accounts by changing the execution mode",
title: "Turning in-app wallets into EIP-7702 smart accounts",
}}
lang="tsx"
preview={<Eip7702SmartAccountPreview />}
/>
</>
header={{
description:
"In-app wallets can be turned into EIP-7702 smart accounts by changing the execution mode",
title: "Turning in-app wallets into EIP-7702 smart accounts",
}}
lang="tsx"
preview={<Eip7702SmartAccountPreview />}
/>
);
}
@@ -26,7 +26,7 @@ export default function Page() {
programmability.
</>
}
docsLink="https://portal.thirdweb.com/connect/account-abstraction/overview?utm_source=playground"
docsLink="https://portal.thirdweb.com/wallets/sponsor-gas?utm_source=playground"
title="Connect smart accounts"
>
<ConnectSmartAccount />
@@ -22,7 +22,7 @@ export default function Page() {
abstraction with no code changes.
</>
}
docsLink="https://portal.thirdweb.com/connect/account-abstraction/overview?utm_source=playground"
docsLink="https://portal.thirdweb.com/wallets/sponsor-gas?utm_source=playground"
title="Native Account Abstraction"
>
<SponsoredZksyncTx />
@@ -33,9 +33,8 @@ export default function Page() {
function SponsoredZksyncTx() {
return (
<>
<CodeExample
code={`\
<CodeExample
code={`\
import { claimTo } from "thirdweb/extensions/erc1155";
import { TransactionButton } from "thirdweb/react";
@@ -68,9 +67,8 @@ function App() {
</>
);
}`}
lang="tsx"
preview={<SponsoredTxZksyncPreview />}
/>
</>
lang="tsx"
preview={<SponsoredTxZksyncPreview />}
/>
);
}
@@ -20,7 +20,7 @@ export default function Page() {
description={
<>Turn any EOA into a smart contract wallet with EIP-4337.</>
}
docsLink="https://portal.thirdweb.com/connect/account-abstraction/overview?utm_source=playground"
docsLink="https://portal.thirdweb.com/wallets/sponsor-gas?utm_source=playground"
title="EIP-4337 Smart Contract Wallets"
>
<div className="flex flex-col gap-14">
@@ -81,7 +81,7 @@ import { baseSepolia } from "thirdweb/chains";
const wallets = [
inAppWallet(
{
{
// turn on gas sponsorship for in-app wallets
// Can use EIP4337 or EIP7702 on supported chains
executionMode: {
@@ -23,7 +23,7 @@ export default function Page() {
apps and games to connect to the same accounts.
</>
}
docsLink="https://portal.thirdweb.com/connect/wallet/ecosystem/set-up?utm_source=playground"
docsLink="https://portal.thirdweb.com/wallets/ecosystem/set-up?utm_source=playground"
title="Build your own Ecosystem"
>
<ConnectEmbedExample />

Some files were not shown because too many files have changed in this diff Show More