Skip to content

Commit 7de1635

Browse files
committed
update
1 parent fdf3d5b commit 7de1635

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

apps/dashboard/next-env.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33
/// <reference types="next/navigation-types/compat/navigation" />
44

55
// NOTE: This file should not be edited
6-
// see https://nextjs.org/docs/app/building-your-application/configuring/typescript for more information.
6+
// see https://nextjs.org/docs/app/api-reference/config/typescript for more information.

apps/dashboard/src/app/(dashboard)/(chain)/[chain_id]/[contractAddress]/nfts/components/claim-button.tsx

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import { GemIcon } from "lucide-react";
1616
import { useState } from "react";
1717
import { useForm } from "react-hook-form";
1818
import { toast } from "sonner";
19-
import { type ThirdwebContract, ZERO_ADDRESS } from "thirdweb";
19+
import { type ThirdwebContract, ZERO_ADDRESS, isAddress } from "thirdweb";
2020
import { getApprovalForTransaction } from "thirdweb/extensions/erc20";
2121
import { claimTo } from "thirdweb/extensions/erc721";
2222
import { useActiveAccount, useSendAndConfirmTransaction } from "thirdweb/react";
@@ -62,7 +62,19 @@ export const NFTClaimButton: React.FC<NFTClaimButtonProps> = ({
6262
<div className="flex w-full flex-col gap-6 md:flex-row">
6363
<FormControl isRequired isInvalid={!!errors.to}>
6464
<FormLabel>To Address</FormLabel>
65-
<Input placeholder={ZERO_ADDRESS} {...register("to")} />
65+
<Input
66+
placeholder={ZERO_ADDRESS}
67+
{...register("to", {
68+
validate: (value) => {
69+
if (!value) {
70+
return "Enter a recipient address";
71+
}
72+
if (!isAddress(value.trim())) {
73+
return "Invalid EVM address";
74+
}
75+
},
76+
})}
77+
/>
6678
<FormHelperText>Enter the address to claim to.</FormHelperText>
6779
<FormErrorMessage>{errors.to?.message}</FormErrorMessage>
6880
</FormControl>
@@ -110,7 +122,7 @@ export const NFTClaimButton: React.FC<NFTClaimButtonProps> = ({
110122

111123
const transaction = claimTo({
112124
contract,
113-
to: d.to,
125+
to: d.to.trim(),
114126
quantity: BigInt(d.amount),
115127
from: account.address,
116128
});

0 commit comments

Comments
 (0)