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/fine-bobcats-rhyme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"thirdweb": patch
---

Fix Select Token UI stuck in loading state if wallet is connected to a chain that is not supported by thirdweb Bridge in BuyWidget, SwapWidget and BridgeWidget
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,11 @@
activeWalletInfo: ActiveWalletInfo | undefined;
};

function getDefaultSelectedChain(
chains: BridgeChain[],
activeChainId: number | undefined,
) {
return chains.find((chain) => chain.chainId === (activeChainId || 1));
function findChain(chains: BridgeChain[], activeChainId: number | undefined) {
if (!activeChainId) {
return undefined;
}
return chains.find((chain) => chain.chainId === activeChainId);

Check warning on line 52 in packages/thirdweb/src/react/web/ui/Bridge/swap-widget/select-token-ui.tsx

View check run for this annotation

Codecov / codecov/patch

packages/thirdweb/src/react/web/ui/Bridge/swap-widget/select-token-ui.tsx#L48-L52

Added lines #L48 - L52 were not covered by tests
}

/**
Expand All @@ -67,11 +67,9 @@
const selectedChain =
_selectedChain ||
(chainQuery.data
? getDefaultSelectedChain(
chainQuery.data,
props.selectedToken?.chainId ||
props.activeWalletInfo?.activeChain.id,
)
? findChain(chainQuery.data, props.selectedToken?.chainId) ||
findChain(chainQuery.data, props.activeWalletInfo?.activeChain.id) ||
findChain(chainQuery.data, 1)

Check warning on line 72 in packages/thirdweb/src/react/web/ui/Bridge/swap-widget/select-token-ui.tsx

View check run for this annotation

Codecov / codecov/patch

packages/thirdweb/src/react/web/ui/Bridge/swap-widget/select-token-ui.tsx#L70-L72

Added lines #L70 - L72 were not covered by tests
: undefined);

// all tokens
Expand Down
Loading