mirror of
https://github.com/Such-Software/hash-wallet.git
synced 2026-10-20 06:08:34 +02:00
Merge redesign part 7.
This commit is contained in:
@@ -82,28 +82,28 @@ Future<void> migrate_wallets({Directory appDocDir}) async {
|
||||
Future<void> migrate_ios_wallet_info(
|
||||
{@required Directory appDocDir,
|
||||
@required Box<WalletInfo> walletsInfo}) async {
|
||||
final walletsDir = Directory('${appDocDir.path}/wallets');
|
||||
final moneroWalletsDir = Directory('${walletsDir.path}/monero');
|
||||
// final walletsDir = Directory('${appDocDir.path}/wallets');
|
||||
// final moneroWalletsDir = Directory('${walletsDir.path}/monero');
|
||||
|
||||
moneroWalletsDir.listSync().forEach((item) async {
|
||||
try {
|
||||
if (item is Directory) {
|
||||
final name = item.path.split('/').last;
|
||||
final configFile = File('${item.path}/$name.json');
|
||||
final config =
|
||||
json.decode(configFile.readAsStringSync()) as Map<String, dynamic>;
|
||||
final isRecovery = config["isRecovery"] as bool ?? false;
|
||||
final id =
|
||||
walletTypeToString(WalletType.monero).toLowerCase() + '_' + name;
|
||||
final walletInfo =
|
||||
WalletInfo(id: id, name: name, isRecovery: isRecovery);
|
||||
// moneroWalletsDir.listSync().forEach((item) async {
|
||||
// try {
|
||||
// if (item is Directory) {
|
||||
// final name = item.path.split('/').last;
|
||||
// final configFile = File('${item.path}/$name.json');
|
||||
// final config =
|
||||
// json.decode(configFile.readAsStringSync()) as Map<String, dynamic>;
|
||||
// final isRecovery = config["isRecovery"] as bool ?? false;
|
||||
// final id =
|
||||
// walletTypeToString(WalletType.monero).toLowerCase() + '_' + name;
|
||||
// final walletInfo =
|
||||
// WalletInfo(id: id, name: name, isRecovery: isRecovery);
|
||||
|
||||
await walletsInfo.add(walletInfo);
|
||||
}
|
||||
} catch (e) {
|
||||
print(e.toString());
|
||||
}
|
||||
});
|
||||
// await walletsInfo.add(walletInfo);
|
||||
// }
|
||||
// } catch (e) {
|
||||
// print(e.toString());
|
||||
// }
|
||||
// });
|
||||
}
|
||||
|
||||
Future<void> migrate_ios_trades_list(
|
||||
|
||||
@@ -1,12 +1,26 @@
|
||||
import 'package:cake_wallet/src/domain/common/wallet_type.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:hive/hive.dart';
|
||||
import 'package:cake_wallet/src/domain/common/wallet_type.dart';
|
||||
|
||||
part 'wallet_info.g.dart';
|
||||
|
||||
@HiveType(typeId: 4)
|
||||
class WalletInfo extends HiveObject {
|
||||
WalletInfo(
|
||||
{this.id, this.name, this.type, this.isRecovery, this.restoreHeight});
|
||||
WalletInfo(this.id, this.name, this.type, this.isRecovery, this.restoreHeight,
|
||||
this.timestamp, this.dirPath, this.path);
|
||||
|
||||
factory WalletInfo.external(
|
||||
{@required String id,
|
||||
@required String name,
|
||||
@required WalletType type,
|
||||
@required bool isRecovery,
|
||||
@required int restoreHeight,
|
||||
@required DateTime date,
|
||||
@required String dirPath,
|
||||
@required String path}) {
|
||||
return WalletInfo(id, name, type, isRecovery, restoreHeight,
|
||||
date.millisecondsSinceEpoch ?? 0, dirPath, path);
|
||||
}
|
||||
|
||||
static const boxName = 'WalletInfo';
|
||||
|
||||
@@ -24,4 +38,15 @@ class WalletInfo extends HiveObject {
|
||||
|
||||
@HiveField(4)
|
||||
int restoreHeight;
|
||||
|
||||
@HiveField(5)
|
||||
int timestamp;
|
||||
|
||||
@HiveField(6)
|
||||
String dirPath;
|
||||
|
||||
@HiveField(7)
|
||||
String path;
|
||||
|
||||
DateTime get date => DateTime.fromMillisecondsSinceEpoch(timestamp);
|
||||
}
|
||||
|
||||
@@ -47,18 +47,19 @@ class MoneroWallet extends Wallet {
|
||||
String name,
|
||||
bool isRecovery = false,
|
||||
int restoreHeight = 0}) async {
|
||||
const type = WalletType.monero;
|
||||
final id = walletTypeToString(type).toLowerCase() + '_' + name;
|
||||
final walletInfo = WalletInfo(
|
||||
id: id,
|
||||
name: name,
|
||||
type: type,
|
||||
isRecovery: isRecovery,
|
||||
restoreHeight: restoreHeight);
|
||||
await walletInfoSource.add(walletInfo);
|
||||
// const type = WalletType.monero;
|
||||
// final id = walletTypeToString(type).toLowerCase() + '_' + name;
|
||||
// final walletInfo = WalletInfo(
|
||||
// id: id,
|
||||
// name: name,
|
||||
// type: type,
|
||||
// isRecovery: isRecovery,
|
||||
// restoreHeight: restoreHeight);
|
||||
// await walletInfoSource.add(walletInfo);
|
||||
|
||||
return await configured(
|
||||
walletInfo: walletInfo, walletInfoSource: walletInfoSource);
|
||||
// return await configured(
|
||||
// walletInfo: walletInfo, walletInfoSource: walletInfoSource);
|
||||
return null;
|
||||
}
|
||||
|
||||
static Future<MoneroWallet> load(
|
||||
|
||||
@@ -12,8 +12,6 @@ import 'package:cake_wallet/src/domain/common/wallet.dart';
|
||||
import 'package:cake_wallet/src/domain/monero/monero_wallet.dart';
|
||||
import 'package:cake_wallet/src/domain/common/wallet_description.dart';
|
||||
|
||||
|
||||
|
||||
class MoneroWalletsManager extends WalletsManager {
|
||||
MoneroWalletsManager({@required this.walletInfoSource});
|
||||
|
||||
@@ -27,7 +25,8 @@ class MoneroWalletsManager extends WalletsManager {
|
||||
const isRecovery = false;
|
||||
final path = await pathForWallet(name: name, type: WalletType.monero);
|
||||
|
||||
await monero_wallet_manager.createWallet(path: path, password: password, language: language);
|
||||
await monero_wallet_manager.createWallet(
|
||||
path: path, password: password, language: language);
|
||||
|
||||
final wallet = await MoneroWallet.createdWallet(
|
||||
walletInfoSource: walletInfoSource,
|
||||
|
||||
@@ -65,18 +65,18 @@ void onSyncStatusChange(
|
||||
{SyncStore syncStore,
|
||||
WalletStore walletStore,
|
||||
SettingsStore settingsStore}) {
|
||||
_onSyncStatusChangeDisposer?.call();
|
||||
// _onSyncStatusChangeDisposer?.call();
|
||||
|
||||
reaction((_) => syncStore.status, (SyncStatus status) async {
|
||||
if (status is ConnectedSyncStatus) {
|
||||
await walletStore.startSync();
|
||||
}
|
||||
// reaction((_) => syncStore.status, (SyncStatus status) async {
|
||||
// if (status is ConnectedSyncStatus) {
|
||||
// await walletStore.startSync();
|
||||
// }
|
||||
|
||||
// Reconnect to the node if the app is not started sync after 30 seconds
|
||||
if (status is StartingSyncStatus) {
|
||||
startReconnectionObserver(syncStore: syncStore, walletStore: walletStore);
|
||||
}
|
||||
});
|
||||
// // Reconnect to the node if the app is not started sync after 30 seconds
|
||||
// if (status is StartingSyncStatus) {
|
||||
// startReconnectionObserver(syncStore: syncStore, walletStore: walletStore);
|
||||
// }
|
||||
// });
|
||||
}
|
||||
|
||||
void startReconnectionObserver({SyncStore syncStore, WalletStore walletStore}) {
|
||||
|
||||
Reference in New Issue
Block a user