CAKE-343 | applied subaddresses for contact book; added addresses field to wallet_info.dart; added updateAddressesInfo() to wallet_base.dart; applied updateAddressesInfo() to wallet services and view models

This commit is contained in:
OleksandrSobol
2021-06-18 15:36:49 +03:00
parent b5cacbc1c1
commit 6709b7779a
13 changed files with 81 additions and 18 deletions
@@ -16,11 +16,23 @@ class ContactListViewModel = ContactListViewModelBase
abstract class ContactListViewModelBase with Store {
ContactListViewModelBase(this.contactSource, this.walletInfoSource)
: contacts = ObservableList<ContactRecord>(),
walletContacts = walletInfoSource.values
.where((info) => info.address?.isNotEmpty ?? false)
.map((info) => WalletContact(
info.address, info.name, walletTypeToCryptoCurrency(info.type)))
.toList() {
walletContacts = [] {
walletInfoSource.values.forEach((info) {
if (info.address?.isNotEmpty ?? false) {
if (info.addresses != null) {
info.addresses.forEach((address, label) {
walletContacts.add(WalletContact(
address,
info.name + ' ($label)',
walletTypeToCryptoCurrency(info.type)));
});
} else {
walletContacts.add(WalletContact(info.address, info.name,
walletTypeToCryptoCurrency(info.type)));
}
}
});
_subscription = contactSource.bindToListWithTransform(
contacts, (Contact contact) => ContactRecord(contactSource, contact),
initialFire: true);
@@ -1,3 +1,5 @@
import 'package:cake_wallet/core/wallet_base.dart';
import 'package:flutter/foundation.dart';
import 'package:mobx/mobx.dart';
import 'package:cake_wallet/core/execution_state.dart';
import 'package:cake_wallet/monero/monero_account_list.dart';
@@ -10,11 +12,12 @@ class MoneroAccountEditOrCreateViewModel = MoneroAccountEditOrCreateViewModelBas
abstract class MoneroAccountEditOrCreateViewModelBase with Store {
MoneroAccountEditOrCreateViewModelBase(this._moneroAccountList,
{AccountListItem accountListItem})
{@required WalletBase wallet, AccountListItem accountListItem})
: state = InitialExecutionState(),
isEdit = accountListItem != null,
label = accountListItem?.label??'',
_accountListItem = accountListItem;
_accountListItem = accountListItem,
_wallet = wallet;
final bool isEdit;
@@ -26,6 +29,7 @@ abstract class MoneroAccountEditOrCreateViewModelBase with Store {
final MoneroAccountList _moneroAccountList;
final AccountListItem _accountListItem;
final WalletBase _wallet;
Future<void> save() async {
try {
@@ -38,6 +42,8 @@ abstract class MoneroAccountEditOrCreateViewModelBase with Store {
await _moneroAccountList.addAccount(label: label);
}
await _wallet.updateAddressesInfo();
state = ExecutedSuccessfullyState();
} catch (e) {
state = FailureState(e.toString());
@@ -54,6 +54,8 @@ abstract class WalletAddressEditOrCreateViewModelBase with Store {
await _createNew();
}
await _wallet.updateAddressesInfo();
state = AddressSavedSuccessfully();
} catch (e) {
state = AddressEditOrCreateStateFailure(error: e.toString());
+1
View File
@@ -54,6 +54,7 @@ abstract class WalletCreationVMBase with Store {
await _walletInfoSource.add(walletInfo);
_appStore.changeCurrentWallet(wallet);
_appStore.authenticationStore.allowed();
await wallet.updateAddressesInfo();
state = ExecutedSuccessfullyState();
} catch (e) {
state = FailureState(e.toString());