Skip to content

Commit 44e6e11

Browse files
authored
[SDK] Feature: Allow proceeding past first checkout widget page with no wallet (#7937)
1 parent 76cfecb commit 44e6e11

File tree

5 files changed

+27
-33
lines changed

5 files changed

+27
-33
lines changed

.changeset/eager-loops-fold.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"thirdweb": patch
3+
---
4+
5+
Allows using the checkout widget without a wallet connected

packages/thirdweb/src/react/web/ui/Bridge/BridgeOrchestrator.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,6 @@ export function BridgeOrchestrator({
277277
{state.value === "init" && uiOptions.mode === "direct_payment" && (
278278
<DirectPayment
279279
client={client}
280-
connectOptions={modifiedConnectOptions}
281280
onContinue={handleRequirementsResolved}
282281
showThirdwebBranding={showThirdwebBranding}
283282
uiOptions={uiOptions}

packages/thirdweb/src/react/web/ui/Bridge/CheckoutWidget.tsx

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,11 @@ import type { ConnectButton_connectModalOptions } from "../../../core/hooks/conn
2222
import type { SupportedTokens } from "../../../core/utils/defaultTokens.js";
2323
import { useConnectLocale } from "../ConnectWallet/locale/getConnectLocale.js";
2424
import { EmbedContainer } from "../ConnectWallet/Modal/ConnectEmbed.js";
25+
import { Container } from "../components/basic.js";
26+
import { Button } from "../components/buttons.js";
2527
import { DynamicHeight } from "../components/DynamicHeight.js";
2628
import { Spinner } from "../components/Spinner.js";
29+
import { Text } from "../components/text.js";
2730
import type { LocaleId } from "../types.js";
2831
import { BridgeOrchestrator, type UIOptions } from "./BridgeOrchestrator.js";
2932
import { UnsupportedTokenScreen } from "./UnsupportedTokenScreen.js";
@@ -421,6 +424,19 @@ export function CheckoutWidget(props: CheckoutWidgetProps) {
421424
);
422425
}
423426

427+
if (bridgeDataQuery.isError) {
428+
content = (
429+
<Container flex="column" center="both" gap="md" p="md" py="xl">
430+
<Text center size="md" weight={600}>
431+
Something went wrong.
432+
</Text>
433+
<Button variant="ghost" onClick={() => bridgeDataQuery.refetch()}>
434+
Retry
435+
</Button>
436+
</Container>
437+
);
438+
}
439+
424440
return (
425441
<CustomThemeProvider theme={theme}>
426442
<EmbedContainer

packages/thirdweb/src/react/web/ui/Bridge/DirectPayment.tsx

Lines changed: 3 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,13 @@ import type { Token } from "../../../../bridge/types/Token.js";
33
import { defineChain } from "../../../../chains/utils.js";
44
import type { ThirdwebClient } from "../../../../client/client.js";
55
import type { Address } from "../../../../utils/address.js";
6-
import { useCustomTheme } from "../../../core/design-system/CustomThemeProvider.js";
7-
import { useActiveAccount } from "../../../core/hooks/wallets/useActiveAccount.js";
8-
import { ConnectButton } from "../ConnectWallet/ConnectButton.js";
96
import { PoweredByThirdweb } from "../ConnectWallet/PoweredByTW.js";
107
import { FiatValue } from "../ConnectWallet/screens/Buy/swap/FiatValue.js";
118
import { Container, Line } from "../components/basic.js";
129
import { Button } from "../components/buttons.js";
1310
import { ChainName } from "../components/ChainName.js";
1411
import { Spacer } from "../components/Spacer.js";
1512
import { Text } from "../components/text.js";
16-
import type { PayEmbedConnectOptions } from "../PayEmbed.js";
1713
import type { UIOptions } from "./BridgeOrchestrator.js";
1814
import { ChainIcon } from "./common/TokenAndChain.js";
1915
import { WithHeader } from "./common/WithHeader.js";
@@ -34,11 +30,6 @@ export interface DirectPaymentProps {
3430
*/
3531
onContinue: (amount: string, token: Token, receiverAddress: Address) => void;
3632

37-
/**
38-
* Connect options for wallet connection
39-
*/
40-
connectOptions?: PayEmbedConnectOptions;
41-
4233
/**
4334
* Whether to show thirdweb branding in the widget.
4435
* @default true
@@ -50,12 +41,9 @@ export function DirectPayment({
5041
uiOptions,
5142
client,
5243
onContinue,
53-
connectOptions,
5444
showThirdwebBranding = true,
5545
}: DirectPaymentProps) {
56-
const activeAccount = useActiveAccount();
5746
const chain = defineChain(uiOptions.paymentInfo.token.chainId);
58-
const theme = useCustomTheme();
5947
const handleContinue = () => {
6048
onContinue(
6149
uiOptions.paymentInfo.amount,
@@ -188,23 +176,9 @@ export function DirectPayment({
188176

189177
{/* Action button */}
190178
<Container flex="column">
191-
{activeAccount ? (
192-
<Button fullWidth onClick={handleContinue} variant="primary">
193-
{buyNow}
194-
</Button>
195-
) : (
196-
<ConnectButton
197-
client={client}
198-
connectButton={{
199-
label: buyNow,
200-
style: {
201-
width: "100%",
202-
},
203-
}}
204-
theme={theme}
205-
{...connectOptions}
206-
/>
207-
)}
179+
<Button fullWidth onClick={handleContinue} variant="primary">
180+
{buyNow}
181+
</Button>
208182

209183
{showThirdwebBranding ? (
210184
<div>

packages/thirdweb/src/react/web/ui/Bridge/payment-selection/WalletFiatSelection.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -121,10 +121,10 @@ export function WalletFiatSelection({
121121
</Container>
122122
<Container flex="column" gap="3xs" style={{ flex: 1 }}>
123123
<Text color="primaryText" size="sm" style={{ fontWeight: 600 }}>
124-
Connect Another Wallet
124+
Connect a Wallet
125125
</Text>
126126
<Text color="secondaryText" size="xs">
127-
Use a different wallet to pay
127+
Pay with any web3 wallet
128128
</Text>
129129
</Container>
130130
</Container>
@@ -169,7 +169,7 @@ export function WalletFiatSelection({
169169
Pay with Card
170170
</Text>
171171
<Text color="secondaryText" size="xs">
172-
Buy crypto and bridge in one step
172+
Onramp and pay in one step
173173
</Text>
174174
</Container>
175175
</Container>

0 commit comments

Comments
 (0)