gecko/lib/models/wallet_data.dart

108 lines
1.7 KiB
Dart
Raw Normal View History

import 'package:hive_flutter/hive_flutter.dart';
2021-11-14 19:21:20 +01:00
part 'wallet_data.g.dart';
@HiveType(typeId: 0)
class WalletData extends HiveObject {
@HiveField(0)
String address;
@HiveField(1)
int? chest;
@HiveField(2)
int? number;
@HiveField(3)
String? name;
@HiveField(4)
int? derivation;
2021-11-17 06:20:23 +01:00
@HiveField(5)
String? imageDefaultPath;
@HiveField(6)
String? imageCustomPath;
2022-05-24 16:51:40 +02:00
@HiveField(7)
bool isOwned;
@HiveField(8)
IdtyStatus identityStatus;
@HiveField(9)
double balance;
@HiveField(10)
List<int>? certs;
WalletData({
required this.address,
this.chest,
this.number,
this.name,
this.derivation,
this.imageDefaultPath,
this.imageCustomPath,
this.isOwned = false,
this.identityStatus = IdtyStatus.unknown,
this.balance = 0,
this.certs,
});
// representation of WalletData when debugging
@override
String toString() {
2021-12-23 12:36:09 +01:00
return name!;
}
// creates the ':'-separated string from the WalletData
String inLine() {
return "$chest:$number:$name:$derivation:$imageDefaultPath";
}
2023-11-19 21:53:36 +01:00
bool hasIdentity() {
return identityStatus == IdtyStatus.created ||
identityStatus == IdtyStatus.confirmed ||
identityStatus == IdtyStatus.validated;
}
bool isMembre() {
return identityStatus == IdtyStatus.validated;
}
bool exist() {
return balance != 0;
}
bool hasCustomImage() {
return imageCustomPath != null;
}
// returns only the id part of the ':'-separated string
2021-12-23 12:36:09 +01:00
List<int?> id() {
2021-11-14 19:21:20 +01:00
return [chest, number];
}
}
@HiveType(typeId: 5)
enum IdtyStatus {
@HiveField(0)
none,
@HiveField(1)
created,
@HiveField(2)
confirmed,
@HiveField(3)
validated,
@HiveField(4)
expired,
@HiveField(5)
unknown
}