Skip to content

Commit 946c64f

Browse files
committed
fix: ens address parsing
1 parent e5ce154 commit 946c64f

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

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

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
"use client";
22

3+
import { resolveAddressAndEns } from "@app/(dashboard)/profile/[addressOrEns]/resolveAddressAndEns";
34
import { zodResolver } from "@hookform/resolvers/zod";
45
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
56
import { LinkIcon } from "lucide-react";
67
import { type PropsWithChildren, useState } from "react";
78
import { useForm } from "react-hook-form";
89
import { toast } from "sonner";
9-
import { Bridge, isAddress, toUnits } from "thirdweb";
10-
import { checksumAddress, shortenAddress } from "thirdweb/utils";
10+
import { Bridge, toUnits } from "thirdweb";
11+
import { checksumAddress } from "thirdweb/utils";
1112
import z from "zod";
1213
import { createPaymentLink } from "@/api/universal-bridge/developer";
1314
import { getUniversalBridgeTokens } from "@/api/universal-bridge/tokens";
@@ -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)