diff --git a/packages/checkout/sdk/src/network/network.ts b/packages/checkout/sdk/src/network/network.ts index 1a5586f616..b36f8d7139 100644 --- a/packages/checkout/sdk/src/network/network.ts +++ b/packages/checkout/sdk/src/network/network.ts @@ -165,6 +165,13 @@ export async function switchWalletNetwork( ); } + // walletconnect on trying to switch network, if network doesn't exist, it does not throw an error! + // so the catch block below is not triggered, so we need to add the network manually + // always calling addNetworkToWallet is harmless, as nothing happens if the network already exists + if (provider.ethereumProvider?.isWalletConnect) { + await addNetworkToWallet(networkMap, provider, chainId); + } + // WT-1146 - Refer to the README in this folder for explanation on the switch network flow try { await switchNetworkInWallet(networkMap, provider, chainId); diff --git a/packages/checkout/widgets-lib/src/widgets/connect/components/WalletList.tsx b/packages/checkout/widgets-lib/src/widgets/connect/components/WalletList.tsx index 8e5c15df58..300eb51b9f 100644 --- a/packages/checkout/widgets-lib/src/widgets/connect/components/WalletList.tsx +++ b/packages/checkout/widgets-lib/src/widgets/connect/components/WalletList.tsx @@ -218,20 +218,14 @@ export function WalletList(props: WalletListProps) { const browserProvider = new WrappedBrowserProvider(ethereumProvider); selectBrowserProvider(browserProvider, 'walletconnect'); - const { chainId } = await ((await browserProvider.getSigner()).provider.getNetwork()); - if (ethereumProvider.chainId !== targetChainId) { - // @ts-ignore allow protected method `switchEthereumChain` to be called - await ethereumProvider.switchEthereumChain(targetChainId); - } - - if (chainId as unknown as ChainId !== targetChainId) { viewDispatch({ payload: { type: ViewActions.UPDATE_VIEW, view: { type: ConnectWidgetViews.SWITCH_NETWORK }, }, }); + return; } viewDispatch({ diff --git a/packages/checkout/widgets-sample-app/src/components/ui/checkout/checkout.tsx b/packages/checkout/widgets-sample-app/src/components/ui/checkout/checkout.tsx index bd74914112..666c62cfea 100644 --- a/packages/checkout/widgets-sample-app/src/components/ui/checkout/checkout.tsx +++ b/packages/checkout/widgets-sample-app/src/components/ui/checkout/checkout.tsx @@ -238,7 +238,15 @@ function CheckoutUI() { // setup widgets factory // ignore language or theme changes const widgetsFactory = useAsyncMemo( - async () => new WidgetsFactory(checkoutSdk, { theme, language }), + async () => new WidgetsFactory(checkoutSdk, { theme, language, walletConnect: { + projectId: "938b553484e344b1e0b4bb80edf8c362", + metadata: { + url: 'http://localhost:3000/checkout', + name: 'Widgets Sample App', + description: 'Checkout', + icons: [], + }, + } }), [checkoutSdk] );