Skip to content

Commit 44a7460

Browse files
authored
[SDK] Feature: Remove Switch Network button (#7191)
1 parent 0731831 commit 44a7460

File tree

2 files changed

+8
-16
lines changed

2 files changed

+8
-16
lines changed

.changeset/tricky-points-tease.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+
Remove unnecessary Switch Network button in PayEmbed

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

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ import {
2121
} from "../../../../components/Drawer.js";
2222
import { Spacer } from "../../../../components/Spacer.js";
2323
import { Spinner } from "../../../../components/Spinner.js";
24-
import { SwitchNetworkButton } from "../../../../components/SwitchNetwork.js";
2524
import { Container } from "../../../../components/basic.js";
2625
import { Button } from "../../../../components/buttons.js";
2726
import { Text } from "../../../../components/text.js";
@@ -171,8 +170,6 @@ export function SwapScreenContent(props: {
171170
(swapRequired && !quoteQuery.data) ||
172171
isNotEnoughBalance ||
173172
allowanceQuery.isLoading;
174-
const switchChainRequired =
175-
props.payer.wallet.getChain()?.id !== fromChain?.id;
176173

177174
const errorMsg =
178175
!quoteQuery.isLoading && quoteQuery.error
@@ -319,19 +316,6 @@ export function SwapScreenContent(props: {
319316
>
320317
Pay with another token
321318
</Button>
322-
) : switchChainRequired &&
323-
fromChain &&
324-
!quoteQuery.isLoading &&
325-
!allowanceQuery.isLoading &&
326-
!isNotEnoughBalance &&
327-
!quoteQuery.error ? (
328-
<SwitchNetworkButton
329-
variant="accent"
330-
fullWidth
331-
switchChain={async () => {
332-
await props.payer.wallet.switchChain(fromChain);
333-
}}
334-
/>
335319
) : (
336320
<Button
337321
variant={disableContinue ? "outline" : "accent"}
@@ -340,6 +324,9 @@ export function SwapScreenContent(props: {
340324
disabled={disableContinue}
341325
onClick={async () => {
342326
if (!disableContinue) {
327+
if (props.payer.wallet.getChain()?.id !== fromChain?.id) {
328+
await props.payer.wallet.switchChain(fromChain);
329+
}
343330
showSwapFlow();
344331
trackPayEvent({
345332
event: "confirm_swap_quote",

0 commit comments

Comments
 (0)