Skip to content

Commit d907017

Browse files
committed
[MNY-295] Fix BuyWidget autoconnect not working when receiverAddress prop is set (#8363)
<!-- ## title your PR with this format: "[SDK/Dashboard/Portal] Feature/Fix: Concise title for the changes" If you did not copy the branch name from Linear, paste the issue tag here (format is TEAM-0000): ## Notes for the reviewer Anything important to call out? Be sure to also clarify these in your comments. ## How to test Unit tests, playground, etc. --> <!-- start pr-codex --> --- ## PR-Codex overview This PR focuses on fixing the `BuyWidget` component's autoconnect functionality when the `receiverAddress` prop is set, and it introduces a new story variant to demonstrate this behavior. ### Detailed summary - Updated `BuyWidget` to conditionally render the `AutoConnect` component based on `connectOptions.autoConnect`. - Introduced a new story `NoAutoConnect` in `BuyWidget.stories.tsx` to showcase the widget with `autoConnect` set to false. - Modified `FundWallet.tsx` to ensure proper handling of the `autoConnect` prop. > ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}` <!-- end pr-codex --> <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit ## Release Notes * **Bug Fixes** * Fixed auto-connect functionality that was not working correctly when the receiver address property is set on the buy widget. * **New Features** * Added configurable auto-connect option to the buy widget, enabling users to control whether auto-connection is enabled or disabled based on their needs. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
1 parent cf53c2d commit d907017

File tree

4 files changed

+36
-0
lines changed

4 files changed

+36
-0
lines changed

.changeset/bumpy-shoes-flow.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+
Fix BuyWidget autoconnect not working when receiverAddress prop is set

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

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import type {
2525
import type { CompletedStatusResult } from "../../../core/hooks/useStepExecutor.js";
2626
import type { SupportedTokens } from "../../../core/utils/defaultTokens.js";
2727
import { webWindowAdapter } from "../../adapters/WindowAdapter.js";
28+
import { AutoConnect } from "../AutoConnect/AutoConnect.js";
2829
import connectLocaleEn from "../ConnectWallet/locale/en.js";
2930
import { EmbedContainer } from "../ConnectWallet/Modal/ConnectEmbed.js";
3031
import { DynamicHeight } from "../components/DynamicHeight.js";
@@ -359,6 +360,21 @@ export function BuyWidget(props: BuyWidgetProps) {
359360
className={props.className}
360361
style={props.style}
361362
>
363+
{props.connectOptions?.autoConnect !== false && (
364+
<AutoConnect
365+
client={props.client}
366+
wallets={props.connectOptions?.wallets}
367+
timeout={
368+
typeof props.connectOptions?.autoConnect === "object"
369+
? props.connectOptions?.autoConnect?.timeout
370+
: undefined
371+
}
372+
appMetadata={props.connectOptions?.appMetadata}
373+
accountAbstraction={props.connectOptions?.accountAbstraction}
374+
chain={props.connectOptions?.chain}
375+
/>
376+
)}
377+
362378
<BridgeWidgetContent
363379
{...props}
364380
theme={props.theme || "dark"}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,7 @@ export function FundWallet(props: FundWalletProps) {
298298
}}
299299
theme={theme}
300300
{...props.connectOptions}
301+
autoConnect={false}
301302
/>
302303
) : (
303304
<Button

packages/thirdweb/src/stories/BuyWidget.stories.tsx

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,20 @@ export function LargeAmount() {
138138
);
139139
}
140140

141+
export function NoAutoConnect() {
142+
return (
143+
<Variant
144+
client={storyClient}
145+
chain={ethereum}
146+
tokenAddress="0x1f9840a85d5aF5bf1D1762F925BDADdC4201F984"
147+
amount="150000"
148+
connectOptions={{
149+
autoConnect: false,
150+
}}
151+
/>
152+
);
153+
}
154+
141155
function Variant(props: BuyWidgetProps) {
142156
return (
143157
<div

0 commit comments

Comments
 (0)