mirror of
https://github.com/Such-Software/hash-wallet.git
synced 2026-11-21 10:24:15 +01: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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user