2024-05-03 08:46:41 +00:00
|
|
|
import 'dart:convert';
|
|
|
|
|
2023-08-15 00:47:25 +00:00
|
|
|
import 'package:cw_core/hive_type_ids.dart';
|
2020-01-04 19:31:52 +00:00
|
|
|
import 'package:hive/hive.dart';
|
|
|
|
|
|
|
|
part 'transaction_description.g.dart';
|
|
|
|
|
2021-01-15 17:41:30 +00:00
|
|
|
@HiveType(typeId: TransactionDescription.typeId)
|
2020-01-04 19:31:52 +00:00
|
|
|
class TransactionDescription extends HiveObject {
|
2023-05-19 06:30:47 +00:00
|
|
|
TransactionDescription(
|
|
|
|
{required this.id,
|
|
|
|
this.recipientAddress,
|
|
|
|
this.transactionNote,
|
2024-05-03 08:46:41 +00:00
|
|
|
this.historicalRatesJson});
|
2020-01-08 12:26:34 +00:00
|
|
|
|
2023-08-15 00:47:25 +00:00
|
|
|
static const typeId = TRANSACTION_TYPE_ID;
|
2020-01-04 19:31:52 +00:00
|
|
|
static const boxName = 'TransactionDescriptions';
|
2020-09-21 11:50:26 +00:00
|
|
|
static const boxKey = 'transactionDescriptionsBoxKey';
|
2020-01-04 19:31:52 +00:00
|
|
|
|
2022-11-04 19:55:21 +00:00
|
|
|
@HiveField(0, defaultValue: '')
|
2020-01-04 19:31:52 +00:00
|
|
|
String id;
|
|
|
|
|
|
|
|
@HiveField(1)
|
2022-10-12 17:09:57 +00:00
|
|
|
String? recipientAddress;
|
2020-12-22 18:42:30 +00:00
|
|
|
|
|
|
|
@HiveField(2)
|
2022-10-12 17:09:57 +00:00
|
|
|
String? transactionNote;
|
2020-12-22 18:42:30 +00:00
|
|
|
|
2023-05-19 06:30:47 +00:00
|
|
|
@HiveField(3)
|
2024-05-03 08:46:41 +00:00
|
|
|
String? historicalRatesJson;
|
2023-05-19 06:30:47 +00:00
|
|
|
|
|
|
|
|
2020-12-22 18:42:30 +00:00
|
|
|
String get note => transactionNote ?? '';
|
2023-05-19 06:30:47 +00:00
|
|
|
|
2024-05-03 08:46:41 +00:00
|
|
|
Map<String, String> get historicalRates =>
|
|
|
|
historicalRatesJson != null ? Map<String, String>.from(jsonDecode(historicalRatesJson!) as Map<dynamic, dynamic>) : {};
|
|
|
|
|
|
|
|
set historicalRates(Map<String, String> value) {
|
|
|
|
historicalRatesJson = jsonEncode(value);
|
|
|
|
}
|
2020-01-08 12:26:34 +00:00
|
|
|
}
|