11import { ArrowUpRightIcon } from "lucide-react" ;
22import type { Metadata } from "next" ;
3+ import type { Address } from "thirdweb" ;
4+ import { defineChain } from "thirdweb/chains" ;
5+ import { getContract } from "thirdweb/contract" ;
6+ import { getCurrencyMetadata } from "thirdweb/extensions/erc20" ;
37import { UniversalBridgeEmbed } from "./components/client/UniversalBridgeEmbed" ;
8+ import { bridgeAppThirdwebClient } from "./constants" ;
49
510const title = "Universal Bridge: Swap, Bridge, and Onramp" ;
611const description =
@@ -18,11 +23,39 @@ export const metadata: Metadata = {
1823export default async function BridgePage ( {
1924 searchParams,
2025} : { searchParams : Promise < Record < string , string | string [ ] > > } ) {
21- const { chainId } = await searchParams ;
26+ const { chainId, tokenAddress, amount } = await searchParams ;
27+
28+ const {
29+ symbol,
30+ decimals,
31+ name : tokenName ,
32+ } = chainId && tokenAddress
33+ ? await getCurrencyMetadata ( {
34+ contract : getContract ( {
35+ client : bridgeAppThirdwebClient ,
36+ // eslint-disable-next-line no-restricted-syntax
37+ chain : defineChain ( Number ( chainId ) ) ,
38+ address : tokenAddress as Address ,
39+ } ) ,
40+ } )
41+ : { } ;
42+
2243 return (
2344 < div className = "relative mx-auto flex h-screen w-full flex-col items-center justify-center overflow-hidden border py-10" >
2445 < main className = "container z-10 flex justify-center" >
25- < UniversalBridgeEmbed chainId = { chainId ? Number ( chainId ) : undefined } />
46+ < UniversalBridgeEmbed
47+ chainId = { chainId ? Number ( chainId ) : undefined }
48+ token = {
49+ symbol && decimals && tokenName
50+ ? {
51+ address : tokenAddress as Address ,
52+ name : tokenName ,
53+ symbol,
54+ }
55+ : undefined
56+ }
57+ amount = { ( amount || "0.01" ) as string }
58+ />
2659 </ main >
2760
2861 { /* eslint-disable-next-line @next/next/no-img-element */ }
0 commit comments