tentative fix for evm wallet creation issue after backup restore (#3316)

David Adegoke committed Jun 8, 2026 at 23:01 UTC f462f0a2d73a66b0b5c5330e1ec5587413ea54ba
2 files changed +20 -5
lib/src/screens/wallet_connect/services/walletkit_service.dart
+5 -2
@@ -132,7 +132,10 @@ abstract class WalletKitServiceBase with Store {
132 debugPrint('Intializing walletKit');
133 if (!isInitialized) {
134 try {
135 - await _walletKit.init();
135 + await _walletKit.init().timeout(
136 + const Duration(seconds: 8),
137 + onTimeout: () => throw TimeoutException('walletKit init timed out'),
138 + );
139 debugPrint('Initialized');
140 isInitialized = true;
141 } catch (e) {
@@ -206,7 +209,7 @@ abstract class WalletKitServiceBase with Store {
209 name: 'accountsChanged',
210 data: [chain.publicKey],
211 ),
209 - );
212 + ).timeout(const Duration(seconds: 3));
213 }
214 } on ReownSignError catch (e) {
215 if (e.code == 6) {
lib/store/app_store.dart
+15 -3
@@ -1,3 +1,5 @@
1 +import 'dart:async';
2 +
3 import 'package:cake_wallet/core/amount_parsing_proxy.dart';
4 import 'package:cake_wallet/di.dart';
5 import 'package:cake_wallet/entities/preferences_key.dart';
@@ -6,6 +8,7 @@ import 'package:cake_wallet/src/screens/wallet_connect/services/walletkit_servic
8 import 'package:cake_wallet/themes/core/theme_store.dart';
9 import 'package:cake_wallet/utils/exception_handler.dart';
10 import 'package:cw_core/transaction_info.dart';
11 +import 'package:cw_core/utils/print_verbose.dart';
12 import 'package:cw_core/wallet_type.dart';
13 import 'package:mobx/mobx.dart';
14 import 'package:cw_core/balance.dart';
@@ -63,13 +66,22 @@ abstract class AppStoreBase with Store {
66 this.wallet!.setExceptionHandler(ExceptionHandler.onError);
67
68 if (isWalletConnectCompatibleChain(wallet.type)) {
66 - await getIt.get<WalletKitService>().onDispose();
67 - getIt.get<WalletKitService>().create();
68 - await getIt.get<WalletKitService>().init();
69 + unawaited(_setupWalletConnect());
70 }
71 await getIt.get<SharedPreferences>().setString(PreferencesKey.currentWalletName, wallet.name);
72 await getIt
73 .get<SharedPreferences>()
74 .setInt(PreferencesKey.currentWalletType, serializeToInt(wallet.type));
75 }
76 +
77 + Future<void> _setupWalletConnect() async {
78 + try {
79 + final wcService = getIt.get<WalletKitService>();
80 + await wcService.onDispose();
81 + wcService.create();
82 + await wcService.init();
83 + } catch (e, s) {
84 + printV('WalletConnect setup failed: $e\n$s');
85 + }
86 + }
87 }