mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2024-12-23 03:59:23 +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,
|
hash: coin.hash,
|
||||||
isFrozen: coin.isFrozen,
|
isFrozen: coin.isFrozen,
|
||||||
isSending: coin.isSending,
|
isSending: coin.isSending,
|
||||||
note: coin.note
|
noteRaw: coin.note
|
||||||
);
|
);
|
||||||
|
|
||||||
await unspentCoinsInfo.add(newInfo);
|
await unspentCoinsInfo.add(newInfo);
|
||||||
|
|
|
@ -9,7 +9,7 @@ class UnspentCoinsInfo extends HiveObject {
|
||||||
required this.hash,
|
required this.hash,
|
||||||
required this.isFrozen,
|
required this.isFrozen,
|
||||||
required this.isSending,
|
required this.isSending,
|
||||||
required this.note});
|
required this.noteRaw});
|
||||||
|
|
||||||
static const typeId = 9;
|
static const typeId = 9;
|
||||||
static const boxName = 'Unspent';
|
static const boxName = 'Unspent';
|
||||||
|
@ -28,5 +28,9 @@ class UnspentCoinsInfo extends HiveObject {
|
||||||
bool isSending;
|
bool isSending;
|
||||||
|
|
||||||
@HiveField(4)
|
@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)
|
@HiveType(typeId: Template.typeId)
|
||||||
class Template extends HiveObject {
|
class Template extends HiveObject {
|
||||||
Template({
|
Template({
|
||||||
required this.name,
|
required this.nameRaw,
|
||||||
required this.isCurrencySelected,
|
required this.isCurrencySelectedRaw,
|
||||||
required this.address,
|
required this.addressRaw,
|
||||||
required this.cryptoCurrency,
|
required this.cryptoCurrencyRaw,
|
||||||
required this.amount,
|
required this.amountRaw,
|
||||||
required this.fiatCurrency,
|
required this.fiatCurrencyRaw,
|
||||||
required this.amountFiat});
|
required this.amountFiatRaw});
|
||||||
|
|
||||||
static const typeId = 6;
|
static const typeId = 6;
|
||||||
static const boxName = 'Template';
|
static const boxName = 'Template';
|
||||||
|
|
||||||
@HiveField(0)
|
@HiveField(0)
|
||||||
String name;
|
String? nameRaw;
|
||||||
|
|
||||||
@HiveField(1)
|
@HiveField(1)
|
||||||
String address;
|
String? addressRaw;
|
||||||
|
|
||||||
@HiveField(2)
|
@HiveField(2)
|
||||||
String cryptoCurrency;
|
String? cryptoCurrencyRaw;
|
||||||
|
|
||||||
@HiveField(3)
|
@HiveField(3)
|
||||||
String amount;
|
String? amountRaw;
|
||||||
|
|
||||||
@HiveField(4)
|
@HiveField(4)
|
||||||
String fiatCurrency;
|
String? fiatCurrencyRaw;
|
||||||
|
|
||||||
@HiveField(5)
|
@HiveField(5)
|
||||||
bool isCurrencySelected;
|
bool? isCurrencySelectedRaw;
|
||||||
|
|
||||||
@HiveField(6)
|
@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)
|
@HiveType(typeId: ExchangeTemplate.typeId)
|
||||||
class ExchangeTemplate extends HiveObject {
|
class ExchangeTemplate extends HiveObject {
|
||||||
ExchangeTemplate({
|
ExchangeTemplate({
|
||||||
required this.amount,
|
required this.amountRaw,
|
||||||
required this.depositCurrency,
|
required this.depositCurrencyRaw,
|
||||||
required this.receiveCurrency,
|
required this.receiveCurrencyRaw,
|
||||||
required this.provider,
|
required this.providerRaw,
|
||||||
required this.depositAddress,
|
required this.depositAddressRaw,
|
||||||
required this.receiveAddress
|
required this.receiveAddressRaw
|
||||||
});
|
});
|
||||||
|
|
||||||
static const typeId = 7;
|
static const typeId = 7;
|
||||||
static const boxName = 'ExchangeTemplate';
|
static const boxName = 'ExchangeTemplate';
|
||||||
|
|
||||||
@HiveField(0)
|
@HiveField(0)
|
||||||
String amount;
|
String? amountRaw;
|
||||||
|
|
||||||
@HiveField(1)
|
@HiveField(1)
|
||||||
String depositCurrency;
|
String? depositCurrencyRaw;
|
||||||
|
|
||||||
@HiveField(2)
|
@HiveField(2)
|
||||||
String receiveCurrency;
|
String? receiveCurrencyRaw;
|
||||||
|
|
||||||
@HiveField(3)
|
@HiveField(3)
|
||||||
String provider;
|
String? providerRaw;
|
||||||
|
|
||||||
@HiveField(4)
|
@HiveField(4)
|
||||||
String depositAddress;
|
String? depositAddressRaw;
|
||||||
|
|
||||||
@HiveField(5)
|
@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());
|
templates.replaceRange(0, templates.length, templateSource.values.toList());
|
||||||
|
|
||||||
@action
|
@action
|
||||||
Future addTemplate({
|
Future<void> addTemplate({
|
||||||
required String amount,
|
required String amount,
|
||||||
required String depositCurrency,
|
required String depositCurrency,
|
||||||
required String receiveCurrency,
|
required String receiveCurrency,
|
||||||
|
@ -32,15 +32,15 @@ abstract class ExchangeTemplateBase with Store {
|
||||||
required String depositAddress,
|
required String depositAddress,
|
||||||
required String receiveAddress}) async {
|
required String receiveAddress}) async {
|
||||||
final template = ExchangeTemplate(
|
final template = ExchangeTemplate(
|
||||||
amount: amount,
|
amountRaw: amount,
|
||||||
depositCurrency: depositCurrency,
|
depositCurrencyRaw: depositCurrency,
|
||||||
receiveCurrency: receiveCurrency,
|
receiveCurrencyRaw: receiveCurrency,
|
||||||
provider: provider,
|
providerRaw: provider,
|
||||||
depositAddress: depositAddress,
|
depositAddressRaw: depositAddress,
|
||||||
receiveAddress: receiveAddress);
|
receiveAddressRaw: receiveAddress);
|
||||||
await templateSource.add(template);
|
await templateSource.add(template);
|
||||||
}
|
}
|
||||||
|
|
||||||
@action
|
@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());
|
templates.replaceRange(0, templates.length, templateSource.values.toList());
|
||||||
|
|
||||||
@action
|
@action
|
||||||
Future addTemplate({
|
Future<void> addTemplate({
|
||||||
required String name,
|
required String name,
|
||||||
required bool isCurrencySelected,
|
required bool isCurrencySelected,
|
||||||
required String address,
|
required String address,
|
||||||
|
@ -32,16 +32,16 @@ abstract class SendTemplateBase with Store {
|
||||||
required String amount,
|
required String amount,
|
||||||
required String amountFiat}) async {
|
required String amountFiat}) async {
|
||||||
final template = Template(
|
final template = Template(
|
||||||
name: name,
|
nameRaw: name,
|
||||||
isCurrencySelected: isCurrencySelected,
|
isCurrencySelectedRaw: isCurrencySelected,
|
||||||
address: address,
|
addressRaw: address,
|
||||||
cryptoCurrency: cryptoCurrency,
|
cryptoCurrencyRaw: cryptoCurrency,
|
||||||
fiatCurrency: fiatCurrency,
|
fiatCurrencyRaw: fiatCurrency,
|
||||||
amount: amount,
|
amountRaw: amount,
|
||||||
amountFiat: amountFiat);
|
amountFiatRaw: amountFiat);
|
||||||
await templateSource.add(template);
|
await templateSource.add(template);
|
||||||
}
|
}
|
||||||
|
|
||||||
@action
|
@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