mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2024-12-22 11:39:22 +00:00
Update hive types: UnspentCoinsInfo, Template, ExchangeTemplate. (#583)
This commit is contained in:
parent
03d6701bb7
commit
b182c26ff2
6 changed files with 76 additions and 46 deletions
|
@ -495,7 +495,7 @@ abstract class ElectrumWalletBase extends WalletBase<ElectrumBalance,
|
|||
hash: coin.hash,
|
||||
isFrozen: coin.isFrozen,
|
||||
isSending: coin.isSending,
|
||||
note: coin.note
|
||||
noteRaw: coin.note
|
||||
);
|
||||
|
||||
await unspentCoinsInfo.add(newInfo);
|
||||
|
|
|
@ -9,7 +9,7 @@ class UnspentCoinsInfo extends HiveObject {
|
|||
required this.hash,
|
||||
required this.isFrozen,
|
||||
required this.isSending,
|
||||
required this.note});
|
||||
required this.noteRaw});
|
||||
|
||||
static const typeId = 9;
|
||||
static const boxName = 'Unspent';
|
||||
|
@ -28,5 +28,9 @@ class UnspentCoinsInfo extends HiveObject {
|
|||
bool isSending;
|
||||
|
||||
@HiveField(4)
|
||||
String note;
|
||||
String? noteRaw;
|
||||
|
||||
String get note => noteRaw ?? '';
|
||||
|
||||
set note(String value) => noteRaw = value;
|
||||
}
|
|
@ -5,36 +5,50 @@ part 'template.g.dart';
|
|||
@HiveType(typeId: Template.typeId)
|
||||
class Template extends HiveObject {
|
||||
Template({
|
||||
required this.name,
|
||||
required this.isCurrencySelected,
|
||||
required this.address,
|
||||
required this.cryptoCurrency,
|
||||
required this.amount,
|
||||
required this.fiatCurrency,
|
||||
required this.amountFiat});
|
||||
required this.nameRaw,
|
||||
required this.isCurrencySelectedRaw,
|
||||
required this.addressRaw,
|
||||
required this.cryptoCurrencyRaw,
|
||||
required this.amountRaw,
|
||||
required this.fiatCurrencyRaw,
|
||||
required this.amountFiatRaw});
|
||||
|
||||
static const typeId = 6;
|
||||
static const boxName = 'Template';
|
||||
|
||||
@HiveField(0)
|
||||
String name;
|
||||
String? nameRaw;
|
||||
|
||||
@HiveField(1)
|
||||
String address;
|
||||
String? addressRaw;
|
||||
|
||||
@HiveField(2)
|
||||
String cryptoCurrency;
|
||||
String? cryptoCurrencyRaw;
|
||||
|
||||
@HiveField(3)
|
||||
String amount;
|
||||
String? amountRaw;
|
||||
|
||||
@HiveField(4)
|
||||
String fiatCurrency;
|
||||
String? fiatCurrencyRaw;
|
||||
|
||||
@HiveField(5)
|
||||
bool isCurrencySelected;
|
||||
bool? isCurrencySelectedRaw;
|
||||
|
||||
@HiveField(6)
|
||||
String amountFiat;
|
||||
String? amountFiatRaw;
|
||||
|
||||
bool get isCurrencySelected => isCurrencySelectedRaw ?? false;
|
||||
|
||||
String get fiatCurrency => fiatCurrencyRaw ?? '';
|
||||
|
||||
String get amountFiat => amountFiatRaw ?? '';
|
||||
|
||||
String get name => nameRaw ?? '';
|
||||
|
||||
String get address => addressRaw ?? '';
|
||||
|
||||
String get cryptoCurrency => cryptoCurrencyRaw ?? '';
|
||||
|
||||
String get amount => amountRaw ?? '';
|
||||
}
|
||||
|
||||
|
|
|
@ -5,32 +5,44 @@ part 'exchange_template.g.dart';
|
|||
@HiveType(typeId: ExchangeTemplate.typeId)
|
||||
class ExchangeTemplate extends HiveObject {
|
||||
ExchangeTemplate({
|
||||
required this.amount,
|
||||
required this.depositCurrency,
|
||||
required this.receiveCurrency,
|
||||
required this.provider,
|
||||
required this.depositAddress,
|
||||
required this.receiveAddress
|
||||
required this.amountRaw,
|
||||
required this.depositCurrencyRaw,
|
||||
required this.receiveCurrencyRaw,
|
||||
required this.providerRaw,
|
||||
required this.depositAddressRaw,
|
||||
required this.receiveAddressRaw
|
||||
});
|
||||
|
||||
static const typeId = 7;
|
||||
static const boxName = 'ExchangeTemplate';
|
||||
|
||||
@HiveField(0)
|
||||
String amount;
|
||||
String? amountRaw;
|
||||
|
||||
@HiveField(1)
|
||||
String depositCurrency;
|
||||
String? depositCurrencyRaw;
|
||||
|
||||
@HiveField(2)
|
||||
String receiveCurrency;
|
||||
String? receiveCurrencyRaw;
|
||||
|
||||
@HiveField(3)
|
||||
String provider;
|
||||
String? providerRaw;
|
||||
|
||||
@HiveField(4)
|
||||
String depositAddress;
|
||||
String? depositAddressRaw;
|
||||
|
||||
@HiveField(5)
|
||||
String receiveAddress;
|
||||
String? receiveAddressRaw;
|
||||
|
||||
String get amount => amountRaw ?? '';
|
||||
|
||||
String get depositCurrency => depositCurrencyRaw ?? '';
|
||||
|
||||
String get receiveCurrency => receiveCurrencyRaw ?? '';
|
||||
|
||||
String get provider => providerRaw ?? '';
|
||||
|
||||
String get depositAddress => depositAddressRaw ?? '';
|
||||
|
||||
String get receiveAddress => receiveAddressRaw ?? '';
|
||||
}
|
|
@ -24,7 +24,7 @@ abstract class ExchangeTemplateBase with Store {
|
|||
templates.replaceRange(0, templates.length, templateSource.values.toList());
|
||||
|
||||
@action
|
||||
Future addTemplate({
|
||||
Future<void> addTemplate({
|
||||
required String amount,
|
||||
required String depositCurrency,
|
||||
required String receiveCurrency,
|
||||
|
@ -32,15 +32,15 @@ abstract class ExchangeTemplateBase with Store {
|
|||
required String depositAddress,
|
||||
required String receiveAddress}) async {
|
||||
final template = ExchangeTemplate(
|
||||
amount: amount,
|
||||
depositCurrency: depositCurrency,
|
||||
receiveCurrency: receiveCurrency,
|
||||
provider: provider,
|
||||
depositAddress: depositAddress,
|
||||
receiveAddress: receiveAddress);
|
||||
amountRaw: amount,
|
||||
depositCurrencyRaw: depositCurrency,
|
||||
receiveCurrencyRaw: receiveCurrency,
|
||||
providerRaw: provider,
|
||||
depositAddressRaw: depositAddress,
|
||||
receiveAddressRaw: receiveAddress);
|
||||
await templateSource.add(template);
|
||||
}
|
||||
|
||||
@action
|
||||
Future remove({required ExchangeTemplate template}) async => await template.delete();
|
||||
Future<void> remove({required ExchangeTemplate template}) async => await template.delete();
|
||||
}
|
|
@ -23,7 +23,7 @@ abstract class SendTemplateBase with Store {
|
|||
templates.replaceRange(0, templates.length, templateSource.values.toList());
|
||||
|
||||
@action
|
||||
Future addTemplate({
|
||||
Future<void> addTemplate({
|
||||
required String name,
|
||||
required bool isCurrencySelected,
|
||||
required String address,
|
||||
|
@ -32,16 +32,16 @@ abstract class SendTemplateBase with Store {
|
|||
required String amount,
|
||||
required String amountFiat}) async {
|
||||
final template = Template(
|
||||
name: name,
|
||||
isCurrencySelected: isCurrencySelected,
|
||||
address: address,
|
||||
cryptoCurrency: cryptoCurrency,
|
||||
fiatCurrency: fiatCurrency,
|
||||
amount: amount,
|
||||
amountFiat: amountFiat);
|
||||
nameRaw: name,
|
||||
isCurrencySelectedRaw: isCurrencySelected,
|
||||
addressRaw: address,
|
||||
cryptoCurrencyRaw: cryptoCurrency,
|
||||
fiatCurrencyRaw: fiatCurrency,
|
||||
amountRaw: amount,
|
||||
amountFiatRaw: amountFiat);
|
||||
await templateSource.add(template);
|
||||
}
|
||||
|
||||
@action
|
||||
Future remove({required Template template}) async => await template.delete();
|
||||
Future<void> remove({required Template template}) async => await template.delete();
|
||||
}
|
Loading…
Reference in a new issue