mirror of
https://github.com/Such-Software/hash-wallet.git
synced 2026-10-24 06:48:38 +02:00
Fixes
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
import 'package:cake_wallet/entities/transaction_description.dart';
|
||||
import 'package:hive/hive.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
import 'package:mobx/mobx.dart';
|
||||
import 'package:cake_wallet/entities/openalias_record.dart';
|
||||
@@ -30,9 +32,8 @@ part 'send_view_model.g.dart';
|
||||
class SendViewModel = SendViewModelBase with _$SendViewModel;
|
||||
|
||||
abstract class SendViewModelBase with Store {
|
||||
SendViewModelBase(
|
||||
this._wallet, this._settingsStore, this._sendTemplateStore,
|
||||
this._fiatConversationStore)
|
||||
SendViewModelBase(this._wallet, this._settingsStore, this._sendTemplateStore,
|
||||
this._fiatConversationStore, this.transactionDescriptionBox)
|
||||
: state = InitialExecutionState(),
|
||||
_cryptoNumberFormat = NumberFormat(),
|
||||
sendAll = false {
|
||||
@@ -101,6 +102,7 @@ abstract class SendViewModelBase with Store {
|
||||
final SendTemplateStore _sendTemplateStore;
|
||||
final FiatConversionStore _fiatConversationStore;
|
||||
final NumberFormat _cryptoNumberFormat;
|
||||
final Box<TransactionDescription> transactionDescriptionBox;
|
||||
|
||||
@action
|
||||
void setSendAll() => sendAll = true;
|
||||
@@ -129,6 +131,13 @@ abstract class SendViewModelBase with Store {
|
||||
try {
|
||||
state = TransactionCommitting();
|
||||
await pendingTransaction.commit();
|
||||
|
||||
if (_settingsStore.shouldSaveRecipientAddress &&
|
||||
(pendingTransaction.id?.isNotEmpty ?? false)) {
|
||||
await transactionDescriptionBox.add(TransactionDescription(
|
||||
id: pendingTransaction.id, recipientAddress: address));
|
||||
}
|
||||
|
||||
state = TransactionCommitted();
|
||||
} catch (e) {
|
||||
state = FailureState(e.toString());
|
||||
@@ -156,8 +165,8 @@ abstract class SendViewModelBase with Store {
|
||||
_settingsStore.transactionPriority = priority;
|
||||
|
||||
Future<OpenaliasRecord> decodeOpenaliasRecord(String name) async {
|
||||
final record = await OpenaliasRecord
|
||||
.fetchAddressAndName(OpenaliasRecord.formatDomainName(name));
|
||||
final record = await OpenaliasRecord.fetchAddressAndName(
|
||||
OpenaliasRecord.formatDomainName(name));
|
||||
|
||||
return record.name != name ? record : null;
|
||||
}
|
||||
@@ -232,13 +241,16 @@ abstract class SendViewModelBase with Store {
|
||||
|
||||
void updateTemplate() => _sendTemplateStore.update();
|
||||
|
||||
void addTemplate({String name, String address, String cryptoCurrency,
|
||||
String amount}) => _sendTemplateStore
|
||||
.addTemplate(
|
||||
name: name,
|
||||
address: address,
|
||||
cryptoCurrency: cryptoCurrency,
|
||||
amount: amount);
|
||||
void addTemplate(
|
||||
{String name,
|
||||
String address,
|
||||
String cryptoCurrency,
|
||||
String amount}) =>
|
||||
_sendTemplateStore.addTemplate(
|
||||
name: name,
|
||||
address: address,
|
||||
cryptoCurrency: cryptoCurrency,
|
||||
amount: amount);
|
||||
|
||||
void removeTemplate({Template template}) =>
|
||||
_sendTemplateStore.remove(template: template);
|
||||
|
||||
Reference in New Issue
Block a user