Skip to content

Commit a0f1323

Browse files
committed
feat: adds token and amount query params to bridge page
1 parent a4d1da1 commit a0f1323

File tree

2 files changed

+43
-5
lines changed

2 files changed

+43
-5
lines changed

apps/dashboard/src/app/bridge/components/client/UniversalBridgeEmbed.tsx

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

33
import { useTheme } from "next-themes";
4-
import { PayEmbed } from "thirdweb/react";
4+
import { PayEmbed, type TokenInfo } from "thirdweb/react";
55
import { getSDKTheme } from "../../../(app)/components/sdk-component-theme";
66
import { useV5DashboardChain } from "../../../../lib/v5-adapter";
77
import { bridgeAppThirdwebClient } from "../../constants";
88

9-
export function UniversalBridgeEmbed({ chainId }: { chainId?: number }) {
9+
export function UniversalBridgeEmbed({
10+
chainId,
11+
token,
12+
amount,
13+
}: { chainId?: number; token: TokenInfo | undefined; amount: string }) {
1014
const { theme } = useTheme();
1115
const chain = useV5DashboardChain(chainId || 1);
1216

@@ -17,7 +21,8 @@ export function UniversalBridgeEmbed({ chainId }: { chainId?: number }) {
1721
mode: "fund_wallet",
1822
prefillBuy: {
1923
chain,
20-
amount: "0.01",
24+
token,
25+
amount,
2126
},
2227
}}
2328
theme={getSDKTheme(theme === "light" ? "light" : "dark")}

apps/dashboard/src/app/bridge/page.tsx

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
import { ArrowUpRightIcon } from "lucide-react";
22
import 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";
37
import { UniversalBridgeEmbed } from "./components/client/UniversalBridgeEmbed";
8+
import { bridgeAppThirdwebClient } from "./constants";
49

510
const title = "Universal Bridge: Swap, Bridge, and Onramp";
611
const description =
@@ -18,11 +23,39 @@ export const metadata: Metadata = {
1823
export 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

Comments
 (0)