|
1 | 1 | "use client"; |
2 | 2 |
|
| 3 | +import { resolveAddressAndEns } from "@app/(dashboard)/profile/[addressOrEns]/resolveAddressAndEns"; |
3 | 4 | import { zodResolver } from "@hookform/resolvers/zod"; |
4 | 5 | import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query"; |
5 | 6 | import { LinkIcon } from "lucide-react"; |
6 | 7 | import { type PropsWithChildren, useState } from "react"; |
7 | 8 | import { useForm } from "react-hook-form"; |
8 | 9 | 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"; |
11 | 12 | import z from "zod"; |
12 | 13 | import { createPaymentLink } from "@/api/universal-bridge/developer"; |
13 | 14 | import { getUniversalBridgeTokens } from "@/api/universal-bridge/tokens"; |
@@ -81,13 +82,22 @@ export function CreatePaymentLinkButton( |
81 | 82 | throw new Error("Token not found"); |
82 | 83 | } |
83 | 84 |
|
| 85 | + const addressResult = await resolveAddressAndEns( |
| 86 | + values.recipient, |
| 87 | + client, |
| 88 | + ); |
| 89 | + |
| 90 | + if (!addressResult) { |
| 91 | + throw new Error("Invalid recipient address."); |
| 92 | + } |
| 93 | + |
84 | 94 | await createPaymentLink({ |
85 | 95 | clientId: props.clientId, |
86 | 96 | teamId: props.teamId, |
87 | 97 | intent: { |
88 | 98 | destinationChainId: values.chainId, |
89 | 99 | destinationTokenAddress: checksumAddress(values.tokenAddress), |
90 | | - receiver: checksumAddress(values.recipient), |
| 100 | + receiver: checksumAddress(addressResult.address), |
91 | 101 | amount: toUnits(values.amount.toString(), token.decimals), |
92 | 102 | }, |
93 | 103 | title: values.title, |
@@ -179,11 +189,7 @@ export function CreatePaymentLinkButton( |
179 | 189 | className="w-full" |
180 | 190 | {...field} |
181 | 191 | onChange={field.onChange} |
182 | | - value={ |
183 | | - isAddress(field.value) |
184 | | - ? shortenAddress(field.value) |
185 | | - : field.value |
186 | | - } |
| 192 | + value={field.value} |
187 | 193 | placeholder="Address or ENS" |
188 | 194 | required |
189 | 195 | /> |
|
0 commit comments