Skip to content

Commit 11e7b27

Browse files
committed
always add a call for adding a chain when its walletconnect
1 parent 20b1965 commit 11e7b27

2 files changed

Lines changed: 8 additions & 1 deletion

File tree

packages/checkout/sdk/src/network/network.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,13 @@ export async function switchWalletNetwork(
165165
);
166166
}
167167

168+
// walletconnect on trying to switch network, if network doesn't exist, it does not throw an error!
169+
// so the catch block below is not triggered, so we need to add the network manually
170+
// always calling addNetworkToWallet is harmless, as nothing happens if the network already exists
171+
if (provider.ethereumProvider?.isWalletConnect) {
172+
await addNetworkToWallet(networkMap, provider, chainId);
173+
}
174+
168175
// WT-1146 - Refer to the README in this folder for explanation on the switch network flow
169176
try {
170177
await switchNetworkInWallet(networkMap, provider, chainId);

packages/checkout/widgets-lib/src/widgets/connect/components/WalletList.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ export function WalletList(props: WalletListProps) {
215215

216216
const connectCallback = async (ethereumProvider: EthereumProvider) => {
217217
if (ethereumProvider.connected && ethereumProvider.session) {
218-
const browserProvider = new WrappedBrowserProvider(ethereumProvider, 'any');
218+
const browserProvider = new WrappedBrowserProvider(ethereumProvider);
219219
selectBrowserProvider(browserProvider, 'walletconnect');
220220

221221
if (ethereumProvider.chainId !== targetChainId) {

0 commit comments

Comments
 (0)