2020-09-15 20:35:49 +00:00
|
|
|
import 'package:flutter/foundation.dart';
|
2020-01-04 19:31:52 +00:00
|
|
|
import 'package:hive/hive.dart';
|
2020-09-21 11:50:26 +00:00
|
|
|
import 'package:cake_wallet/entities/wallet_type.dart';
|
2020-01-04 19:31:52 +00:00
|
|
|
|
|
|
|
part 'wallet_info.g.dart';
|
|
|
|
|
2021-01-15 17:41:30 +00:00
|
|
|
@HiveType(typeId: WalletInfo.typeId)
|
2020-01-04 19:31:52 +00:00
|
|
|
class WalletInfo extends HiveObject {
|
2020-09-15 20:35:49 +00:00
|
|
|
WalletInfo(this.id, this.name, this.type, this.isRecovery, this.restoreHeight,
|
2021-01-08 18:10:37 +00:00
|
|
|
this.timestamp, this.dirPath, this.path, this.address);
|
2020-09-15 20:35:49 +00:00
|
|
|
|
|
|
|
factory WalletInfo.external(
|
|
|
|
{@required String id,
|
|
|
|
@required String name,
|
|
|
|
@required WalletType type,
|
|
|
|
@required bool isRecovery,
|
|
|
|
@required int restoreHeight,
|
|
|
|
@required DateTime date,
|
|
|
|
@required String dirPath,
|
2021-01-08 18:10:37 +00:00
|
|
|
@required String path,
|
|
|
|
@required String address}) {
|
2020-09-15 20:35:49 +00:00
|
|
|
return WalletInfo(id, name, type, isRecovery, restoreHeight,
|
2021-01-08 18:10:37 +00:00
|
|
|
date.millisecondsSinceEpoch ?? 0, dirPath, path, address);
|
2020-09-15 20:35:49 +00:00
|
|
|
}
|
2020-01-08 12:26:34 +00:00
|
|
|
|
2021-01-15 17:41:30 +00:00
|
|
|
static const typeId = 4;
|
2020-01-04 19:31:52 +00:00
|
|
|
static const boxName = 'WalletInfo';
|
2020-01-08 12:26:34 +00:00
|
|
|
|
2020-01-04 19:31:52 +00:00
|
|
|
@HiveField(0)
|
|
|
|
String id;
|
|
|
|
|
|
|
|
@HiveField(1)
|
|
|
|
String name;
|
|
|
|
|
|
|
|
@HiveField(2)
|
|
|
|
WalletType type;
|
|
|
|
|
|
|
|
@HiveField(3)
|
|
|
|
bool isRecovery;
|
|
|
|
|
|
|
|
@HiveField(4)
|
|
|
|
int restoreHeight;
|
2020-09-15 20:35:49 +00:00
|
|
|
|
|
|
|
@HiveField(5)
|
|
|
|
int timestamp;
|
|
|
|
|
|
|
|
@HiveField(6)
|
|
|
|
String dirPath;
|
|
|
|
|
|
|
|
@HiveField(7)
|
|
|
|
String path;
|
|
|
|
|
2021-01-08 18:10:37 +00:00
|
|
|
@HiveField(8)
|
|
|
|
String address;
|
|
|
|
|
2020-09-15 20:35:49 +00:00
|
|
|
DateTime get date => DateTime.fromMillisecondsSinceEpoch(timestamp);
|
2020-01-04 19:31:52 +00:00
|
|
|
}
|