cake_wallet/lib/src/domain/common/wallet_info.dart

53 lines
1.1 KiB
Dart
Raw Normal View History

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-15 20:35:49 +00:00
import 'package:cake_wallet/src/domain/common/wallet_type.dart';
2020-01-04 19:31:52 +00:00
part 'wallet_info.g.dart';
2020-05-26 15:27:10 +00:00
@HiveType(typeId: 4)
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,
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);
}
2020-01-08 12:26:34 +00:00
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;
DateTime get date => DateTime.fromMillisecondsSinceEpoch(timestamp);
2020-01-04 19:31:52 +00:00
}