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 -->
This commit is contained in:
edwardysun
2024-08-30 08:03:15 +00:00
parent 42d5c65e49
commit c97b1a5d7e
2 changed files with 17 additions and 2 deletions
+5
View File
@@ -0,0 +1,5 @@
---
"thirdweb": patch
---
Update default source chain selection in PayEmbed
@@ -185,12 +185,22 @@ function BuyScreenContent(props: BuyScreenContentProps) {
return undefined;
}
const supportedSources = supportedSourcesQuery.data;
if (supportedSources[0]?.chain) {
setFromChain(supportedSources[0]?.chain);
}
return createSupportedTokens(
supportedSourcesQuery.data,
supportedSources,
payOptions,
props.supportedTokens,
);
}, [props.supportedTokens, supportedSourcesQuery.data, payOptions]);
}, [
props.supportedTokens,
supportedSourcesQuery.data,
payOptions,
setFromChain,
]);
const enabledPaymentMethods = useEnabledPaymentMethods({
payOptions: props.payOptions,