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

Dont attempt chain switching for cb wallet if already connected to the right chain
10 changes: 10 additions & 0 deletions packages/thirdweb/src/wallets/coinbase/coinbase-web.ts
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,16 @@
provider: ProviderInterface,
chain: Chain,
) {
// check if chain is already connected
const connectedChainId = (await provider.request({
method: "eth_chainId",
})) as string | number;
const connectedChain = getCachedChain(normalizeChainId(connectedChainId));
if (connectedChain?.id === chain.id) {

Check warning on line 482 in packages/thirdweb/src/wallets/coinbase/coinbase-web.ts

View check run for this annotation

Codecov / codecov/patch

packages/thirdweb/src/wallets/coinbase/coinbase-web.ts#L478-L482

Added lines #L478 - L482 were not covered by tests
// chain is already connected, no need to switch
return;
}

Check warning on line 485 in packages/thirdweb/src/wallets/coinbase/coinbase-web.ts

View check run for this annotation

Codecov / codecov/patch

packages/thirdweb/src/wallets/coinbase/coinbase-web.ts#L484-L485

Added lines #L484 - L485 were not covered by tests

const chainIdHex = numberToHex(chain.id);

try {
Expand Down
Loading