Skip to content

Commit 0252bf7

Browse files
committed
fix: ens address parsing
1 parent e5ce154 commit 0252bf7

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/payments/links/components/CreatePaymentLinkButton.client.tsx

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ import { Input } from "@/components/ui/input";
3535
import { Spinner } from "@/components/ui/Spinner/Spinner";
3636
import { getClientThirdwebClient } from "@/constants/thirdweb-client.client";
3737
import { parseErrorToMessage } from "@/utils/errorParser";
38+
import { resolveAddressAndEns } from "@app/(dashboard)/profile/[addressOrEns]/resolveAddressAndEns";
3839

3940
const formSchema = z.object({
4041
chainId: z.number(),
@@ -81,13 +82,22 @@ export function CreatePaymentLinkButton(
8182
throw new Error("Token not found");
8283
}
8384

85+
const addressResult = await resolveAddressAndEns(
86+
values.recipient,
87+
client,
88+
);
89+
90+
if (!addressResult) {
91+
throw new Error("Invalid recipient address.");
92+
}
93+
8494
await createPaymentLink({
8595
clientId: props.clientId,
8696
teamId: props.teamId,
8797
intent: {
8898
destinationChainId: values.chainId,
8999
destinationTokenAddress: checksumAddress(values.tokenAddress),
90-
receiver: checksumAddress(values.recipient),
100+
receiver: checksumAddress(addressResult.address),
91101
amount: toUnits(values.amount.toString(), token.decimals),
92102
},
93103
title: values.title,
@@ -179,11 +189,7 @@ export function CreatePaymentLinkButton(
179189
className="w-full"
180190
{...field}
181191
onChange={field.onChange}
182-
value={
183-
isAddress(field.value)
184-
? shortenAddress(field.value)
185-
: field.value
186-
}
192+
value={field.value}
187193
placeholder="Address or ENS"
188194
required
189195
/>

0 commit comments

Comments
 (0)