Skip to content

Commit 20b1965

Browse files
committed
show switch network screen for walletconnect if on incorrect network
1 parent 29ec917 commit 20b1965

2 files changed

Lines changed: 11 additions & 9 deletions

File tree

  • packages/checkout

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

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -215,23 +215,17 @@ export function WalletList(props: WalletListProps) {
215215

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

221-
const { chainId } = await ((await browserProvider.getSigner()).provider.getNetwork());
222-
223221
if (ethereumProvider.chainId !== targetChainId) {
224-
// @ts-ignore allow protected method `switchEthereumChain` to be called
225-
await ethereumProvider.switchEthereumChain(targetChainId);
226-
}
227-
228-
if (chainId as unknown as ChainId !== targetChainId) {
229222
viewDispatch({
230223
payload: {
231224
type: ViewActions.UPDATE_VIEW,
232225
view: { type: ConnectWidgetViews.SWITCH_NETWORK },
233226
},
234227
});
228+
return;
235229
}
236230

237231
viewDispatch({

packages/checkout/widgets-sample-app/src/components/ui/checkout/checkout.tsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,15 @@ function CheckoutUI() {
238238
// setup widgets factory
239239
// ignore language or theme changes
240240
const widgetsFactory = useAsyncMemo(
241-
async () => new WidgetsFactory(checkoutSdk, { theme, language }),
241+
async () => new WidgetsFactory(checkoutSdk, { theme, language, walletConnect: {
242+
projectId: "938b553484e344b1e0b4bb80edf8c362",
243+
metadata: {
244+
url: 'http://localhost:3000/checkout',
245+
name: 'Widgets Sample App',
246+
description: 'Checkout',
247+
icons: [],
248+
},
249+
} }),
242250
[checkoutSdk]
243251
);
244252

0 commit comments

Comments
 (0)