mirror of
https://github.com/Such-Software/hash-wallet.git
synced 2026-10-22 06:28:39 +02:00
General changes. CAKE-1.
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
import 'package:mobx/mobx.dart';
|
||||
import 'package:cake_wallet/core/contact_service.dart';
|
||||
import 'package:cake_wallet/store/contact_list_store.dart';
|
||||
import 'package:cake_wallet/src/domain/common/contact.dart';
|
||||
|
||||
part 'contact_list_view_model.g.dart';
|
||||
|
||||
class ContactListViewModel = ContactListViewModelBase with _$ContactListViewModel;
|
||||
|
||||
abstract class ContactListViewModelBase with Store {
|
||||
ContactListViewModelBase(this.addressBookStore, this.contactService);
|
||||
|
||||
final ContactListStore addressBookStore;
|
||||
final ContactService contactService;
|
||||
|
||||
@computed
|
||||
ObservableList<Contact> get contacts => addressBookStore.contacts;
|
||||
|
||||
Future<void> delete(Contact contact) async => contactService.delete(contact);
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
import 'package:mobx/mobx.dart';
|
||||
import 'package:cake_wallet/core/wallet_base.dart';
|
||||
import 'package:cake_wallet/core/contact_service.dart';
|
||||
import 'package:cake_wallet/src/domain/common/contact.dart';
|
||||
import 'package:cake_wallet/src/domain/common/crypto_currency.dart';
|
||||
import 'package:cake_wallet/view_model/contact_list/contact_view_model_state.dart';
|
||||
|
||||
part 'contact_view_model.g.dart';
|
||||
|
||||
class ContactViewModel = ContactViewModelBase with _$ContactViewModel;
|
||||
|
||||
abstract class ContactViewModelBase with Store {
|
||||
ContactViewModelBase(this._contactService, this._wallet, {Contact contact})
|
||||
: state = InitialContactViewModelState(),
|
||||
currencies = CryptoCurrency.all,
|
||||
_contact = contact {
|
||||
name = _contact?.name;
|
||||
address = _contact?.address;
|
||||
currency = _contact?.type ?? _wallet.currency;
|
||||
}
|
||||
|
||||
@observable
|
||||
ContactViewModelState state;
|
||||
|
||||
@observable
|
||||
String name;
|
||||
|
||||
@observable
|
||||
String address;
|
||||
|
||||
@observable
|
||||
CryptoCurrency currency;
|
||||
|
||||
@computed
|
||||
bool get isReady =>
|
||||
(name?.isNotEmpty ?? false) && (address?.isNotEmpty ?? false);
|
||||
|
||||
final List<CryptoCurrency> currencies;
|
||||
final ContactService _contactService;
|
||||
final WalletBase _wallet;
|
||||
final Contact _contact;
|
||||
|
||||
@action
|
||||
void reset() {
|
||||
address = '';
|
||||
name = '';
|
||||
currency = _wallet.currency;
|
||||
}
|
||||
|
||||
Future save() async {
|
||||
try {
|
||||
state = ContactIsCreating();
|
||||
|
||||
if (_contact != null) {
|
||||
_contact.name = name;
|
||||
_contact.address = address;
|
||||
_contact.updateCryptoCurrency(currency: currency);
|
||||
await _contactService.update(_contact);
|
||||
} else {
|
||||
await _contactService
|
||||
.add(Contact(name: name, address: address, type: currency));
|
||||
}
|
||||
|
||||
state = ContactSavingSuccessfully();
|
||||
} catch (e) {
|
||||
state = ContactCreationFailure(e.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
abstract class ContactViewModelState {}
|
||||
|
||||
class InitialContactViewModelState extends ContactViewModelState {}
|
||||
|
||||
class ContactIsCreating extends ContactViewModelState {}
|
||||
|
||||
class ContactSavingSuccessfully extends ContactViewModelState {}
|
||||
|
||||
class ContactCreationFailure extends ContactViewModelState {
|
||||
ContactCreationFailure(this.error);
|
||||
|
||||
final String error;
|
||||
}
|
||||
@@ -1,4 +1,6 @@
|
||||
import 'package:cake_wallet/bitcoin/bitcoin_transaction_info.dart';
|
||||
import 'package:cake_wallet/bitcoin/bitcoin_wallet.dart';
|
||||
import 'package:cake_wallet/monero/monero_wallet.dart';
|
||||
import 'package:cake_wallet/src/domain/common/transaction_direction.dart';
|
||||
import 'package:cake_wallet/src/domain/common/transaction_info.dart';
|
||||
import 'package:cake_wallet/src/stores/action_list/transaction_list_item.dart';
|
||||
@@ -22,13 +24,17 @@ class WalletBalace {
|
||||
abstract class DashboardViewModelBase with Store {
|
||||
DashboardViewModelBase({this.appStore}) {
|
||||
name = appStore.wallet?.name;
|
||||
balance = WalletBalace(unlockedBalance: '0.001', totalBalance: '0.005');
|
||||
status = SyncedSyncStatus();
|
||||
type = WalletType.bitcoin;
|
||||
wallet ??= appStore.wallet;
|
||||
_reaction = reaction((_) => appStore.wallet, _onWalletChange);
|
||||
type = wallet.type;
|
||||
transactions = ObservableList.of(wallet.transactionHistory.transactions
|
||||
.map((transaction) => TransactionListItem(transaction: transaction)));
|
||||
_reaction = reaction((_) => appStore.wallet, _onWalletChange);
|
||||
|
||||
final _wallet = wallet;
|
||||
|
||||
if (_wallet is MoneroWallet) {
|
||||
subname = _wallet.account?.label;
|
||||
}
|
||||
}
|
||||
|
||||
@observable
|
||||
@@ -40,14 +46,110 @@ abstract class DashboardViewModelBase with Store {
|
||||
@computed
|
||||
String get address => wallet.address;
|
||||
|
||||
@observable
|
||||
WalletBalace balance;
|
||||
@computed
|
||||
SyncStatus get status => wallet.syncStatus;
|
||||
|
||||
@observable
|
||||
SyncStatus status;
|
||||
@computed
|
||||
WalletBalace get balance {
|
||||
final wallet = this.wallet;
|
||||
|
||||
if (wallet is MoneroWallet) {
|
||||
return WalletBalace(
|
||||
unlockedBalance: wallet.balance.formattedUnlockedBalance,
|
||||
totalBalance: wallet.balance.formattedFullBalance);
|
||||
}
|
||||
|
||||
if (wallet is BitcoinWallet) {
|
||||
return WalletBalace(
|
||||
unlockedBalance: wallet.balance.confirmedFormatted,
|
||||
totalBalance: wallet.balance.unconfirmedFormatted);
|
||||
}
|
||||
}
|
||||
|
||||
@observable
|
||||
ObservableList<Object> transactions;
|
||||
// ObservableList.of([
|
||||
// TransactionListItem(transaction: BitcoinTransactionInfo(
|
||||
// id: '',
|
||||
// height: 0,
|
||||
// amount: 0,
|
||||
// direction: TransactionDirection.incoming,
|
||||
// date: DateTime.now(),
|
||||
// isPending: false
|
||||
// )),
|
||||
// TransactionListItem(transaction: BitcoinTransactionInfo(
|
||||
// id: '',
|
||||
// height: 0,
|
||||
// amount: 0,
|
||||
// direction: TransactionDirection.incoming,
|
||||
// date: DateTime.now(),
|
||||
// isPending: false
|
||||
// )),
|
||||
// TransactionListItem(transaction: BitcoinTransactionInfo(
|
||||
// id: '',
|
||||
// height: 0,
|
||||
// amount: 0,
|
||||
// direction: TransactionDirection.incoming,
|
||||
// date: DateTime.now(),
|
||||
// isPending: false
|
||||
// )),
|
||||
// TransactionListItem(transaction: BitcoinTransactionInfo(
|
||||
// id: '',
|
||||
// height: 0,
|
||||
// amount: 0,
|
||||
// direction: TransactionDirection.incoming,
|
||||
// date: DateTime.now(),
|
||||
// isPending: false
|
||||
// )),
|
||||
// TransactionListItem(transaction: BitcoinTransactionInfo(
|
||||
// id: '',
|
||||
// height: 0,
|
||||
// amount: 0,
|
||||
// direction: TransactionDirection.incoming,
|
||||
// date: DateTime.now(),
|
||||
// isPending: false
|
||||
// )),
|
||||
// TransactionListItem(transaction: BitcoinTransactionInfo(
|
||||
// id: '',
|
||||
// height: 0,
|
||||
// amount: 0,
|
||||
// direction: TransactionDirection.incoming,
|
||||
// date: DateTime.now(),
|
||||
// isPending: false
|
||||
// )),
|
||||
// TransactionListItem(transaction: BitcoinTransactionInfo(
|
||||
// id: '',
|
||||
// height: 0,
|
||||
// amount: 0,
|
||||
// direction: TransactionDirection.incoming,
|
||||
// date: DateTime.now(),
|
||||
// isPending: false
|
||||
// )),
|
||||
// TransactionListItem(transaction: BitcoinTransactionInfo(
|
||||
// id: '',
|
||||
// height: 0,
|
||||
// amount: 0,
|
||||
// direction: TransactionDirection.incoming,
|
||||
// date: DateTime.now(),
|
||||
// isPending: false
|
||||
// )),
|
||||
// TransactionListItem(transaction: BitcoinTransactionInfo(
|
||||
// id: '',
|
||||
// height: 0,
|
||||
// amount: 0,
|
||||
// direction: TransactionDirection.incoming,
|
||||
// date: DateTime.now(),
|
||||
// isPending: false
|
||||
// )),
|
||||
// TransactionListItem(transaction: BitcoinTransactionInfo(
|
||||
// id: '',
|
||||
// height: 0,
|
||||
// amount: 0,
|
||||
// direction: TransactionDirection.incoming,
|
||||
// date: DateTime.now(),
|
||||
// isPending: false
|
||||
// )),
|
||||
// ]);
|
||||
|
||||
@observable
|
||||
String subname;
|
||||
@@ -63,6 +165,5 @@ abstract class DashboardViewModelBase with Store {
|
||||
transactions.clear();
|
||||
transactions.addAll(wallet.transactionHistory.transactions
|
||||
.map((transaction) => TransactionListItem(transaction: transaction)));
|
||||
balance = WalletBalace(unlockedBalance: '0.001', totalBalance: '0.005');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
import 'package:flutter/foundation.dart';
|
||||
|
||||
class AccountListItem {
|
||||
AccountListItem(
|
||||
{@required this.label, @required this.id, this.isSelected = false});
|
||||
|
||||
final String label;
|
||||
final int id;
|
||||
final bool isSelected;
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
import 'package:flutter/foundation.dart';
|
||||
|
||||
abstract class MoneroAccountEditOrCreateState {}
|
||||
|
||||
class InitialAccountCreationState extends MoneroAccountEditOrCreateState {}
|
||||
|
||||
class AccountIsCreating extends MoneroAccountEditOrCreateState {}
|
||||
|
||||
class AccountCreatedSuccessfully extends MoneroAccountEditOrCreateState {}
|
||||
|
||||
class AccountCreationFailure extends MoneroAccountEditOrCreateState {
|
||||
AccountCreationFailure({@required this.error});
|
||||
|
||||
final String error;
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
import 'package:mobx/mobx.dart';
|
||||
import 'package:cake_wallet/monero/monero_account_list.dart';
|
||||
import 'package:cake_wallet/view_model/monero_account_list/account_list_item.dart';
|
||||
import 'package:cake_wallet/view_model/monero_account_list/monero_account_edit_or_create_state.dart';
|
||||
|
||||
part 'monero_account_edit_or_create_view_model.g.dart';
|
||||
|
||||
class MoneroAccountEditOrCreateViewModel = MoneroAccountEditOrCreateViewModelBase
|
||||
with _$MoneroAccountEditOrCreateViewModel;
|
||||
|
||||
abstract class MoneroAccountEditOrCreateViewModelBase with Store {
|
||||
MoneroAccountEditOrCreateViewModelBase(this._moneroAccountList,
|
||||
{AccountListItem accountListItem})
|
||||
: state = InitialAccountCreationState(),
|
||||
isEdit = accountListItem != null,
|
||||
_accountListItem = accountListItem;
|
||||
|
||||
final bool isEdit;
|
||||
|
||||
@observable
|
||||
MoneroAccountEditOrCreateState state;
|
||||
|
||||
@observable
|
||||
String label;
|
||||
|
||||
final MoneroAccountList _moneroAccountList;
|
||||
final AccountListItem _accountListItem;
|
||||
|
||||
Future<void> save() async {
|
||||
try {
|
||||
state = AccountIsCreating();
|
||||
|
||||
if (_accountListItem != null) {
|
||||
await _moneroAccountList.setLabelAccount(
|
||||
accountIndex: _accountListItem.id, label: label);
|
||||
} else {
|
||||
await _moneroAccountList.addAccount(label: label);
|
||||
}
|
||||
|
||||
state = AccountCreatedSuccessfully();
|
||||
} catch (e) {
|
||||
state = AccountCreationFailure(error: e.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
import 'package:mobx/mobx.dart';
|
||||
import 'package:cake_wallet/src/domain/monero/account.dart';
|
||||
import 'package:cake_wallet/monero/monero_wallet.dart';
|
||||
import 'package:cake_wallet/view_model/monero_account_list/account_list_item.dart';
|
||||
|
||||
part 'monero_account_list_view_model.g.dart';
|
||||
|
||||
class MoneroAccountListViewModel = MoneroAccountListViewModelBase
|
||||
with _$MoneroAccountListViewModel;
|
||||
|
||||
abstract class MoneroAccountListViewModelBase with Store {
|
||||
MoneroAccountListViewModelBase(this._moneroWallet);
|
||||
|
||||
@computed
|
||||
List<AccountListItem> get accounts => _moneroWallet.accountList.accounts
|
||||
.map((acc) => AccountListItem(
|
||||
label: acc.label,
|
||||
id: acc.id,
|
||||
isSelected: acc.id == _moneroWallet.account.id))
|
||||
.toList();
|
||||
|
||||
final MoneroWallet _moneroWallet;
|
||||
|
||||
void select(AccountListItem item) =>
|
||||
_moneroWallet.account = Account(id: item.id, label: item.label);
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
import 'package:hive/hive.dart';
|
||||
import 'package:mobx/mobx.dart';
|
||||
import 'package:cake_wallet/core/wallet_base.dart';
|
||||
import 'package:cake_wallet/src/domain/common/node.dart';
|
||||
import 'package:cake_wallet/src/domain/common/wallet_type.dart';
|
||||
import 'package:cake_wallet/view_model/node_list/node_create_or_edit_view_model_state.dart';
|
||||
|
||||
part 'node_create_or_edit_view_model.g.dart';
|
||||
|
||||
class NodeCreateOrEditViewModel = NodeCreateOrEditViewModelBase
|
||||
with _$NodeCreateOrEditViewModel;
|
||||
|
||||
abstract class NodeCreateOrEditViewModelBase with Store {
|
||||
NodeCreateOrEditViewModelBase(this._nodeSource, this._wallet)
|
||||
: state = InitialNodeCreateOrEditViewModelState();
|
||||
|
||||
@observable
|
||||
NodeCreateOrEditViewModelState state;
|
||||
|
||||
@observable
|
||||
String address;
|
||||
|
||||
@observable
|
||||
String port;
|
||||
|
||||
@observable
|
||||
String login;
|
||||
|
||||
@observable
|
||||
String password;
|
||||
|
||||
@computed
|
||||
bool get isReady =>
|
||||
(address?.isNotEmpty ?? false) && (port?.isNotEmpty ?? false);
|
||||
|
||||
bool get hasAuthCredentials => _wallet.type == WalletType.monero;
|
||||
|
||||
String get uri {
|
||||
var uri = address;
|
||||
|
||||
if (port != null && port.isNotEmpty) {
|
||||
uri += ':' + port;
|
||||
}
|
||||
|
||||
return uri;
|
||||
}
|
||||
|
||||
final WalletBase _wallet;
|
||||
final Box<Node> _nodeSource;
|
||||
|
||||
@action
|
||||
void reset() {
|
||||
address = '';
|
||||
port = '';
|
||||
login = '';
|
||||
password = '';
|
||||
}
|
||||
|
||||
@action
|
||||
Future<void> save() async {
|
||||
try {
|
||||
state = NodeIsCreating();
|
||||
final node =
|
||||
Node(uri: uri, type: _wallet.type, login: login, password: password);
|
||||
await _nodeSource.add(node);
|
||||
state = NodeCreatedSuccessfully();
|
||||
} catch (e) {
|
||||
state = NodeCreateOrEditViewModelFailure(e.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
abstract class NodeCreateOrEditViewModelState {}
|
||||
|
||||
class InitialNodeCreateOrEditViewModelState
|
||||
extends NodeCreateOrEditViewModelState {}
|
||||
|
||||
class NodeIsCreating extends NodeCreateOrEditViewModelState {}
|
||||
|
||||
class NodeCreatedSuccessfully extends NodeCreateOrEditViewModelState {}
|
||||
|
||||
class NodeCreateOrEditViewModelFailure extends NodeCreateOrEditViewModelState {
|
||||
NodeCreateOrEditViewModelFailure(this.error);
|
||||
|
||||
final String error;
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
import 'package:hive/hive.dart';
|
||||
import 'package:mobx/mobx.dart';
|
||||
import 'package:cake_wallet/core/wallet_base.dart';
|
||||
import 'package:cake_wallet/src/domain/common/node.dart';
|
||||
import 'package:cake_wallet/src/domain/common/node_list.dart';
|
||||
import 'package:cake_wallet/store/node_list_store.dart';
|
||||
|
||||
part 'node_list_view_model.g.dart';
|
||||
|
||||
class NodeListViewModel = NodeListViewModelBase with _$NodeListViewModel;
|
||||
|
||||
abstract class NodeListViewModelBase with Store {
|
||||
NodeListViewModelBase(this._nodeListStore, this._nodeSource, this._wallet);
|
||||
|
||||
@computed
|
||||
ObservableList<Node> get nodes => ObservableList<Node>.of(
|
||||
_nodeListStore.nodes.where((node) => node.type == _wallet.type));
|
||||
|
||||
final WalletBase _wallet;
|
||||
final Box<Node> _nodeSource;
|
||||
final NodeListStore _nodeListStore;
|
||||
|
||||
Future<void> reset() async => await resetToDefault(_nodeSource);
|
||||
|
||||
Future<void> delete(Node node) async => node.delete();
|
||||
}
|
||||
@@ -0,0 +1,94 @@
|
||||
import 'package:cake_wallet/core/address_validator.dart';
|
||||
import 'package:cake_wallet/core/amount_validator.dart';
|
||||
import 'package:cake_wallet/core/validator.dart';
|
||||
import 'package:cake_wallet/core/wallet_base.dart';
|
||||
import 'package:cake_wallet/bitcoin/bitcoin_wallet.dart';
|
||||
import 'package:cake_wallet/monero/monero_wallet.dart';
|
||||
import 'package:cake_wallet/src/domain/common/balance.dart';
|
||||
import 'package:cake_wallet/src/domain/common/calculate_estimated_fee.dart';
|
||||
import 'package:cake_wallet/src/domain/common/crypto_currency.dart';
|
||||
import 'package:cake_wallet/src/domain/common/fiat_currency.dart';
|
||||
import 'package:cake_wallet/src/domain/common/transaction_priority.dart';
|
||||
import 'package:cake_wallet/store/settings_store.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:mobx/mobx.dart';
|
||||
import 'package:cake_wallet/monero/monero_wallet_service.dart';
|
||||
import 'package:cake_wallet/bitcoin/bitcoin_wallet_creation_credentials.dart';
|
||||
import 'package:cake_wallet/core/wallet_creation_service.dart';
|
||||
import 'package:cake_wallet/core/wallet_credentials.dart';
|
||||
import 'package:cake_wallet/src/domain/common/wallet_type.dart';
|
||||
import 'package:cake_wallet/view_model/wallet_creation_vm.dart';
|
||||
|
||||
part 'send_view_model.g.dart';
|
||||
|
||||
abstract class SendViewModelState {}
|
||||
|
||||
class InitialSendViewModelState extends SendViewModelState {}
|
||||
|
||||
class TransactionIsCreating extends SendViewModelState {}
|
||||
|
||||
class TransactionCreatedSuccessfully extends SendViewModelState {}
|
||||
|
||||
class TransactionCommitting extends SendViewModelState {}
|
||||
|
||||
class TransactionCommitted extends SendViewModelState {}
|
||||
|
||||
class SendingFailed extends SendViewModelState {
|
||||
SendingFailed({@required this.error});
|
||||
|
||||
String error;
|
||||
}
|
||||
|
||||
class SendViewModel = SendViewModelBase with _$SendViewModel;
|
||||
|
||||
abstract class SendViewModelBase with Store {
|
||||
SendViewModelBase(this._wallet, this._settingsStore)
|
||||
: state = InitialSendViewModelState();
|
||||
|
||||
@observable
|
||||
SendViewModelState state;
|
||||
|
||||
@observable
|
||||
String fiatAmount;
|
||||
|
||||
@observable
|
||||
String cryptoAmount;
|
||||
|
||||
@observable
|
||||
String address;
|
||||
|
||||
FiatCurrency get fiat => _settingsStore.fiatCurrency;
|
||||
|
||||
TransactionPriority get transactionPriority =>
|
||||
_settingsStore.transactionPriority;
|
||||
|
||||
double get estimatedFee =>
|
||||
calculateEstimatedFee(priority: transactionPriority);
|
||||
|
||||
CryptoCurrency get currency => _wallet.currency;
|
||||
|
||||
Validator get amountValidator => AmountValidator(type: _wallet.type);
|
||||
|
||||
Validator get addressValidator => AddressValidator(type: _wallet.currency);
|
||||
|
||||
@computed
|
||||
String get balance {
|
||||
if (_wallet is MoneroWallet) {
|
||||
_wallet.balance.formattedUnlockedBalance;
|
||||
}
|
||||
|
||||
if (_wallet is BitcoinWallet) {
|
||||
_wallet.balance.confirmedFormatted;
|
||||
}
|
||||
|
||||
return '0.0';
|
||||
}
|
||||
|
||||
WalletBase _wallet;
|
||||
|
||||
SettingsStore _settingsStore;
|
||||
|
||||
Future<void> createTransaction() async {}
|
||||
|
||||
Future<void> commitTransaction() async {}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:cake_wallet/view_model/settings/settings_list_item.dart';
|
||||
|
||||
class LinkListItem extends SettingsListItem {
|
||||
LinkListItem(
|
||||
{@required String title,
|
||||
@required this.link,
|
||||
@required this.linkTitle,
|
||||
this.icon})
|
||||
: super(title);
|
||||
|
||||
final String icon;
|
||||
final String link;
|
||||
final String linkTitle;
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:cake_wallet/view_model/settings/settings_list_item.dart';
|
||||
|
||||
class PickerListItem<ItemType> extends SettingsListItem {
|
||||
PickerListItem(
|
||||
{@required String title,
|
||||
@required this.selectedItem,
|
||||
@required this.items})
|
||||
: super(title);
|
||||
|
||||
final ItemType Function() selectedItem;
|
||||
final List<ItemType> items;
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:cake_wallet/view_model/settings/settings_list_item.dart';
|
||||
|
||||
class RegularListItem extends SettingsListItem {
|
||||
RegularListItem({@required String title, this.handler}) : super(title);
|
||||
|
||||
final void Function(BuildContext context) handler;
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
abstract class SettingsListItem {
|
||||
SettingsListItem(this.title);
|
||||
|
||||
final String title;
|
||||
}
|
||||
@@ -0,0 +1,185 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:mobx/mobx.dart';
|
||||
import 'package:cake_wallet/routes.dart';
|
||||
import 'package:cake_wallet/generated/i18n.dart';
|
||||
import 'package:cake_wallet/store/settings_store.dart';
|
||||
import 'package:cake_wallet/src/domain/common/balance_display_mode.dart';
|
||||
import 'package:cake_wallet/src/domain/common/fiat_currency.dart';
|
||||
import 'package:cake_wallet/src/domain/common/node.dart';
|
||||
import 'package:cake_wallet/src/domain/common/transaction_priority.dart';
|
||||
import 'package:cake_wallet/src/stores/action_list/action_list_display_mode.dart';
|
||||
import 'package:cake_wallet/src/screens/auth/auth_page.dart';
|
||||
import 'package:cake_wallet/view_model/settings/link_list_item.dart';
|
||||
import 'package:cake_wallet/view_model/settings/picker_list_item.dart';
|
||||
import 'package:cake_wallet/view_model/settings/regular_list_item.dart';
|
||||
import 'package:cake_wallet/view_model/settings/settings_list_item.dart';
|
||||
import 'package:cake_wallet/view_model/settings/switcher_list_item.dart';
|
||||
|
||||
part 'settings_view_model.g.dart';
|
||||
|
||||
class SettingsViewModel = SettingsViewModelBase with _$SettingsViewModel;
|
||||
|
||||
abstract class SettingsViewModelBase with Store {
|
||||
SettingsViewModelBase(this._settingsStore) : itemHeaders = {} {
|
||||
sections = [
|
||||
[
|
||||
PickerListItem(
|
||||
title: S.current.settings_display_balance_as,
|
||||
items: BalanceDisplayMode.all,
|
||||
selectedItem: () => balanceDisplayMode),
|
||||
PickerListItem(
|
||||
title: S.current.settings_currency,
|
||||
items: FiatCurrency.all,
|
||||
selectedItem: () => fiatCurrency),
|
||||
PickerListItem(
|
||||
title: S.current.settings_fee_priority,
|
||||
items: TransactionPriority.all,
|
||||
selectedItem: () => transactionPriority),
|
||||
SwitcherListItem(
|
||||
title: S.current.settings_save_recipient_address,
|
||||
value: () => shouldSaveRecipientAddress,
|
||||
onValueChange: (bool value) => shouldSaveRecipientAddress = value)
|
||||
],
|
||||
[
|
||||
RegularListItem(
|
||||
title: S.current.settings_change_pin,
|
||||
handler: (BuildContext context) {
|
||||
Navigator.of(context).pushNamed(Routes.auth,
|
||||
arguments: (bool isAuthenticatedSuccessfully,
|
||||
AuthPageState auth) =>
|
||||
isAuthenticatedSuccessfully
|
||||
? Navigator.of(context).popAndPushNamed(
|
||||
Routes.setupPin,
|
||||
arguments:
|
||||
(BuildContext setupPinContext, String _) =>
|
||||
Navigator.of(context).pop())
|
||||
: null);
|
||||
}),
|
||||
RegularListItem(
|
||||
title: S.current.settings_change_language,
|
||||
handler: (BuildContext context) =>
|
||||
Navigator.of(context).pushNamed(Routes.changeLanguage),
|
||||
),
|
||||
SwitcherListItem(
|
||||
title: S.current.settings_allow_biometrical_authentication,
|
||||
value: () => allowBiometricalAuthentication,
|
||||
onValueChange: (bool value) =>
|
||||
allowBiometricalAuthentication = value),
|
||||
SwitcherListItem(
|
||||
title: S.current.settings_dark_mode,
|
||||
value: () => _settingsStore.isDarkTheme,
|
||||
onValueChange: (bool value) {
|
||||
// FIXME: Implement me
|
||||
})
|
||||
],
|
||||
[
|
||||
LinkListItem(
|
||||
title: 'Email',
|
||||
linkTitle: 'support@cakewallet.com',
|
||||
link: 'mailto:support@cakewallet.com'),
|
||||
LinkListItem(
|
||||
title: 'Telegram',
|
||||
icon: 'assets/images/Telegram.png',
|
||||
linkTitle: 'Cake_Wallet',
|
||||
link: 'https:t.me/cakewallet_bot'),
|
||||
LinkListItem(
|
||||
title: 'Twitter',
|
||||
icon: 'assets/images/Twitter.png',
|
||||
linkTitle: '@CakeWalletXMR',
|
||||
link: 'https:twitter.com/CakewalletXMR'),
|
||||
LinkListItem(
|
||||
title: 'ChangeNow',
|
||||
icon: 'assets/images/change_now.png',
|
||||
linkTitle: 'support@changenow.io',
|
||||
link: 'mailto:support@changenow.io'),
|
||||
LinkListItem(
|
||||
title: 'Morph',
|
||||
icon: 'assets/images/morph_icon.png',
|
||||
linkTitle: 'support@morphtoken.com',
|
||||
link: 'mailto:support@morphtoken.com'),
|
||||
LinkListItem(
|
||||
title: 'XMR.to',
|
||||
icon: 'assets/images/xmr_btc.png',
|
||||
linkTitle: 'support@xmr.to',
|
||||
link: 'mailto:support@xmr.to'),
|
||||
RegularListItem(
|
||||
title: S.current.settings_terms_and_conditions,
|
||||
handler: (BuildContext context) =>
|
||||
Navigator.of(context).pushNamed(Routes.disclaimer),
|
||||
)
|
||||
]
|
||||
];
|
||||
}
|
||||
|
||||
@computed
|
||||
Node get node => _settingsStore.node;
|
||||
|
||||
@computed
|
||||
FiatCurrency get fiatCurrency => _settingsStore.fiatCurrency;
|
||||
|
||||
@computed
|
||||
ObservableList<ActionListDisplayMode> get actionlistDisplayMode =>
|
||||
_settingsStore.actionlistDisplayMode;
|
||||
|
||||
@computed
|
||||
TransactionPriority get transactionPriority =>
|
||||
_settingsStore.transactionPriority;
|
||||
|
||||
@computed
|
||||
BalanceDisplayMode get balanceDisplayMode =>
|
||||
_settingsStore.balanceDisplayMode;
|
||||
|
||||
@computed
|
||||
bool get shouldSaveRecipientAddress =>
|
||||
_settingsStore.shouldSaveRecipientAddress;
|
||||
|
||||
@action
|
||||
set shouldSaveRecipientAddress(bool value) =>
|
||||
_settingsStore.shouldSaveRecipientAddress = value;
|
||||
|
||||
@computed
|
||||
bool get allowBiometricalAuthentication =>
|
||||
_settingsStore.allowBiometricalAuthentication;
|
||||
|
||||
@action
|
||||
set allowBiometricalAuthentication(bool value) =>
|
||||
_settingsStore.allowBiometricalAuthentication = value;
|
||||
|
||||
// @observable
|
||||
// bool isDarkTheme;
|
||||
//
|
||||
// @observable
|
||||
// int defaultPinLength;
|
||||
|
||||
// @observable
|
||||
final Map<String, String> itemHeaders;
|
||||
List<List<SettingsListItem>> sections;
|
||||
final SettingsStore _settingsStore;
|
||||
|
||||
@action
|
||||
void toggleTransactionsDisplay() =>
|
||||
actionlistDisplayMode.contains(ActionListDisplayMode.transactions)
|
||||
? _hideTransaction()
|
||||
: _showTransaction();
|
||||
|
||||
@action
|
||||
void toggleTradesDisplay() =>
|
||||
actionlistDisplayMode.contains(ActionListDisplayMode.trades)
|
||||
? _hideTrades()
|
||||
: _showTrades();
|
||||
|
||||
@action
|
||||
void _hideTransaction() =>
|
||||
actionlistDisplayMode.remove(ActionListDisplayMode.transactions);
|
||||
|
||||
@action
|
||||
void _hideTrades() =>
|
||||
actionlistDisplayMode.remove(ActionListDisplayMode.trades);
|
||||
|
||||
@action
|
||||
void _showTransaction() =>
|
||||
actionlistDisplayMode.add(ActionListDisplayMode.transactions);
|
||||
|
||||
@action
|
||||
void _showTrades() => actionlistDisplayMode.add(ActionListDisplayMode.trades);
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:cake_wallet/view_model/settings/settings_list_item.dart';
|
||||
|
||||
class SwitcherListItem extends SettingsListItem {
|
||||
SwitcherListItem(
|
||||
{@required String title,
|
||||
@required this.value,
|
||||
@required this.onValueChange})
|
||||
: super(title);
|
||||
|
||||
final bool Function() value;
|
||||
final void Function(bool value) onValueChange;
|
||||
}
|
||||
+1
-1
@@ -1,3 +1,3 @@
|
||||
import 'package:cake_wallet/utils/list_item.dart';
|
||||
|
||||
class AccountListHeader extends ListItem {}
|
||||
class WalletAccountListHeader extends ListItem {}
|
||||
+5
-5
@@ -4,10 +4,10 @@ import 'package:cake_wallet/core/wallet_base.dart';
|
||||
import 'package:cake_wallet/bitcoin/bitcoin_wallet.dart';
|
||||
import 'package:cake_wallet/monero/monero_wallet.dart';
|
||||
|
||||
part 'address_edit_or_create_view_model.g.dart';
|
||||
part 'wallet_address_edit_or_create_view_model.g.dart';
|
||||
|
||||
class AddressEditOrCreateViewModel = AddressEditOrCreateViewModelBase
|
||||
with _$AddressEditOrCreateViewModel;
|
||||
class WalletAddressEditOrCreateViewModel = WalletAddressEditOrCreateViewModelBase
|
||||
with _$WalletAddressEditOrCreateViewModel;
|
||||
|
||||
abstract class AddressEditOrCreateState {}
|
||||
|
||||
@@ -23,8 +23,8 @@ class AddressEditOrCreateStateFailure extends AddressEditOrCreateState {
|
||||
String error;
|
||||
}
|
||||
|
||||
abstract class AddressEditOrCreateViewModelBase with Store {
|
||||
AddressEditOrCreateViewModelBase({@required WalletBase wallet, dynamic item})
|
||||
abstract class WalletAddressEditOrCreateViewModelBase with Store {
|
||||
WalletAddressEditOrCreateViewModelBase({@required WalletBase wallet, dynamic item})
|
||||
: isEdit = item != null,
|
||||
state = AddressEditOrCreateStateInitial(),
|
||||
label = item?.name as String,
|
||||
+1
-1
@@ -1,3 +1,3 @@
|
||||
import 'package:cake_wallet/utils/list_item.dart';
|
||||
|
||||
class AddressListHeader extends ListItem {}
|
||||
class WalletAddressListHeader extends ListItem {}
|
||||
+2
-2
@@ -1,8 +1,8 @@
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:cake_wallet/utils/list_item.dart';
|
||||
|
||||
class AddressListItem extends ListItem {
|
||||
const AddressListItem({@required this.address, this.name, this.id})
|
||||
class WalletAddressListItem extends ListItem {
|
||||
const WalletAddressListItem({@required this.address, this.name, this.id})
|
||||
: super();
|
||||
|
||||
final int id;
|
||||
+14
-14
@@ -4,14 +4,14 @@ import 'package:cake_wallet/bitcoin/bitcoin_wallet.dart';
|
||||
import 'package:cake_wallet/monero/monero_wallet.dart';
|
||||
import 'package:cake_wallet/core/wallet_base.dart';
|
||||
import 'package:cake_wallet/utils/list_item.dart';
|
||||
import 'package:cake_wallet/view_model/address_list/account_list_header.dart';
|
||||
import 'package:cake_wallet/view_model/address_list/address_list_header.dart';
|
||||
import 'package:cake_wallet/view_model/address_list/address_list_item.dart';
|
||||
import 'package:cake_wallet/view_model/wallet_address_list/wallet_account_list_header.dart';
|
||||
import 'package:cake_wallet/view_model/wallet_address_list/wallet_address_list_header.dart';
|
||||
import 'package:cake_wallet/view_model/wallet_address_list/wallet_address_list_item.dart';
|
||||
|
||||
part 'address_list_view_model.g.dart';
|
||||
part 'wallet_address_list_view_model.g.dart';
|
||||
|
||||
class AddressListViewModel = AddressListViewModelBase
|
||||
with _$AddressListViewModel;
|
||||
class WalletAddressListViewModel = WalletAddressListViewModelBase
|
||||
with _$WalletAddressListViewModel;
|
||||
|
||||
abstract class PaymentURI {
|
||||
PaymentURI({this.amount, this.address});
|
||||
@@ -52,8 +52,8 @@ class BitcoinURI extends PaymentURI {
|
||||
}
|
||||
}
|
||||
|
||||
abstract class AddressListViewModelBase with Store {
|
||||
AddressListViewModelBase({@required WalletBase wallet}) {
|
||||
abstract class WalletAddressListViewModelBase with Store {
|
||||
WalletAddressListViewModelBase({@required WalletBase wallet}) {
|
||||
hasAccounts = _wallet is MoneroWallet;
|
||||
_wallet = wallet;
|
||||
_init();
|
||||
@@ -63,7 +63,7 @@ abstract class AddressListViewModelBase with Store {
|
||||
String amount;
|
||||
|
||||
@computed
|
||||
AddressListItem get address => AddressListItem(address: _wallet.address);
|
||||
WalletAddressListItem get address => WalletAddressListItem(address: _wallet.address);
|
||||
|
||||
@computed
|
||||
PaymentURI get uri {
|
||||
@@ -89,7 +89,7 @@ abstract class AddressListViewModelBase with Store {
|
||||
|
||||
if (wallet is MoneroWallet) {
|
||||
addressList.addAll(wallet.subaddressList.subaddresses.map((subaddress) =>
|
||||
AddressListItem(
|
||||
WalletAddressListItem(
|
||||
id: subaddress.id,
|
||||
name: subaddress.label,
|
||||
address: subaddress.address)));
|
||||
@@ -97,14 +97,14 @@ abstract class AddressListViewModelBase with Store {
|
||||
|
||||
if (wallet is BitcoinWallet) {
|
||||
final bitcoinAddresses = wallet.addresses.map(
|
||||
(addr) => AddressListItem(name: addr.label, address: addr.address));
|
||||
(addr) => WalletAddressListItem(name: addr.label, address: addr.address));
|
||||
addressList.addAll(bitcoinAddresses);
|
||||
}
|
||||
|
||||
return addressList;
|
||||
}
|
||||
|
||||
set address(AddressListItem address) => _wallet.address = address.address;
|
||||
set address(WalletAddressListItem address) => _wallet.address = address.address;
|
||||
|
||||
bool hasAccounts;
|
||||
|
||||
@@ -127,9 +127,9 @@ abstract class AddressListViewModelBase with Store {
|
||||
_baseItems = [];
|
||||
|
||||
if (_wallet is MoneroWallet) {
|
||||
_baseItems.add(AccountListHeader());
|
||||
_baseItems.add(WalletAccountListHeader());
|
||||
}
|
||||
|
||||
_baseItems.add(AddressListHeader());
|
||||
_baseItems.add(WalletAddressListHeader());
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,6 @@
|
||||
import 'package:cake_wallet/src/domain/common/wallet_info.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:hive/hive.dart';
|
||||
import 'package:mobx/mobx.dart';
|
||||
import 'package:cake_wallet/core/wallet_credentials.dart';
|
||||
import 'package:cake_wallet/src/domain/common/wallet_type.dart';
|
||||
@@ -9,7 +11,8 @@ part 'wallet_creation_vm.g.dart';
|
||||
class WalletCreationVM = WalletCreationVMBase with _$WalletCreationVM;
|
||||
|
||||
abstract class WalletCreationVMBase with Store {
|
||||
WalletCreationVMBase({@required this.type}) {
|
||||
WalletCreationVMBase(this._walletInfoSource,
|
||||
{@required this.type, @required this.isRecovery}) {
|
||||
state = InitialWalletCreationState();
|
||||
name = '';
|
||||
}
|
||||
@@ -20,12 +23,24 @@ abstract class WalletCreationVMBase with Store {
|
||||
@observable
|
||||
WalletCreationState state;
|
||||
|
||||
WalletType type;
|
||||
final WalletType type;
|
||||
|
||||
final bool isRecovery;
|
||||
|
||||
Box<WalletInfo> _walletInfoSource;
|
||||
|
||||
Future<void> create({dynamic options}) async {
|
||||
try {
|
||||
state = WalletCreating();
|
||||
await process(getCredentials(options));
|
||||
final id = walletTypeToString(type).toLowerCase() + '_' + name;
|
||||
final walletInfo = WalletInfo(
|
||||
id: id,
|
||||
name: name,
|
||||
type: type,
|
||||
isRecovery: isRecovery,
|
||||
restoreHeight: 0);
|
||||
await _walletInfoSource.add(walletInfo);
|
||||
state = WalletCreatedSuccessfully();
|
||||
} catch (e) {
|
||||
state = WalletCreationFailure(error: e.toString());
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
import 'package:mobx/mobx.dart';
|
||||
import 'package:cake_wallet/generated/i18n.dart';
|
||||
import 'package:cake_wallet/core/wallet_base.dart';
|
||||
import 'package:cake_wallet/monero/monero_wallet.dart';
|
||||
import 'package:cake_wallet/bitcoin/bitcoin_wallet.dart';
|
||||
import 'package:cake_wallet/src/screens/transaction_details/standart_list_item.dart';
|
||||
|
||||
part 'wallet_keys_view_model.g.dart';
|
||||
|
||||
class WalletKeysViewModel = WalletKeysViewModelBase with _$WalletKeysViewModel;
|
||||
|
||||
abstract class WalletKeysViewModelBase with Store {
|
||||
WalletKeysViewModelBase(WalletBase wallet)
|
||||
: items = ObservableList<StandartListItem>() {
|
||||
if (wallet is MoneroWallet) {
|
||||
final keys = wallet.keys;
|
||||
|
||||
items.addAll([
|
||||
StandartListItem(
|
||||
title: S.current.spend_key_public, value: keys.publicSpendKey),
|
||||
StandartListItem(
|
||||
title: S.current.spend_key_private, value: keys.privateSpendKey),
|
||||
StandartListItem(
|
||||
title: S.current.view_key_public, value: keys.publicViewKey),
|
||||
StandartListItem(
|
||||
title: S.current.view_key_private, value: keys.privateViewKey),
|
||||
]);
|
||||
}
|
||||
|
||||
if (wallet is BitcoinWallet) {
|
||||
final keys = wallet.keys;
|
||||
|
||||
items.addAll([
|
||||
StandartListItem(title: 'WIF', value: keys.wif),
|
||||
StandartListItem(title: 'Public key', value: keys.publicKey),
|
||||
StandartListItem(title: 'Private key', value: keys.privateKey)
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
final ObservableList<StandartListItem> items;
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:cake_wallet/src/domain/common/wallet_type.dart';
|
||||
|
||||
class WalletListItem {
|
||||
const WalletListItem(
|
||||
{@required this.name, @required this.type, this.isCurrent = false});
|
||||
|
||||
final String name;
|
||||
final WalletType type;
|
||||
final bool isCurrent;
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
import 'package:hive/hive.dart';
|
||||
import 'package:mobx/mobx.dart';
|
||||
import 'package:cake_wallet/store/app_store.dart';
|
||||
import 'package:cake_wallet/core/key_service.dart';
|
||||
import 'package:cake_wallet/core/wallet_service.dart';
|
||||
import 'package:cake_wallet/bitcoin/bitcoin_wallet_service.dart';
|
||||
import 'package:cake_wallet/monero/monero_wallet_service.dart';
|
||||
import 'package:cake_wallet/view_model/wallet_list/wallet_list_item.dart';
|
||||
import 'package:cake_wallet/src/domain/common/wallet_type.dart';
|
||||
import 'package:cake_wallet/src/domain/common/wallet_info.dart';
|
||||
|
||||
part 'wallet_list_view_model.g.dart';
|
||||
|
||||
class WalletListViewModel = WalletListViewModelBase with _$WalletListViewModel;
|
||||
|
||||
abstract class WalletListViewModelBase with Store {
|
||||
WalletListViewModelBase(
|
||||
this._walletInfoSource, this._appStore, this._keyService) {
|
||||
wallets = ObservableList<WalletListItem>();
|
||||
wallets.addAll(_walletInfoSource.values.map((info) => WalletListItem(
|
||||
name: info.name,
|
||||
type: info.type,
|
||||
isCurrent: info.name == _appStore.wallet.name &&
|
||||
info.type == _appStore.wallet.type)));
|
||||
}
|
||||
|
||||
@observable
|
||||
ObservableList<WalletListItem> wallets;
|
||||
|
||||
final AppStore _appStore;
|
||||
final Box<WalletInfo> _walletInfoSource;
|
||||
final KeyService _keyService;
|
||||
|
||||
@action
|
||||
Future<void> loadWallet(WalletListItem wallet) async {
|
||||
final password =
|
||||
await _keyService.getWalletPassword(walletName: wallet.name);
|
||||
final walletService = _getWalletService(wallet.type);
|
||||
_appStore.wallet = await walletService.openWallet(wallet.name, password);
|
||||
}
|
||||
|
||||
@action
|
||||
Future<void> remove(WalletListItem wallet) async {}
|
||||
|
||||
WalletService _getWalletService(WalletType type) {
|
||||
switch (type) {
|
||||
case WalletType.monero:
|
||||
return MoneroWalletService();
|
||||
case WalletType.bitcoin:
|
||||
return BitcoinWalletService();
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,11 @@
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:hive/hive.dart';
|
||||
import 'package:mobx/mobx.dart';
|
||||
import 'package:cake_wallet/monero/monero_wallet_service.dart';
|
||||
import 'package:cake_wallet/bitcoin/bitcoin_wallet_creation_credentials.dart';
|
||||
import 'package:cake_wallet/core/wallet_creation_service.dart';
|
||||
import 'package:cake_wallet/core/wallet_credentials.dart';
|
||||
import 'package:cake_wallet/src/domain/common/wallet_info.dart';
|
||||
import 'package:cake_wallet/src/domain/common/wallet_type.dart';
|
||||
import 'package:cake_wallet/view_model/wallet_creation_vm.dart';
|
||||
|
||||
@@ -12,9 +14,9 @@ part 'wallet_new_vm.g.dart';
|
||||
class WalletNewVM = WalletNewVMBase with _$WalletNewVM;
|
||||
|
||||
abstract class WalletNewVMBase extends WalletCreationVM with Store {
|
||||
WalletNewVMBase(this._walletCreationService, {@required WalletType type})
|
||||
WalletNewVMBase(this._walletCreationService, Box<WalletInfo> walletInfoSource, {@required WalletType type})
|
||||
: selectedMnemonicLanguage = '',
|
||||
super(type: type);
|
||||
super(walletInfoSource, type: type, isRecovery: false);
|
||||
|
||||
@observable
|
||||
String selectedMnemonicLanguage;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:hive/hive.dart';
|
||||
import 'package:mobx/mobx.dart';
|
||||
import 'package:cake_wallet/monero/monero_wallet_service.dart';
|
||||
import 'package:cake_wallet/bitcoin/bitcoin_wallet_creation_credentials.dart';
|
||||
@@ -7,6 +8,7 @@ import 'package:cake_wallet/core/wallet_creation_service.dart';
|
||||
import 'package:cake_wallet/core/wallet_credentials.dart';
|
||||
import 'package:cake_wallet/src/domain/common/wallet_type.dart';
|
||||
import 'package:cake_wallet/view_model/wallet_creation_vm.dart';
|
||||
import 'package:cake_wallet/src/domain/common/wallet_info.dart';
|
||||
|
||||
part 'wallet_restoration_from_seed_vm.g.dart';
|
||||
|
||||
@@ -15,9 +17,9 @@ class WalletRestorationFromSeedVM = WalletRestorationFromSeedVMBase
|
||||
|
||||
abstract class WalletRestorationFromSeedVMBase extends WalletCreationVM
|
||||
with Store {
|
||||
WalletRestorationFromSeedVMBase(this._walletCreationService,
|
||||
WalletRestorationFromSeedVMBase(this._walletCreationService, Box<WalletInfo> walletInfoSource,
|
||||
{@required WalletType type, @required this.language, this.seed})
|
||||
: super(type: type);
|
||||
: super(walletInfoSource, type: type, isRecovery: true);
|
||||
|
||||
@observable
|
||||
String seed;
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
import 'package:mobx/mobx.dart';
|
||||
import 'package:cake_wallet/core/wallet_base.dart';
|
||||
|
||||
part 'wallet_seed_view_model.g.dart';
|
||||
|
||||
class WalletSeedViewModel = WalletSeedViewModelBase with _$WalletSeedViewModel;
|
||||
|
||||
abstract class WalletSeedViewModelBase with Store {
|
||||
WalletSeedViewModelBase(WalletBase wallet)
|
||||
: name = wallet.name,
|
||||
seed = wallet.seed;
|
||||
|
||||
@observable
|
||||
String name;
|
||||
|
||||
@observable
|
||||
String seed;
|
||||
}
|
||||
Reference in New Issue
Block a user