dev
dart 44 lines 1.23 KB
Raw
1 import 'package:cw_core/hive_type_ids.dart';
2 import 'package:hive/hive.dart';
3
4 part 'transaction_description.part.dart';
5
6 // @HiveType(typeId: TransactionDescription.typeId)
7 class TransactionDescription extends HiveObject {
8 TransactionDescription(
9 {required this.id, this.recipientAddress, this.transactionNote, this.transactionKey});
10
11 static const typeId = TRANSACTION_TYPE_ID;
12 static const boxName = 'TransactionDescriptions';
13 static const boxKey = 'transactionDescriptionsBoxKey';
14
15 // @HiveField(0, defaultValue: '')
16 String id;
17
18 // @HiveField(1)
19 String? recipientAddress;
20
21 // @HiveField(2)
22 String? transactionNote;
23
24 // @HiveField(3)
25 String? transactionKey;
26
27 String get note => transactionNote ?? '';
28
29 Map<String, dynamic> toJson() => {
30 'id': id,
31 'recipientAddress': recipientAddress,
32 'transactionNote': transactionNote,
33 'transactionKey': transactionKey,
34 };
35
36 factory TransactionDescription.fromJson(Map<String, dynamic> json) {
37 return TransactionDescription(
38 id: json['id'] as String,
39 recipientAddress: json['recipientAddress'] as String?,
40 transactionNote: json['transactionNote'] as String?,
41 transactionKey: json['transactionKey'] as String?,
42 );
43 }
44 }