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

This commit is contained in:
David Adegoke
2026-06-09 00:01:44 +02:00
committed by GitHub
parent 879eb9193c
commit f462f0a2d7
2 changed files with 20 additions and 5 deletions
@@ -132,7 +132,10 @@ abstract class WalletKitServiceBase with Store {
debugPrint('Intializing walletKit');
if (!isInitialized) {
try {
await _walletKit.init();
await _walletKit.init().timeout(
const Duration(seconds: 8),
onTimeout: () => throw TimeoutException('walletKit init timed out'),
);
debugPrint('Initialized');
isInitialized = true;
} catch (e) {
@@ -206,7 +209,7 @@ abstract class WalletKitServiceBase with Store {
name: 'accountsChanged',
data: [chain.publicKey],
),
);
).timeout(const Duration(seconds: 3));
}
} on ReownSignError catch (e) {
if (e.code == 6) {
+15 -3
View File
@@ -1,3 +1,5 @@
import 'dart:async';
import 'package:cake_wallet/core/amount_parsing_proxy.dart';
import 'package:cake_wallet/di.dart';
import 'package:cake_wallet/entities/preferences_key.dart';
@@ -6,6 +8,7 @@ import 'package:cake_wallet/src/screens/wallet_connect/services/walletkit_servic
import 'package:cake_wallet/themes/core/theme_store.dart';
import 'package:cake_wallet/utils/exception_handler.dart';
import 'package:cw_core/transaction_info.dart';
import 'package:cw_core/utils/print_verbose.dart';
import 'package:cw_core/wallet_type.dart';
import 'package:mobx/mobx.dart';
import 'package:cw_core/balance.dart';
@@ -63,13 +66,22 @@ abstract class AppStoreBase with Store {
this.wallet!.setExceptionHandler(ExceptionHandler.onError);
if (isWalletConnectCompatibleChain(wallet.type)) {
await getIt.get<WalletKitService>().onDispose();
getIt.get<WalletKitService>().create();
await getIt.get<WalletKitService>().init();
unawaited(_setupWalletConnect());
}
await getIt.get<SharedPreferences>().setString(PreferencesKey.currentWalletName, wallet.name);
await getIt
.get<SharedPreferences>()
.setInt(PreferencesKey.currentWalletType, serializeToInt(wallet.type));
}
Future<void> _setupWalletConnect() async {
try {
final wcService = getIt.get<WalletKitService>();
await wcService.onDispose();
wcService.create();
await wcService.init();
} catch (e, s) {
printV('WalletConnect setup failed: $e\n$s');
}
}
}