Skip to content

Commit 6177e11

Browse files
committed
feat: use BuyWidget in bridge page
1 parent ffea73c commit 6177e11

File tree

3 files changed

+37
-18
lines changed

3 files changed

+37
-18
lines changed

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

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

33
import { useTheme } from "next-themes";
4-
import { PayEmbed, type TokenInfo } from "thirdweb/react";
4+
import { BuyWidget, 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";
8+
import type { Address } from "thirdweb";
89

910
export function UniversalBridgeEmbed({
1011
chainId,
1112
token,
1213
amount,
13-
}: { chainId?: number; token: TokenInfo | undefined; amount: string }) {
14+
}: { chainId?: number; token: TokenInfo | undefined; amount?: string }) {
1415
const { theme } = useTheme();
1516
const chain = useV5DashboardChain(chainId || 1);
1617

18+
if (chainId && token) {
19+
return (
20+
<BuyWidget
21+
client={bridgeAppThirdwebClient}
22+
chain={chain}
23+
tokenAddress={token.address as Address}
24+
amount={amount ?? "1"}
25+
/>
26+
);
27+
}
28+
1729
return (
1830
<PayEmbed
1931
client={bridgeAppThirdwebClient}

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,13 @@ export default async function BridgePage({
5454
token={
5555
symbol && decimals && tokenName
5656
? {
57-
address: tokenAddress as Address,
58-
name: tokenName,
59-
symbol,
60-
}
57+
address: tokenAddress as Address,
58+
name: tokenName,
59+
symbol,
60+
}
6161
: undefined
6262
}
63-
amount={(amount || "0.01") as string}
63+
amount={amount as string}
6464
/>
6565
</main>
6666

apps/playground-web/src/app/connect/sign-in/button/RightSection.tsx

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { useEffect, useState } from "react";
55
import {
66
arbitrumSepolia,
77
baseSepolia,
8+
defineChain,
89
optimismSepolia,
910
sepolia,
1011
} from "thirdweb/chains";
@@ -89,11 +90,11 @@ export function RightSection(props: {
8990
const themeObj =
9091
connectOptions.theme.type === "dark"
9192
? darkTheme({
92-
colors: connectOptions.theme.darkColorOverrides,
93-
})
93+
colors: connectOptions.theme.darkColorOverrides,
94+
})
9495
: lightTheme({
95-
colors: connectOptions.theme.lightColorOverrides,
96-
});
96+
colors: connectOptions.theme.lightColorOverrides,
97+
});
9798

9899
useEffect(() => {
99100
if (!connectOptions.enableAuth) {
@@ -119,15 +120,21 @@ export function RightSection(props: {
119120
showThirdwebBranding: connectOptions.ShowThirdwebBranding,
120121
requireApproval: connectOptions.requireApproval,
121122
}}
122-
chains={[sepolia, baseSepolia, optimismSepolia, arbitrumSepolia]}
123+
chains={[
124+
defineChain(578),
125+
sepolia,
126+
baseSepolia,
127+
optimismSepolia,
128+
arbitrumSepolia,
129+
]}
123130
wallets={wallets}
124131
auth={connectOptions.enableAuth ? playgroundAuth : undefined}
125132
accountAbstraction={
126133
connectOptions.enableAccountAbstraction
127134
? {
128-
chain: sepolia,
129-
sponsorGas: true,
130-
}
135+
chain: sepolia,
136+
sponsorGas: true,
137+
}
131138
: undefined
132139
}
133140
/>
@@ -185,9 +192,9 @@ export function RightSection(props: {
185192
accountAbstraction={
186193
connectOptions.enableAccountAbstraction
187194
? {
188-
chain: sepolia,
189-
sponsorGas: true,
190-
}
195+
chain: sepolia,
196+
sponsorGas: true,
197+
}
191198
: undefined
192199
}
193200
termsOfServiceUrl={connectOptions.termsOfServiceLink}

0 commit comments

Comments
 (0)