Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/eager-loops-fold.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"thirdweb": patch
---

Allows using the checkout widget without a wallet connected
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,6 @@ export function BridgeOrchestrator({
{state.value === "init" && uiOptions.mode === "direct_payment" && (
<DirectPayment
client={client}
connectOptions={modifiedConnectOptions}
onContinue={handleRequirementsResolved}
showThirdwebBranding={showThirdwebBranding}
uiOptions={uiOptions}
Expand Down
16 changes: 16 additions & 0 deletions packages/thirdweb/src/react/web/ui/Bridge/CheckoutWidget.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,11 @@ import type { ConnectButton_connectModalOptions } from "../../../core/hooks/conn
import type { SupportedTokens } from "../../../core/utils/defaultTokens.js";
import { useConnectLocale } from "../ConnectWallet/locale/getConnectLocale.js";
import { EmbedContainer } from "../ConnectWallet/Modal/ConnectEmbed.js";
import { Container } from "../components/basic.js";
import { Button } from "../components/buttons.js";
import { DynamicHeight } from "../components/DynamicHeight.js";
import { Spinner } from "../components/Spinner.js";
import { Text } from "../components/text.js";
import type { LocaleId } from "../types.js";
import { BridgeOrchestrator, type UIOptions } from "./BridgeOrchestrator.js";
import { UnsupportedTokenScreen } from "./UnsupportedTokenScreen.js";
Expand Down Expand Up @@ -421,6 +424,19 @@ export function CheckoutWidget(props: CheckoutWidgetProps) {
);
}

if (bridgeDataQuery.isError) {
content = (
<Container flex="column" center="both" gap="md" p="md" py="xl">
<Text center size="md" weight={600}>
Something went wrong.
</Text>
<Button variant="ghost" onClick={() => bridgeDataQuery.refetch()}>
Retry
</Button>
</Container>
);
}

return (
<CustomThemeProvider theme={theme}>
<EmbedContainer
Expand Down
32 changes: 3 additions & 29 deletions packages/thirdweb/src/react/web/ui/Bridge/DirectPayment.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,13 @@
import { defineChain } from "../../../../chains/utils.js";
import type { ThirdwebClient } from "../../../../client/client.js";
import type { Address } from "../../../../utils/address.js";
import { useCustomTheme } from "../../../core/design-system/CustomThemeProvider.js";
import { useActiveAccount } from "../../../core/hooks/wallets/useActiveAccount.js";
import { ConnectButton } from "../ConnectWallet/ConnectButton.js";
import { PoweredByThirdweb } from "../ConnectWallet/PoweredByTW.js";
import { FiatValue } from "../ConnectWallet/screens/Buy/swap/FiatValue.js";
import { Container, Line } from "../components/basic.js";
import { Button } from "../components/buttons.js";
import { ChainName } from "../components/ChainName.js";
import { Spacer } from "../components/Spacer.js";
import { Text } from "../components/text.js";
import type { PayEmbedConnectOptions } from "../PayEmbed.js";
import type { UIOptions } from "./BridgeOrchestrator.js";
import { ChainIcon } from "./common/TokenAndChain.js";
import { WithHeader } from "./common/WithHeader.js";
Expand All @@ -34,11 +30,6 @@
*/
onContinue: (amount: string, token: Token, receiverAddress: Address) => void;

/**
* Connect options for wallet connection
*/
connectOptions?: PayEmbedConnectOptions;

/**
* Whether to show thirdweb branding in the widget.
* @default true
Expand All @@ -50,12 +41,9 @@
uiOptions,
client,
onContinue,
connectOptions,
showThirdwebBranding = true,
}: DirectPaymentProps) {
const activeAccount = useActiveAccount();
const chain = defineChain(uiOptions.paymentInfo.token.chainId);
const theme = useCustomTheme();
const handleContinue = () => {
onContinue(
uiOptions.paymentInfo.amount,
Expand Down Expand Up @@ -188,23 +176,9 @@

{/* Action button */}
<Container flex="column">
{activeAccount ? (
<Button fullWidth onClick={handleContinue} variant="primary">
{buyNow}
</Button>
) : (
<ConnectButton
client={client}
connectButton={{
label: buyNow,
style: {
width: "100%",
},
}}
theme={theme}
{...connectOptions}
/>
)}
<Button fullWidth onClick={handleContinue} variant="primary">
{buyNow}
</Button>

Check warning on line 181 in packages/thirdweb/src/react/web/ui/Bridge/DirectPayment.tsx

View check run for this annotation

Codecov / codecov/patch

packages/thirdweb/src/react/web/ui/Bridge/DirectPayment.tsx#L179-L181

Added lines #L179 - L181 were not covered by tests

{showThirdwebBranding ? (
<div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ export function WalletFiatSelection({
</Container>
<Container flex="column" gap="3xs" style={{ flex: 1 }}>
<Text color="primaryText" size="sm" style={{ fontWeight: 600 }}>
Connect Another Wallet
Connect a Wallet
</Text>
<Text color="secondaryText" size="xs">
Use a different wallet to pay
Expand Down
Loading