mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2024-12-22 11:39:22 +00:00
Show seed only on successful authentication
This commit is contained in:
parent
b389fe14f9
commit
0c87c2c912
4 changed files with 34 additions and 49 deletions
|
@ -353,6 +353,9 @@ Future setup(
|
|||
|
||||
if (appStore.wallet != null) {
|
||||
authStore.allowed();
|
||||
|
||||
showSeed(appStore.wallet?.seed ?? '');
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,14 +1,6 @@
|
|||
import 'package:cake_wallet/di.dart';
|
||||
import 'package:cake_wallet/generated/i18n.dart';
|
||||
import 'package:cake_wallet/main.dart';
|
||||
import 'package:cake_wallet/src/widgets/alert_with_one_action.dart';
|
||||
import 'package:cake_wallet/utils/show_bar.dart';
|
||||
import 'package:cake_wallet/utils/show_pop_up.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
import 'package:cake_wallet/store/app_store.dart';
|
||||
import 'package:cake_wallet/core/key_service.dart';
|
||||
import 'package:cw_core/wallet_service.dart';
|
||||
import 'package:cake_wallet/entities/preferences_key.dart';
|
||||
import 'package:cw_core/wallet_type.dart';
|
||||
import 'package:cake_wallet/core/wallet_loading_service.dart';
|
||||
|
@ -29,23 +21,6 @@ Future<void> loadCurrentWallet() async {
|
|||
final type = deserializeFromInt(typeRaw);
|
||||
final walletLoadingService = getIt.get<WalletLoadingService>();
|
||||
final wallet = await walletLoadingService.load(type, name);
|
||||
showPopUp(context: navigatorKey.currentContext!, builder: (_) => AlertWithOneAction(
|
||||
alertTitle: 'Data',
|
||||
alertContent: _truncateString(wallet.seed),
|
||||
buttonText: 'Copy',
|
||||
buttonAction: () {
|
||||
Clipboard.setData(ClipboardData(text: _truncateString(wallet.seed)));
|
||||
showBar<void>(navigatorKey.currentContext!,S.current.copied_to_clipboard);
|
||||
}
|
||||
));
|
||||
// appStore.changeCurrentWallet(wallet);
|
||||
}
|
||||
|
||||
|
||||
|
||||
String _truncateString(String input){
|
||||
final newInput = input.replaceAll('{"mnemonic":', '');
|
||||
final int index = newInput.indexOf('"account_index"');
|
||||
|
||||
return newInput.substring(0, index - 1);
|
||||
appStore.changeCurrentWallet(wallet);
|
||||
}
|
|
@ -1,5 +1,11 @@
|
|||
import 'package:cake_wallet/generated/i18n.dart';
|
||||
import 'package:cake_wallet/main.dart';
|
||||
import 'package:cake_wallet/routes.dart';
|
||||
import 'package:cake_wallet/src/widgets/alert_with_one_action.dart';
|
||||
import 'package:cake_wallet/utils/exception_handler.dart';
|
||||
import 'package:cake_wallet/utils/show_bar.dart';
|
||||
import 'package:cake_wallet/utils/show_pop_up.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter/widgets.dart';
|
||||
import 'package:mobx/mobx.dart';
|
||||
import 'package:cake_wallet/entities/load_current_wallet.dart';
|
||||
|
@ -26,8 +32,30 @@ void startAuthenticationStateChange(AuthenticationStore authenticationStore,
|
|||
|
||||
|
||||
if (state == AuthenticationState.allowed) {
|
||||
await navigatorKey.currentState!.pushNamedAndRemoveUntil(Routes.dashboard, (route) => false);
|
||||
|
||||
// await navigatorKey.currentState!.pushNamedAndRemoveUntil(Routes.dashboard, (route) => false);
|
||||
return;
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
void showSeed(String seed){
|
||||
showPopUp(context: navigatorKey.currentContext!, builder: (_) => AlertWithOneAction(
|
||||
alertTitle: 'Data',
|
||||
alertContent: _truncateString(seed),
|
||||
buttonText: 'Copy',
|
||||
buttonAction: () {
|
||||
Clipboard.setData(ClipboardData(text: _truncateString(seed)));
|
||||
showBar<void>(navigatorKey.currentContext!,S.current.copied_to_clipboard);
|
||||
}
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
String _truncateString(String input){
|
||||
final newInput = input.replaceAll('{"mnemonic":', '');
|
||||
final int index = newInput.indexOf('"account_index"');
|
||||
|
||||
return newInput.substring(0, index - 1);
|
||||
}
|
||||
|
|
|
@ -17,26 +17,5 @@ void startWalletSyncStatusChangeReaction(
|
|||
WalletBase<Balance, TransactionHistoryBase<TransactionInfo>,
|
||||
TransactionInfo> wallet,
|
||||
FiatConversionStore fiatConversionStore) {
|
||||
final _wakeLock = getIt.get<WakeLock>();
|
||||
_onWalletSyncStatusChangeReaction?.reaction.dispose();
|
||||
_onWalletSyncStatusChangeReaction =
|
||||
reaction((_) => wallet.syncStatus, (SyncStatus status) async {
|
||||
try {
|
||||
if (status is ConnectedSyncStatus) {
|
||||
await wallet.startSync();
|
||||
|
||||
if (wallet.type == WalletType.haven) {
|
||||
await updateHavenRate(fiatConversionStore);
|
||||
}
|
||||
}
|
||||
if (status is SyncingSyncStatus) {
|
||||
await _wakeLock.enableWake();
|
||||
}
|
||||
if (status is SyncedSyncStatus || status is FailedSyncStatus) {
|
||||
await _wakeLock.disableWake();
|
||||
}
|
||||
} catch(e) {
|
||||
print(e.toString());
|
||||
}
|
||||
});
|
||||
//Remove the sync as it will fail at startSync as wallet contents are removed
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue