Skip to content

Commit c97b1a5

Browse files
committed
Fix default "Pay with" chain (#4328)
## Problem solved When supported source chains is updated, update `fromChain` to take the first chain on the supported sources list instead of defaulting to `polygon` <!-- start pr-codex --> --- ## PR-Codex overview The focus of this PR is to update the default source chain selection in `PayEmbed`. ### Detailed summary - Updated default source chain selection logic in `BuyScreen.tsx` - Refactored the dependencies array in `useEffect` hook for better performance > ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}` <!-- end pr-codex -->
1 parent 42d5c65 commit c97b1a5

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

.changeset/wet-socks-jog.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+
Update default source chain selection in PayEmbed

packages/thirdweb/src/react/web/ui/ConnectWallet/screens/Buy/BuyScreen.tsx

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -185,12 +185,22 @@ function BuyScreenContent(props: BuyScreenContentProps) {
185185
return undefined;
186186
}
187187

188+
const supportedSources = supportedSourcesQuery.data;
189+
if (supportedSources[0]?.chain) {
190+
setFromChain(supportedSources[0]?.chain);
191+
}
192+
188193
return createSupportedTokens(
189-
supportedSourcesQuery.data,
194+
supportedSources,
190195
payOptions,
191196
props.supportedTokens,
192197
);
193-
}, [props.supportedTokens, supportedSourcesQuery.data, payOptions]);
198+
}, [
199+
props.supportedTokens,
200+
supportedSourcesQuery.data,
201+
payOptions,
202+
setFromChain,
203+
]);
194204

195205
const enabledPaymentMethods = useEnabledPaymentMethods({
196206
payOptions: props.payOptions,

0 commit comments

Comments
 (0)