cake_wallet/lib/entities/wallet_info.dart

58 lines
1.3 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-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,
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,
@required String path,
@required String address}) {
2020-09-15 20:35:49 +00:00
return WalletInfo(id, name, type, isRecovery, restoreHeight,
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;
@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
}