Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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/light-signs-send.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"thirdweb": patch
---

Do not require connecting wallet in `BuyWidget` if `receiverAddress` is set
4 changes: 1 addition & 3 deletions packages/thirdweb/src/react/web/ui/Bridge/BuyWidget.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
import { SuccessScreen } from "./payment-success/SuccessScreen.js";
import { QuoteLoader } from "./QuoteLoader.js";
import { StepRunner } from "./StepRunner.js";
import { useActiveWalletInfo } from "./swap-widget/hooks.js";
import type { PaymentMethod, RequiredParams } from "./types.js";

export type BuyOrOnrampPrepareResult = Extract<
Expand Down Expand Up @@ -432,7 +431,6 @@
>,
) {
const [screen, setScreen] = useState<BuyWidgetScreen>({ id: "1:buy-ui" });
const activeWalletInfo = useActiveWalletInfo();

const handleError = useCallback(
(error: Error, quote: BridgePrepareResult | undefined) => {
Expand Down Expand Up @@ -478,7 +476,7 @@
};
});

if (screen.id === "1:buy-ui" || !activeWalletInfo) {
if (screen.id === "1:buy-ui") {

Check warning on line 479 in packages/thirdweb/src/react/web/ui/Bridge/BuyWidget.tsx

View check run for this annotation

Codecov / codecov/patch

packages/thirdweb/src/react/web/ui/Bridge/BuyWidget.tsx#L479

Added line #L479 was not covered by tests
return (
<FundWallet
theme={props.theme}
Expand Down
31 changes: 17 additions & 14 deletions packages/thirdweb/src/react/web/ui/Bridge/FundWallet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,9 @@
const actionLabel = isReceiverDifferentFromActiveWallet ? "Pay" : "Buy";
const isMobile = useIsMobile();

// if no receiver address is set - wallet must be connected because the user's wallet is the receiver
const showConnectButton = !props.receiverAddress && !activeWalletInfo;

Check warning on line 171 in packages/thirdweb/src/react/web/ui/Bridge/FundWallet.tsx

View check run for this annotation

Codecov / codecov/patch

packages/thirdweb/src/react/web/ui/Bridge/FundWallet.tsx#L171

Added line #L171 was not covered by tests

return (
<WithHeader
client={props.client}
Expand Down Expand Up @@ -283,7 +286,20 @@
)}

{/* Continue Button */}
{activeWalletInfo ? (
{showConnectButton ? (
<ConnectButton
client={props.client}
connectButton={{
label: props.buttonLabel || actionLabel,
style: {
width: "100%",
borderRadius: radius.full,
},
}}
theme={theme}
{...props.connectOptions}
/>

Check warning on line 301 in packages/thirdweb/src/react/web/ui/Bridge/FundWallet.tsx

View check run for this annotation

Codecov / codecov/patch

packages/thirdweb/src/react/web/ui/Bridge/FundWallet.tsx#L289-L301

Added lines #L289 - L301 were not covered by tests
) : (
<Button
disabled={!receiver}
fullWidth
Expand Down Expand Up @@ -316,19 +332,6 @@
>
{props.buttonLabel || actionLabel}
</Button>
) : (
<ConnectButton
client={props.client}
connectButton={{
label: props.buttonLabel || actionLabel,
style: {
width: "100%",
borderRadius: radius.full,
},
}}
theme={theme}
{...props.connectOptions}
/>
)}

{props.showThirdwebBranding ? (
Expand Down
Loading