cake_wallet/lib/entities/wallet_info.dart

75 lines
1.6 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, this.yatEid,
this.yatRefreshToken);
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,
String yatEid ='',
String yatRefreshToken = ''}) {
2020-09-15 20:35:49 +00:00
return WalletInfo(id, name, type, isRecovery, restoreHeight,
date.millisecondsSinceEpoch ?? 0, dirPath, path, address,
yatEid, yatRefreshToken);
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;
@HiveField(10)
Map<String, String> addresses;
@HiveField(11)
String yatEid;
@HiveField(12)
String yatRefreshToken;
String get yatEmojiId => yatEid ?? '';
String get yatToken => yatRefreshToken ?? '';
2020-09-15 20:35:49 +00:00
DateTime get date => DateTime.fromMillisecondsSinceEpoch(timestamp);
2020-01-04 19:31:52 +00:00
}