Update hive types: UnspentCoinsInfo, Template, ExchangeTemplate. (#583)
mkyq committed
Nov 1, 2022 at 17:43 UTC
b182c26ff2ed6cb97a0f7ec0843459ce6b1ed952
6 files changed
+76
-46
cw_bitcoin/lib/electrum_wallet.dart
+1
-1
@@ -495,7 +495,7 @@ abstract class ElectrumWalletBase extends WalletBase<ElectrumBalance,
495
hash: coin.hash,
496
isFrozen: coin.isFrozen,
497
isSending: coin.isSending,
498
- note: coin.note
498
+ noteRaw: coin.note
499
);
500
501
await unspentCoinsInfo.add(newInfo);
cw_core/lib/unspent_coins_info.dart
+6
-2
@@ -9,7 +9,7 @@ class UnspentCoinsInfo extends HiveObject {
9
required this.hash,
10
required this.isFrozen,
11
required this.isSending,
12
- required this.note});
12
+ required this.noteRaw});
13
14
static const typeId = 9;
15
static const boxName = 'Unspent';
@@ -28,5 +28,9 @@ class UnspentCoinsInfo extends HiveObject {
28
bool isSending;
29
30
@HiveField(4)
31
- String note;
31
+ String? noteRaw;
32
+
33
+ String get note => noteRaw ?? '';
34
+
35
+ set note(String value) => noteRaw = value;
36
}
\ No newline at end of file
lib/entities/template.dart
+28
-14
@@ -5,36 +5,50 @@ part 'template.g.dart';
5
@HiveType(typeId: Template.typeId)
6
class Template extends HiveObject {
7
Template({
8
- required this.name,
9
- required this.isCurrencySelected,
10
- required this.address,
11
- required this.cryptoCurrency,
12
- required this.amount,
13
- required this.fiatCurrency,
14
- required this.amountFiat});
8
+ required this.nameRaw,
9
+ required this.isCurrencySelectedRaw,
10
+ required this.addressRaw,
11
+ required this.cryptoCurrencyRaw,
12
+ required this.amountRaw,
13
+ required this.fiatCurrencyRaw,
14
+ required this.amountFiatRaw});
15
16
static const typeId = 6;
17
static const boxName = 'Template';
18
19
@HiveField(0)
20
- String name;
20
+ String? nameRaw;
21
22
@HiveField(1)
23
- String address;
23
+ String? addressRaw;
24
25
@HiveField(2)
26
- String cryptoCurrency;
26
+ String? cryptoCurrencyRaw;
27
28
@HiveField(3)
29
- String amount;
29
+ String? amountRaw;
30
31
@HiveField(4)
32
- String fiatCurrency;
32
+ String? fiatCurrencyRaw;
33
34
@HiveField(5)
35
- bool isCurrencySelected;
35
+ bool? isCurrencySelectedRaw;
36
37
@HiveField(6)
38
- String amountFiat;
38
+ String? amountFiatRaw;
39
+
40
+ bool get isCurrencySelected => isCurrencySelectedRaw ?? false;
41
+
42
+ String get fiatCurrency => fiatCurrencyRaw ?? '';
43
+
44
+ String get amountFiat => amountFiatRaw ?? '';
45
+
46
+ String get name => nameRaw ?? '';
47
+
48
+ String get address => addressRaw ?? '';
49
+
50
+ String get cryptoCurrency => cryptoCurrencyRaw ?? '';
51
+
52
+ String get amount => amountRaw ?? '';
53
}
54
lib/exchange/exchange_template.dart
+24
-12
@@ -5,32 +5,44 @@ part 'exchange_template.g.dart';
5
@HiveType(typeId: ExchangeTemplate.typeId)
6
class ExchangeTemplate extends HiveObject {
7
ExchangeTemplate({
8
- required this.amount,
9
- required this.depositCurrency,
10
- required this.receiveCurrency,
11
- required this.provider,
12
- required this.depositAddress,
13
- required this.receiveAddress
8
+ required this.amountRaw,
9
+ required this.depositCurrencyRaw,
10
+ required this.receiveCurrencyRaw,
11
+ required this.providerRaw,
12
+ required this.depositAddressRaw,
13
+ required this.receiveAddressRaw
14
});
15
16
static const typeId = 7;
17
static const boxName = 'ExchangeTemplate';
18
19
@HiveField(0)
20
- String amount;
20
+ String? amountRaw;
21
22
@HiveField(1)
23
- String depositCurrency;
23
+ String? depositCurrencyRaw;
24
25
@HiveField(2)
26
- String receiveCurrency;
26
+ String? receiveCurrencyRaw;
27
28
@HiveField(3)
29
- String provider;
29
+ String? providerRaw;
30
31
@HiveField(4)
32
- String depositAddress;
32
+ String? depositAddressRaw;
33
34
@HiveField(5)
35
- String receiveAddress;
35
+ String? receiveAddressRaw;
36
+
37
+ String get amount => amountRaw ?? '';
38
+
39
+ String get depositCurrency => depositCurrencyRaw ?? '';
40
+
41
+ String get receiveCurrency => receiveCurrencyRaw ?? '';
42
+
43
+ String get provider => providerRaw ?? '';
44
+
45
+ String get depositAddress => depositAddressRaw ?? '';
46
+
47
+ String get receiveAddress => receiveAddressRaw ?? '';
48
}
\ No newline at end of file
lib/store/templates/exchange_template_store.dart
+8
-8
@@ -24,7 +24,7 @@ abstract class ExchangeTemplateBase with Store {
24
templates.replaceRange(0, templates.length, templateSource.values.toList());
25
26
@action
27
- Future addTemplate({
27
+ Future<void> addTemplate({
28
required String amount,
29
required String depositCurrency,
30
required String receiveCurrency,
@@ -32,15 +32,15 @@ abstract class ExchangeTemplateBase with Store {
32
required String depositAddress,
33
required String receiveAddress}) async {
34
final template = ExchangeTemplate(
35
- amount: amount,
36
- depositCurrency: depositCurrency,
37
- receiveCurrency: receiveCurrency,
38
- provider: provider,
39
- depositAddress: depositAddress,
40
- receiveAddress: receiveAddress);
35
+ amountRaw: amount,
36
+ depositCurrencyRaw: depositCurrency,
37
+ receiveCurrencyRaw: receiveCurrency,
38
+ providerRaw: provider,
39
+ depositAddressRaw: depositAddress,
40
+ receiveAddressRaw: receiveAddress);
41
await templateSource.add(template);
42
}
43
44
@action
45
- Future remove({required ExchangeTemplate template}) async => await template.delete();
45
+ Future<void> remove({required ExchangeTemplate template}) async => await template.delete();
46
}
\ No newline at end of file
lib/store/templates/send_template_store.dart
+9
-9
@@ -23,7 +23,7 @@ abstract class SendTemplateBase with Store {
23
templates.replaceRange(0, templates.length, templateSource.values.toList());
24
25
@action
26
- Future addTemplate({
26
+ Future<void> addTemplate({
27
required String name,
28
required bool isCurrencySelected,
29
required String address,
@@ -32,16 +32,16 @@ abstract class SendTemplateBase with Store {
32
required String amount,
33
required String amountFiat}) async {
34
final template = Template(
35
- name: name,
36
- isCurrencySelected: isCurrencySelected,
37
- address: address,
38
- cryptoCurrency: cryptoCurrency,
39
- fiatCurrency: fiatCurrency,
40
- amount: amount,
41
- amountFiat: amountFiat);
35
+ nameRaw: name,
36
+ isCurrencySelectedRaw: isCurrencySelected,
37
+ addressRaw: address,
38
+ cryptoCurrencyRaw: cryptoCurrency,
39
+ fiatCurrencyRaw: fiatCurrency,
40
+ amountRaw: amount,
41
+ amountFiatRaw: amountFiat);
42
await templateSource.add(template);
43
}
44
45
@action
46
- Future remove({required Template template}) async => await template.delete();
46
+ Future<void> remove({required Template template}) async => await template.delete();
47
}
\ No newline at end of file