mirror of
https://github.com/Such-Software/hash-wallet.git
synced 2026-10-26 06:08:40 +01:00
tentative fix for evm wallet creation issue after backup restore (#3316)
This commit is contained in:
@@ -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) {
|
||||
|
||||
@@ -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');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user