Part 1

M committed Sep 21, 2020 at 14:50 UTC e4ebfc94b293a8b14f1fcddc983ebe3ae85a9011
273 files changed +2474 -7287
ios/Flutter/.last_build_id
+1 -1
@@ -1 +1 @@
1 -a2dce69f54a78f5b00e19850e4b2d402
\ No newline at end of file
1 +bc336703210c48e30d7216fac3fe1c0f
\ No newline at end of file
ios/Podfile.lock
+12
@@ -47,6 +47,8 @@ PODS:
47 - Flutter
48 - path_provider_macos (0.0.1):
49 - Flutter
50 + - path_provider_windows (0.0.1):
51 + - Flutter
52 - Reachability (3.2)
53 - share (0.0.1):
54 - Flutter
@@ -67,6 +69,8 @@ PODS:
69 - Flutter
70 - url_launcher_web (0.0.1):
71 - Flutter
72 + - url_launcher_windows (0.0.1):
73 + - Flutter
74
75 DEPENDENCIES:
76 - barcode_scan (from `.symlinks/plugins/barcode_scan/ios`)
@@ -84,6 +88,7 @@ DEPENDENCIES:
88 - path_provider (from `.symlinks/plugins/path_provider/ios`)
89 - path_provider_linux (from `.symlinks/plugins/path_provider_linux/ios`)
90 - path_provider_macos (from `.symlinks/plugins/path_provider_macos/ios`)
91 + - path_provider_windows (from `.symlinks/plugins/path_provider_windows/ios`)
92 - share (from `.symlinks/plugins/share/ios`)
93 - shared_preferences (from `.symlinks/plugins/shared_preferences/ios`)
94 - shared_preferences_linux (from `.symlinks/plugins/shared_preferences_linux/ios`)
@@ -93,6 +98,7 @@ DEPENDENCIES:
98 - url_launcher_linux (from `.symlinks/plugins/url_launcher_linux/ios`)
99 - url_launcher_macos (from `.symlinks/plugins/url_launcher_macos/ios`)
100 - url_launcher_web (from `.symlinks/plugins/url_launcher_web/ios`)
101 + - url_launcher_windows (from `.symlinks/plugins/url_launcher_windows/ios`)
102
103 SPEC REPOS:
104 trunk:
@@ -131,6 +137,8 @@ EXTERNAL SOURCES:
137 :path: ".symlinks/plugins/path_provider_linux/ios"
138 path_provider_macos:
139 :path: ".symlinks/plugins/path_provider_macos/ios"
140 + path_provider_windows:
141 + :path: ".symlinks/plugins/path_provider_windows/ios"
142 share:
143 :path: ".symlinks/plugins/share/ios"
144 shared_preferences:
@@ -149,6 +157,8 @@ EXTERNAL SOURCES:
157 :path: ".symlinks/plugins/url_launcher_macos/ios"
158 url_launcher_web:
159 :path: ".symlinks/plugins/url_launcher_web/ios"
160 + url_launcher_windows:
161 + :path: ".symlinks/plugins/url_launcher_windows/ios"
162
163 SPEC CHECKSUMS:
164 barcode_scan: a5c27959edfafaa0c771905bad0b29d6d39e4479
@@ -167,6 +177,7 @@ SPEC CHECKSUMS:
177 path_provider: abfe2b5c733d04e238b0d8691db0cfd63a27a93c
178 path_provider_linux: 4d630dc393e1f20364f3e3b4a2ff41d9674a84e4
179 path_provider_macos: f760a3c5b04357c380e2fddb6f9db6f3015897e0
180 + path_provider_windows: a2b81600c677ac1959367280991971cb9a1edb3b
181 Reachability: 33e18b67625424e47b6cde6d202dce689ad7af96
182 share: 0b2c3e82132f5888bccca3351c504d0003b3b410
183 shared_preferences: af6bfa751691cdc24be3045c43ec037377ada40d
@@ -178,6 +189,7 @@ SPEC CHECKSUMS:
189 url_launcher_linux: ac237cb7a8058736e4aae38bdbcc748a4b394cc0
190 url_launcher_macos: fd7894421cd39320dce5f292fc99ea9270b2a313
191 url_launcher_web: e5527357f037c87560776e36436bf2b0288b965c
192 + url_launcher_windows: 683d7c283894db8d1914d3ab2223b20cc1ad95d5
193
194 PODFILE CHECKSUM: c34e2287a9ccaa606aeceab922830efb9a6ff69a
195
lib/bitcoin/bitcoin_amount_format.dart
+4 -1
@@ -1,5 +1,5 @@
1 import 'package:intl/intl.dart';
2 -import 'package:cake_wallet/src/domain/common/crypto_amount_format.dart';
2 +import 'package:cake_wallet/entities/crypto_amount_format.dart';
3
4 const bitcoinAmountLength = 8;
5 const bitcoinAmountDivider = 100000000;
@@ -11,3 +11,6 @@ String bitcoinAmountToString({int amount}) =>
11 bitcoinAmountFormat.format(cryptoAmountToDouble(amount: amount, divider: bitcoinAmountDivider));
12
13 double bitcoinAmountToDouble({int amount}) => cryptoAmountToDouble(amount: amount, divider: bitcoinAmountDivider);
14 +
15 +int doubleToBitcoinAmount(double amount) =>
16 + (amount * bitcoinAmountDivider).toInt();
\ No newline at end of file
lib/bitcoin/bitcoin_balance.dart
+1 -1
@@ -2,7 +2,7 @@ import 'dart:convert';
2
3 import 'package:flutter/foundation.dart';
4 import 'package:cake_wallet/bitcoin/bitcoin_amount_format.dart';
5 -import 'package:cake_wallet/src/domain/common/balance.dart';
5 +import 'package:cake_wallet/entities/balance.dart';
6
7 class BitcoinBalance extends Balance {
8 const BitcoinBalance({@required this.confirmed, @required this.unconfirmed}) : super();
lib/bitcoin/bitcoin_transaction_credentials.dart
+1 -1
@@ -1,4 +1,4 @@
1 -import 'package:cake_wallet/src/domain/common/transaction_priority.dart';
1 +import 'package:cake_wallet/entities/transaction_priority.dart';
2
3 class BitcoinTransactionCredentials {
4 BitcoinTransactionCredentials(this.address, this.amount, this.priority);
lib/bitcoin/bitcoin_transaction_history.dart
+1 -10
@@ -58,16 +58,7 @@ abstract class BitcoinTransactionHistoryBase
58 final histories =
59 wallet.scriptHashes.map((scriptHash) => eclient.getHistory(scriptHash));
60 final _historiesWithDetails = await Future.wait(histories)
61 - .then((histories) => histories
62 -// .map((h) => h.where((tx) {
63 -// final height = tx['height'] as int ?? 0;
64 -// // FIXME: Filter only needed transactions
65 -// final _tx = get(tx['tx_hash'] as String);
66 -//
67 -// return height == 0 || height > _height;
68 -// }))
69 - .expand((i) => i)
70 - .toList())
61 + .then((histories) => histories.expand((i) => i).toList())
62 .then((histories) => histories.map((tx) => fetchTransactionInfo(
63 hash: tx['tx_hash'] as String, height: tx['height'] as int)));
64 final historiesWithDetails = await Future.wait(_historiesWithDetails);
lib/bitcoin/bitcoin_transaction_info.dart
+6 -9
@@ -1,22 +1,22 @@
1 import 'package:flutter/foundation.dart';
2 import 'package:bitcoin_flutter/bitcoin_flutter.dart' as bitcoin;
3 -import 'package:cake_wallet/bitcoin/bitcoin_address_record.dart';
3 import 'package:bitcoin_flutter/src/payments/index.dart' show PaymentData;
4 +import 'package:cake_wallet/bitcoin/bitcoin_address_record.dart';
5 import 'package:cake_wallet/bitcoin/bitcoin_amount_format.dart';
6 -import 'package:cake_wallet/src/domain/bitcoin/bitcoin_amount_format.dart';
7 -import 'package:cake_wallet/src/domain/common/transaction_direction.dart';
8 -import 'package:cake_wallet/src/domain/common/transaction_info.dart';
9 -import 'package:cake_wallet/src/domain/common/format_amount.dart';
6 +import 'package:cake_wallet/entities/transaction_direction.dart';
7 +import 'package:cake_wallet/entities/transaction_info.dart';
8 +import 'package:cake_wallet/entities/format_amount.dart';
9
10 class BitcoinTransactionInfo extends TransactionInfo {
11 BitcoinTransactionInfo(
13 - {@required this.id,
12 + {@required String id,
13 @required int height,
14 @required int amount,
15 @required TransactionDirection direction,
16 @required bool isPending,
17 @required DateTime date,
18 @required int confirmations}) {
19 + this.id = id;
20 this.height = height;
21 this.amount = amount;
22 this.direction = direction;
@@ -97,7 +97,6 @@ class BitcoinTransactionInfo extends TransactionInfo {
97 ? DateTime.fromMillisecondsSinceEpoch(timestamp * 1000)
98 : DateTime.now();
99
100 - // FIXME: Get transaction is pending
100 return BitcoinTransactionInfo(
101 id: tx.getId(),
102 height: height,
@@ -119,8 +118,6 @@ class BitcoinTransactionInfo extends TransactionInfo {
118 confirmations: data['confirmations'] as int);
119 }
120
122 - final String id;
123 -
121 String _fiatAmount;
122
123 @override
lib/bitcoin/bitcoin_wallet.dart
+10 -5
@@ -14,15 +14,15 @@ import 'package:cake_wallet/bitcoin/electrum.dart';
14 import 'package:cake_wallet/bitcoin/pending_bitcoin_transaction.dart';
15 import 'package:cake_wallet/bitcoin/script_hash.dart';
16 import 'package:cake_wallet/bitcoin/utils.dart';
17 -import 'package:cake_wallet/src/domain/bitcoin/bitcoin_amount_format.dart';
18 -import 'package:cake_wallet/src/domain/common/sync_status.dart';
19 -import 'package:cake_wallet/src/domain/common/transaction_priority.dart';
20 -import 'package:cake_wallet/src/domain/common/wallet_info.dart';
17 +import 'package:cake_wallet/bitcoin/bitcoin_amount_format.dart';
18 +import 'package:cake_wallet/entities/sync_status.dart';
19 +import 'package:cake_wallet/entities/transaction_priority.dart';
20 +import 'package:cake_wallet/entities/wallet_info.dart';
21 import 'package:cake_wallet/bitcoin/bitcoin_transaction_history.dart';
22 import 'package:cake_wallet/bitcoin/bitcoin_address_record.dart';
23 import 'package:cake_wallet/bitcoin/file.dart';
24 import 'package:cake_wallet/bitcoin/bitcoin_balance.dart';
25 -import 'package:cake_wallet/src/domain/common/node.dart';
25 +import 'package:cake_wallet/entities/node.dart';
26 import 'package:cake_wallet/core/wallet_base.dart';
27
28 part 'bitcoin_wallet.g.dart';
@@ -316,6 +316,11 @@ abstract class BitcoinWalletBase extends WalletBase<BitcoinBalance> with Store {
316 bitcoin.ECPair keyPairFor({@required int index}) =>
317 generateKeyPair(hd: hd, index: index);
318
319 + @override
320 + Future<void> rescan({int height}) async {
321 + // FIXME: Unimplemented
322 + }
323 +
324 void _subscribeForUpdates() {
325 scriptHashes.forEach((sh) async {
326 await _scripthashesUpdateSubject[sh]?.close();
lib/bitcoin/bitcoin_wallet_service.dart
+2 -2
@@ -4,8 +4,8 @@ import 'package:cake_wallet/bitcoin/file.dart';
4 import 'package:cake_wallet/bitcoin/bitcoin_wallet_creation_credentials.dart';
5 import 'package:cake_wallet/core/wallet_service.dart';
6 import 'package:cake_wallet/bitcoin/bitcoin_wallet.dart';
7 -import 'package:cake_wallet/src/domain/common/pathForWallet.dart';
8 -import 'package:cake_wallet/src/domain/common/wallet_type.dart';
7 +import 'package:cake_wallet/entities/pathForWallet.dart';
8 +import 'package:cake_wallet/entities/wallet_type.dart';
9
10 class BitcoinWalletService extends WalletService<
11 BitcoinNewWalletCredentials,
lib/bitcoin/electrum.dart
+2 -2
@@ -40,6 +40,7 @@ class ElectrumClient {
40 _tasks = {};
41
42 static const connectionTimeout = Duration(seconds: 5);
43 + static const aliveTimerDuration = Duration(seconds: 2);
44
45 bool get isConnected => _isConnected;
46 Socket socket;
@@ -97,8 +98,7 @@ class ElectrumClient {
98
99 void keepAlive() {
100 _aliveTimer?.cancel();
100 - // FIXME: Unnamed constant.
101 - _aliveTimer = Timer.periodic(Duration(seconds: 2), (_) async => ping());
101 + _aliveTimer = Timer.periodic(aliveTimerDuration, (_) async => ping());
102 }
103
104 Future<void> ping() async {
lib/bitcoin/pending_bitcoin_transaction.dart
+1 -1
@@ -1,6 +1,6 @@
1 import 'package:cake_wallet/bitcoin/bitcoin_amount_format.dart';
2 import 'package:cake_wallet/bitcoin/bitcoin_transaction_info.dart';
3 -import 'package:cake_wallet/src/domain/common/transaction_direction.dart';
3 +import 'package:cake_wallet/entities/transaction_direction.dart';
4 import 'package:flutter/foundation.dart';
5 import 'package:bitcoin_flutter/bitcoin_flutter.dart' as bitcoin;
6 import 'package:cake_wallet/core/pending_transaction.dart';
lib/core/address_label_validator.dart
+1 -1
@@ -1,6 +1,6 @@
1 import 'package:cake_wallet/core/validator.dart';
2 import 'package:cake_wallet/generated/i18n.dart';
3 -import 'package:cake_wallet/src/domain/common/wallet_type.dart';
3 +import 'package:cake_wallet/entities/wallet_type.dart';
4
5 class AddressLabelValidator extends TextValidator {
6 AddressLabelValidator({WalletType type})
lib/core/address_validator.dart
+1 -1
@@ -1,7 +1,7 @@
1 import 'package:flutter/foundation.dart';
2 import 'package:cake_wallet/generated/i18n.dart';
3 import 'package:cake_wallet/core/validator.dart';
4 -import 'package:cake_wallet/src/domain/common/crypto_currency.dart';
4 +import 'package:cake_wallet/entities/crypto_currency.dart';
5
6 class AddressValidator extends TextValidator {
7 AddressValidator({@required CryptoCurrency type})
lib/core/amount.dart new
+37
@@ -0,0 +1,37 @@
1 +abstract class Amount {
2 + Amount(this.value);
3 +
4 + int value;
5 +
6 + int minorDigits;
7 +
8 + String code;
9 +
10 + String formatted();
11 +}
12 +
13 +class MoneroAmount extends Amount {
14 + MoneroAmount(int value) : super(value) {
15 + minorDigits = 12;
16 + code = 'XMR';
17 + }
18 +
19 + // const moneroAmountLength = 12;
20 + // const moneroAmountDivider = 1000000000000;
21 + // final moneroAmountFormat = NumberFormat()
22 + // ..maximumFractionDigits = moneroAmountLength
23 + // ..minimumFractionDigits = 1;
24 +
25 + // String moneroAmountToString({int amount}) =>
26 + // moneroAmountFormat.format(cryptoAmountToDouble(amount: amount, divider: moneroAmountDivider));
27 +
28 + // double moneroAmountToDouble({int amount}) => cryptoAmountToDouble(amount: amount, divider: moneroAmountDivider);
29 +
30 + // int moneroParseAmount({String amount}) => moneroAmountFormat.parse(amount).toInt();
31 +
32 + @override
33 + String formatted() {
34 + // TODO: implement formatted
35 + throw UnimplementedError();
36 + }
37 +}
lib/core/amount_converter.dart new
+92
@@ -0,0 +1,92 @@
1 +import 'package:intl/intl.dart';
2 +import 'package:cake_wallet/entities/crypto_currency.dart';
3 +
4 +class AmountConverter {
5 + static const _moneroAmountLength = 12;
6 + static const _moneroAmountDivider = 1000000000000;
7 + static const _litecoinAmountDivider = 100000000;
8 + static const _ethereumAmountDivider = 1000000000000000000;
9 + static const _dashAmountDivider = 100000000;
10 + static const _bitcoinCashAmountDivider = 100000000;
11 + static const _bitcoinAmountDivider = 100000000;
12 + static const _bitcoinAmountLength = 8;
13 + static final _bitcoinAmountFormat = NumberFormat()
14 + ..maximumFractionDigits = _bitcoinAmountLength
15 + ..minimumFractionDigits = 1;
16 + static final _moneroAmountFormat = NumberFormat()
17 + ..maximumFractionDigits = _moneroAmountLength
18 + ..minimumFractionDigits = 1;
19 +
20 + static double amountIntToDouble(CryptoCurrency cryptoCurrency, int amount) {
21 + switch (cryptoCurrency) {
22 + case CryptoCurrency.xmr:
23 + return _moneroAmountToDouble(amount);
24 + case CryptoCurrency.btc:
25 + return _bitcoinAmountToDouble(amount);
26 + case CryptoCurrency.bch:
27 + return _bitcoinCashAmountToDouble(amount);
28 + case CryptoCurrency.dash:
29 + return _dashAmountToDouble(amount);
30 + case CryptoCurrency.eth:
31 + return _ethereumAmountToDouble(amount);
32 + case CryptoCurrency.ltc:
33 + return _litecoinAmountToDouble(amount);
34 + default:
35 + return null;
36 + }
37 + }
38 +
39 + static int amountStringToInt(CryptoCurrency cryptoCurrency, String amount) {
40 + switch (cryptoCurrency) {
41 + case CryptoCurrency.xmr:
42 + return _moneroParseAmount(amount);
43 + default:
44 + return null;
45 + }
46 + }
47 +
48 + static String amountIntToString(CryptoCurrency cryptoCurrency, int amount) {
49 + switch (cryptoCurrency) {
50 + case CryptoCurrency.xmr:
51 + return _moneroAmountToString(amount);
52 + case CryptoCurrency.btc:
53 + return _bitcoinAmountToString(amount);
54 + default:
55 + return null;
56 + }
57 + }
58 +
59 + static double cryptoAmountToDouble({num amount, num divider}) =>
60 + amount / divider;
61 +
62 + static String _moneroAmountToString(int amount) => _moneroAmountFormat.format(
63 + cryptoAmountToDouble(amount: amount, divider: _moneroAmountDivider));
64 +
65 + static double _moneroAmountToDouble(int amount) =>
66 + cryptoAmountToDouble(amount: amount, divider: _moneroAmountDivider);
67 +
68 + static int _moneroParseAmount(String amount) =>
69 + _moneroAmountFormat.parse(amount).toInt();
70 +
71 + static String _bitcoinAmountToString(int amount) =>
72 + _bitcoinAmountFormat.format(
73 + cryptoAmountToDouble(amount: amount, divider: _bitcoinAmountDivider));
74 +
75 + static double _bitcoinAmountToDouble(int amount) =>
76 + cryptoAmountToDouble(amount: amount, divider: _bitcoinAmountDivider);
77 +
78 + static int _doubleToBitcoinAmount(double amount) =>
79 + (amount * _bitcoinAmountDivider).toInt();
80 +
81 + static double _bitcoinCashAmountToDouble(int amount) =>
82 + cryptoAmountToDouble(amount: amount, divider: _bitcoinCashAmountDivider);
83 +
84 + static double _dashAmountToDouble(int amount) =>
85 + cryptoAmountToDouble(amount: amount, divider: _dashAmountDivider);
86 +
87 + static double _ethereumAmountToDouble(num amount) =>
88 + cryptoAmountToDouble(amount: amount, divider: _ethereumAmountDivider);
89 +
90 + static double _litecoinAmountToDouble(int amount) =>
91 + cryptoAmountToDouble(amount: amount, divider: _litecoinAmountDivider);
92 +}
lib/core/amount_validator.dart
+1 -1
@@ -1,6 +1,6 @@
1 import 'package:cake_wallet/core/validator.dart';
2 import 'package:cake_wallet/generated/i18n.dart';
3 -import 'package:cake_wallet/src/domain/common/wallet_type.dart';
3 +import 'package:cake_wallet/entities/wallet_type.dart';
4
5 class AmountValidator extends TextValidator {
6 AmountValidator({WalletType type, bool isAutovalidate = false})
lib/core/auth_service.dart
+5 -3
@@ -1,8 +1,9 @@
1 import 'package:mobx/mobx.dart';
2 import 'package:flutter_secure_storage/flutter_secure_storage.dart';
3 import 'package:shared_preferences/shared_preferences.dart';
4 -import 'package:cake_wallet/src/domain/common/secret_store_key.dart';
5 -import 'package:cake_wallet/src/domain/common/encrypt.dart';
4 +import 'package:cake_wallet/entities/preferences_key.dart';
5 +import 'package:cake_wallet/entities/secret_store_key.dart';
6 +import 'package:cake_wallet/entities/encrypt.dart';
7
8 class AuthService with Store {
9 AuthService({this.secureStorage, this.sharedPreferences});
@@ -18,7 +19,8 @@ class AuthService with Store {
19
20 Future<bool> canAuthenticate() async {
21 final key = generateStoreKeyFor(key: SecretStoreKey.pinCodePassword);
21 - final walletName = sharedPreferences.getString('current_wallet_name') ?? '';
22 + final walletName =
23 + sharedPreferences.getString(PreferencesKey.currentWalletName) ?? '';
24 var password = '';
25
26 try {
lib/core/contact_service.dart
+1 -1
@@ -1,6 +1,6 @@
1 import 'package:hive/hive.dart';
2 import 'package:cake_wallet/store/contact_list_store.dart';
3 -import 'package:cake_wallet/src/domain/common/contact.dart';
3 +import 'package:cake_wallet/entities/contact.dart';
4
5 class ContactService {
6 ContactService(this.contactSource, this.contactListStore) {
lib/core/execution_state.dart new
+13
@@ -0,0 +1,13 @@
1 +abstract class ExecutionState {}
2 +
3 +class InitialExecutionState extends ExecutionState {}
4 +
5 +class IsExecutingState extends ExecutionState {}
6 +
7 +class ExecutedSuccessfullyState extends ExecutionState {}
8 +
9 +class FailureState extends ExecutionState {
10 + FailureState(this.error);
11 +
12 + final String error;
13 +}
\ No newline at end of file
lib/core/fiat_conversion_service.dart renamed
+16 -4
@@ -1,13 +1,16 @@
1 +import 'package:cake_wallet/entities/crypto_currency.dart';
2 +import 'package:cake_wallet/entities/fiat_currency.dart';
3 import 'dart:convert';
4 +import 'package:flutter/foundation.dart';
5 import 'package:http/http.dart';
3 -import 'package:cake_wallet/src/domain/common/crypto_currency.dart';
4 -import 'package:cake_wallet/src/domain/common/fiat_currency.dart';
5 -import 'package:cake_wallet/src/domain/common/currency_formatter.dart';
6 +import 'package:cake_wallet/entities/currency_formatter.dart';
7
8 const fiatApiAuthority = 'fiat-api.cakewallet.com';
9 const fiatApiPath = '/v1/rates';
10
10 -Future<double> fetchPriceFor({CryptoCurrency crypto, FiatCurrency fiat}) async {
11 +Future<double> _fetchPrice(Map<String, dynamic> args) async {
12 + final crypto = args['crypto'] as CryptoCurrency;
13 + final fiat = args['fiat'] as FiatCurrency;
14 double price = 0.0;
15
16 try {
@@ -35,3 +38,12 @@ Future<double> fetchPriceFor({CryptoCurrency crypto, FiatCurrency fiat}) async {
38 return price;
39 }
40 }
41 +
42 +Future<double> _fetchPriceAsync(
43 + CryptoCurrency crypto, FiatCurrency fiat) async =>
44 + compute(_fetchPrice, {'fiat': fiat, 'crypto': crypto});
45 +
46 +class FiatConversionService {
47 + static Future<double> fetchPrice(CryptoCurrency crypto, FiatCurrency fiat) async =>
48 + await _fetchPriceAsync(crypto, fiat);
49 +}
lib/core/generate_wallet_password.dart
+1 -1
@@ -1,6 +1,6 @@
1 import 'package:uuid/uuid.dart';
2 import 'package:cake_wallet/bitcoin/key.dart';
3 -import 'package:cake_wallet/src/domain/common/wallet_type.dart';
3 +import 'package:cake_wallet/entities/wallet_type.dart';
4
5 String generateWalletPassword(WalletType type) {
6 switch (type) {
lib/core/key_service.dart
+2 -2
@@ -1,6 +1,6 @@
1 import 'package:flutter_secure_storage/flutter_secure_storage.dart';
2 -import 'package:cake_wallet/src/domain/common/secret_store_key.dart';
3 -import 'package:cake_wallet/src/domain/common/encrypt.dart';
2 +import 'package:cake_wallet/entities/secret_store_key.dart';
3 +import 'package:cake_wallet/entities/encrypt.dart';
4
5 class KeyService {
6 KeyService(this._secureStorage);
lib/core/mnemonic_length.dart
+1 -1
@@ -1,4 +1,4 @@
1 -import 'package:cake_wallet/src/domain/common/wallet_type.dart';
1 +import 'package:cake_wallet/entities/wallet_type.dart';
2
3 const bitcoinMnemonicLength = 12;
4 const moneroMnemonicLength = 25;
lib/core/monero_account_label_validator.dart
+1 -1
@@ -1,7 +1,7 @@
1 import 'package:flutter/foundation.dart';
2 import 'package:cake_wallet/generated/i18n.dart';
3 import 'package:cake_wallet/core/validator.dart';
4 -import 'package:cake_wallet/src/domain/common/crypto_currency.dart';
4 +import 'package:cake_wallet/entities/crypto_currency.dart';
5
6 class MoneroLabelValidator extends TextValidator {
7 MoneroLabelValidator({@required CryptoCurrency type})
lib/core/seed_validator.dart
+20 -21
@@ -1,15 +1,16 @@
1 import 'package:bip39/src/wordlists/english.dart' as bitcoin_english;
2 import 'package:cake_wallet/core/validator.dart';
3 -import 'package:cake_wallet/src/domain/common/mnemonic_item.dart';
4 -import 'package:cake_wallet/src/domain/common/wallet_type.dart';
5 -import 'package:cake_wallet/src/domain/monero/mnemonics/chinese_simplified.dart';
6 -import 'package:cake_wallet/src/domain/monero/mnemonics/dutch.dart';
7 -import 'package:cake_wallet/src/domain/monero/mnemonics/english.dart';
8 -import 'package:cake_wallet/src/domain/monero/mnemonics/german.dart';
9 -import 'package:cake_wallet/src/domain/monero/mnemonics/japanese.dart';
10 -import 'package:cake_wallet/src/domain/monero/mnemonics/portuguese.dart';
11 -import 'package:cake_wallet/src/domain/monero/mnemonics/russian.dart';
12 -import 'package:cake_wallet/src/domain/monero/mnemonics/spanish.dart';
3 +import 'package:cake_wallet/entities/mnemonic_item.dart';
4 +import 'package:cake_wallet/entities/wallet_type.dart';
5 +import 'package:cake_wallet/monero/mnemonics/chinese_simplified.dart';
6 +import 'package:cake_wallet/monero/mnemonics/dutch.dart';
7 +import 'package:cake_wallet/monero/mnemonics/english.dart';
8 +import 'package:cake_wallet/monero/mnemonics/german.dart';
9 +import 'package:cake_wallet/monero/mnemonics/japanese.dart';
10 +import 'package:cake_wallet/monero/mnemonics/portuguese.dart';
11 +import 'package:cake_wallet/monero/mnemonics/russian.dart';
12 +import 'package:cake_wallet/monero/mnemonics/spanish.dart';
13 +import 'package:cake_wallet/utils/language_list.dart';
14
15 class SeedValidator extends Validator<MnemonicItem> {
16 SeedValidator({this.type, this.language})
@@ -31,31 +32,29 @@ class SeedValidator extends Validator<MnemonicItem> {
32 }
33
34 static List<String> getMoneroWordList(String language) {
34 - // FIXME: Unnamed constants; Need to be sure that string are in same case;
35 -
35 switch (language) {
37 - case 'English':
36 + case LanguageList.english:
37 return EnglishMnemonics.words;
38 break;
40 - case 'Chinese (simplified)':
39 + case LanguageList.chineseSimplified:
40 return ChineseSimplifiedMnemonics.words;
41 break;
43 - case 'Dutch':
42 + case LanguageList.dutch:
43 return DutchMnemonics.words;
44 break;
46 - case 'German':
45 + case LanguageList.german:
46 return GermanMnemonics.words;
47 break;
49 - case 'Japanese':
48 + case LanguageList.japanese:
49 return JapaneseMnemonics.words;
50 break;
52 - case 'Portuguese':
51 + case LanguageList.portuguese:
52 return PortugueseMnemonics.words;
53 break;
55 - case 'Russian':
54 + case LanguageList.russian:
55 return RussianMnemonics.words;
56 break;
58 - case 'Spanish':
57 + case LanguageList.spanish:
58 return SpanishMnemonics.words;
59 break;
60 default:
@@ -64,7 +63,7 @@ class SeedValidator extends Validator<MnemonicItem> {
63 }
64
65 static List<String> getBitcoinWordList(String language) {
67 - assert(language.toLowerCase() == 'english');
66 + assert(language.toLowerCase() == LanguageList.english.toLowerCase());
67 return bitcoin_english.WORDLIST;
68 }
69
lib/core/transaction_history.dart
+1 -1
@@ -1,6 +1,6 @@
1 import 'package:flutter/foundation.dart';
2 import 'package:mobx/mobx.dart';
3 -import 'package:cake_wallet/src/domain/common/transaction_info.dart';
3 +import 'package:cake_wallet/entities/transaction_info.dart';
4
5 abstract class TransactionHistoryBase<TransactionType extends TransactionInfo> {
6 TransactionHistoryBase() : _isUpdating = false;
lib/core/wallet_base.dart
+9 -18
@@ -1,24 +1,13 @@
1 import 'package:flutter/foundation.dart';
2 -import 'package:cake_wallet/src/domain/common/wallet_info.dart';
2 +import 'package:cake_wallet/entities/wallet_info.dart';
3 import 'package:cake_wallet/core/pending_transaction.dart';
4 import 'package:cake_wallet/core/transaction_history.dart';
5 -import 'package:cake_wallet/src/domain/common/transaction_priority.dart';
6 -import 'package:cake_wallet/src/domain/common/crypto_currency.dart';
7 -import 'package:cake_wallet/src/domain/common/sync_status.dart';
8 -import 'package:cake_wallet/src/domain/common/node.dart';
9 -import 'package:cake_wallet/src/domain/common/wallet_type.dart';
10 -
11 -// FIXME: Move me.
12 -CryptoCurrency currencyForWalletType(WalletType type) {
13 - switch (type) {
14 - case WalletType.bitcoin:
15 - return CryptoCurrency.btc;
16 - case WalletType.monero:
17 - return CryptoCurrency.xmr;
18 - default:
19 - return null;
20 - }
21 -}
5 +import 'package:cake_wallet/entities/currency_for_wallet_type.dart';
6 +import 'package:cake_wallet/entities/transaction_priority.dart';
7 +import 'package:cake_wallet/entities/crypto_currency.dart';
8 +import 'package:cake_wallet/entities/sync_status.dart';
9 +import 'package:cake_wallet/entities/node.dart';
10 +import 'package:cake_wallet/entities/wallet_type.dart';
11
12 abstract class WalletBase<BalaceType> {
13 WalletBase(this.walletInfo);
@@ -61,4 +50,6 @@ abstract class WalletBase<BalaceType> {
50 double calculateEstimatedFee(TransactionPriority priority);
51
52 Future<void> save();
53 +
54 + Future<void> rescan({int height});
55 }
lib/core/wallet_creation_service.dart
+8 -18
@@ -3,18 +3,15 @@ import 'package:flutter/foundation.dart';
3 import 'package:flutter_secure_storage/flutter_secure_storage.dart';
4 import 'package:shared_preferences/shared_preferences.dart';
5 import 'package:cake_wallet/core/key_service.dart';
6 +import 'package:cake_wallet/core/wallet_base.dart';
7 import 'package:cake_wallet/core/generate_wallet_password.dart';
7 -import 'package:cake_wallet/store/app_store.dart';
8 import 'package:cake_wallet/core/wallet_credentials.dart';
9 -import 'package:cake_wallet/bitcoin/bitcoin_wallet_service.dart';
10 -import 'package:cake_wallet/monero/monero_wallet_service.dart';
9 import 'package:cake_wallet/core/wallet_service.dart';
12 -import 'package:cake_wallet/src/domain/common/wallet_type.dart';
10 +import 'package:cake_wallet/entities/wallet_type.dart';
11
12 class WalletCreationService {
13 WalletCreationService(
14 {WalletType initialType,
17 - this.appStore,
15 this.secureStorage,
16 this.keyService,
17 this.sharedPreferences})
@@ -25,7 +22,6 @@ class WalletCreationService {
22 }
23
24 WalletType type;
28 - final AppStore appStore;
25 final FlutterSecureStorage secureStorage;
26 final SharedPreferences sharedPreferences;
27 final KeyService keyService;
@@ -36,33 +32,27 @@ class WalletCreationService {
32 _service = getIt.get<WalletService>(param1: type);
33 }
34
39 - Future<void> create(WalletCredentials credentials) async {
35 + Future<WalletBase> create(WalletCredentials credentials) async {
36 final password = generateWalletPassword(type);
37 credentials.password = password;
38 await keyService.saveWalletPassword(
39 password: password, walletName: credentials.name);
44 - final wallet = await _service.create(credentials);
45 - appStore.wallet = wallet;
46 - appStore.authenticationStore.allowed();
40 + return await _service.create(credentials);
41 }
42
49 - Future<void> restoreFromKeys(WalletCredentials credentials) async {
43 + Future<WalletBase> restoreFromKeys(WalletCredentials credentials) async {
44 final password = generateWalletPassword(type);
45 credentials.password = password;
46 await keyService.saveWalletPassword(
47 password: password, walletName: credentials.name);
54 - final wallet = await _service.restoreFromKeys(credentials);
55 - appStore.wallet = wallet;
56 - appStore.authenticationStore.allowed();
48 + return await _service.restoreFromKeys(credentials);
49 }
50
59 - Future<void> restoreFromSeed(WalletCredentials credentials) async {
51 + Future<WalletBase> restoreFromSeed(WalletCredentials credentials) async {
52 final password = generateWalletPassword(type);
53 credentials.password = password;
54 await keyService.saveWalletPassword(
55 password: password, walletName: credentials.name);
64 - final wallet = await _service.restoreFromSeed(credentials);
65 - appStore.wallet = wallet;
66 - appStore.authenticationStore.allowed();
56 + return await _service.restoreFromSeed(credentials);
57 }
58 }
lib/core/wallet_credentials.dart
+1 -1
@@ -1,4 +1,4 @@
1 -import 'package:cake_wallet/src/domain/common/wallet_info.dart';
1 +import 'package:cake_wallet/entities/wallet_info.dart';
2
3 abstract class WalletCredentials {
4 WalletCredentials({this.name, this.password, this.height});
lib/di.dart
+47 -71
@@ -1,10 +1,12 @@
1 import 'package:cake_wallet/bitcoin/bitcoin_wallet_service.dart';
2 import 'package:cake_wallet/core/contact_service.dart';
3 import 'package:cake_wallet/core/wallet_service.dart';
4 +import 'package:cake_wallet/entities/biometric_auth.dart';
5 import 'package:cake_wallet/monero/monero_wallet_service.dart';
5 -import 'package:cake_wallet/src/domain/common/contact.dart';
6 -import 'package:cake_wallet/src/domain/common/node.dart';
7 -import 'package:cake_wallet/src/domain/exchange/trade.dart';
6 +import 'package:cake_wallet/entities/contact.dart';
7 +import 'package:cake_wallet/entities/node.dart';
8 +import 'package:cake_wallet/exchange/trade.dart';
9 +
10 // import 'package:cake_wallet/src/domain/services/wallet_service.dart';
11 import 'package:cake_wallet/src/screens/contact/contact_list_page.dart';
12 import 'package:cake_wallet/src/screens/contact/contact_page.dart';
@@ -12,9 +14,11 @@ import 'package:cake_wallet/src/screens/exchange_trade/exchange_confirm_page.dar
14 import 'package:cake_wallet/src/screens/exchange_trade/exchange_trade_page.dart';
15 import 'package:cake_wallet/src/screens/nodes/node_create_or_edit_page.dart';
16 import 'package:cake_wallet/src/screens/nodes/nodes_list_page.dart';
17 +import 'package:cake_wallet/src/screens/rescan/rescan_page.dart';
18 import 'package:cake_wallet/src/screens/seed/wallet_seed_page.dart';
19 import 'package:cake_wallet/src/screens/send/send_template_page.dart';
20 import 'package:cake_wallet/src/screens/settings/settings.dart';
21 +import 'package:cake_wallet/src/screens/setup_pin_code/setup_pin_code.dart';
22 import 'package:cake_wallet/src/screens/wallet_keys/wallet_keys_page.dart';
23 import 'package:cake_wallet/src/screens/exchange/exchange_page.dart';
24 import 'package:cake_wallet/src/screens/exchange/exchange_template_page.dart';
@@ -24,7 +28,7 @@ import 'package:cake_wallet/store/settings_store.dart';
28 import 'package:cake_wallet/core/auth_service.dart';
29 import 'package:cake_wallet/core/key_service.dart';
30 import 'package:cake_wallet/monero/monero_wallet.dart';
27 -import 'package:cake_wallet/src/domain/common/wallet_info.dart';
31 +import 'package:cake_wallet/entities/wallet_info.dart';
32 import 'package:cake_wallet/src/screens/monero_accounts/monero_account_list_page.dart';
33 import 'package:cake_wallet/src/screens/monero_accounts/monero_account_edit_or_create_page.dart';
34 import 'package:cake_wallet/src/screens/auth/auth_page.dart';
@@ -42,6 +46,8 @@ import 'package:cake_wallet/view_model/contact_list/contact_view_model.dart';
46 import 'package:cake_wallet/view_model/exchange/exchange_trade_view_model.dart';
47 import 'package:cake_wallet/view_model/node_list/node_list_view_model.dart';
48 import 'package:cake_wallet/view_model/node_list/node_create_or_edit_view_model.dart';
49 +import 'package:cake_wallet/view_model/rescan_view_model.dart';
50 +import 'package:cake_wallet/view_model/setup_pin_code_view_model.dart';
51 import 'package:cake_wallet/view_model/wallet_address_list/wallet_address_edit_or_create_view_model.dart';
52 import 'package:cake_wallet/view_model/auth_view_model.dart';
53 import 'package:cake_wallet/view_model/dashboard/dashboard_view_model.dart';
@@ -56,6 +62,7 @@ import 'package:cake_wallet/view_model/wallet_list/wallet_list_view_model.dart';
62 import 'package:cake_wallet/view_model/wallet_seed_view_model.dart';
63 import 'package:cake_wallet/view_model/exchange/exchange_view_model.dart';
64 import 'package:flutter/foundation.dart';
65 +import 'package:flutter/widgets.dart';
66 import 'package:get_it/get_it.dart';
67 import 'package:hive/hive.dart';
68 import 'package:mobx/mobx.dart';
@@ -65,51 +72,20 @@ import 'package:cake_wallet/view_model/wallet_restoration_from_seed_vm.dart';
72 import 'package:cake_wallet/view_model/wallet_restoration_from_keys_vm.dart';
73 import 'package:cake_wallet/core/wallet_creation_service.dart';
74 import 'package:cake_wallet/store/app_store.dart';
68 -import 'package:cake_wallet/src/domain/common/wallet_type.dart';
75 +import 'package:cake_wallet/entities/wallet_type.dart';
76 import 'package:cake_wallet/view_model/wallet_new_vm.dart';
77 import 'package:cake_wallet/store/authentication_store.dart';
78 import 'package:cake_wallet/store/dashboard/trades_store.dart';
79 import 'package:cake_wallet/store/dashboard/trade_filter_store.dart';
80 import 'package:cake_wallet/store/dashboard/transaction_filter_store.dart';
74 -import 'package:cake_wallet/store/dashboard/fiat_convertation_store.dart';
81 +import 'package:cake_wallet/store/dashboard/fiat_conversion_store.dart';
82 import 'package:cake_wallet/store/templates/send_template_store.dart';
83 import 'package:cake_wallet/store/templates/exchange_template_store.dart';
77 -import 'package:cake_wallet/src/domain/common/template.dart';
78 -import 'package:cake_wallet/src/domain/exchange/exchange_template.dart';
84 +import 'package:cake_wallet/entities/template.dart';
85 +import 'package:cake_wallet/exchange/exchange_template.dart';
86
87 final getIt = GetIt.instance;
88
82 -// FIXME: Move me.
83 -
84 -Stream<BoxEvent> _onNodesSourceChange;
85 -NodeListStore _nodeListStore;
86 -
87 -NodeListStore setupNodeListStore(Box<Node> nodeSource) {
88 - if (_nodeListStore != null) {
89 - return _nodeListStore;
90 - }
91 -
92 - _nodeListStore = NodeListStore();
93 - _nodeListStore.replaceValues(nodeSource.values);
94 - _onNodesSourceChange = nodeSource.watch();
95 - _onNodesSourceChange.listen((event) {
96 -// print(event);
97 -
98 - if (event.deleted) {
99 - _nodeListStore.nodes.removeWhere((n) {
100 - return n.key != null ? n.key == event.key : true;
101 - });
102 - }
103 -
104 - if (event.value is Node) {
105 - final val = event.value as Node;
106 - _nodeListStore.nodes.add(val);
107 - }
108 - });
109 -
110 - return _nodeListStore;
111 -}
112 -
89 Future setup(
90 {Box<WalletInfo> walletInfoSource,
91 Box<Node> nodeSource,
@@ -122,11 +98,13 @@ Future setup(
98
99 final settingsStore = await SettingsStoreBase.load(nodeSource: nodeSource);
100
101 + getIt.registerSingleton<Box<Node>>(nodeSource);
102 +
103 getIt.registerSingleton<FlutterSecureStorage>(FlutterSecureStorage());
104 getIt.registerSingleton(AuthenticationStore());
105 getIt.registerSingleton<WalletListStore>(WalletListStore());
106 getIt.registerSingleton(ContactListStore());
129 - getIt.registerSingleton(setupNodeListStore(nodeSource));
107 + getIt.registerSingleton(NodeListStoreBase.instance);
108 getIt.registerSingleton<SettingsStore>(settingsStore);
109 getIt.registerSingleton<AppStore>(AppStore(
110 authenticationStore: getIt.get<AuthenticationStore>(),
@@ -140,7 +118,7 @@ Future setup(
118 tradesSource: tradesSource, settingsStore: getIt.get<SettingsStore>()));
119 getIt.registerSingleton<TradeFilterStore>(TradeFilterStore());
120 getIt.registerSingleton<TransactionFilterStore>(TransactionFilterStore());
143 - getIt.registerSingleton<FiatConvertationStore>(FiatConvertationStore());
121 + getIt.registerSingleton<FiatConversionStore>(FiatConversionStore());
122 getIt.registerSingleton<SendTemplateStore>(
123 SendTemplateStore(templateSource: templates));
124 getIt.registerSingleton<ExchangeTemplateStore>(
@@ -152,13 +130,12 @@ Future setup(
130 getIt.registerFactoryParam<WalletCreationService, WalletType, void>(
131 (type, _) => WalletCreationService(
132 initialType: type,
155 - appStore: getIt.get<AppStore>(),
133 keyService: getIt.get<KeyService>(),
134 secureStorage: getIt.get<FlutterSecureStorage>(),
135 sharedPreferences: getIt.get<SharedPreferences>()));
136
137 getIt.registerFactoryParam<WalletNewVM, WalletType, void>((type, _) =>
161 - WalletNewVM(
138 + WalletNewVM(getIt.get<AppStore>(),
139 getIt.get<WalletCreationService>(param1: type), walletInfoSource,
140 type: type));
141
@@ -168,7 +145,7 @@ Future setup(
145 final language = args[1] as String;
146 final mnemonic = args[2] as String;
147
171 - return WalletRestorationFromSeedVM(
148 + return WalletRestorationFromSeedVM(getIt.get<AppStore>(),
149 getIt.get<WalletCreationService>(param1: type), walletInfoSource,
150 type: type, language: language, seed: mnemonic);
151 });
@@ -178,7 +155,7 @@ Future setup(
155 final type = args.first as WalletType;
156 final language = args[1] as String;
157
181 - return WalletRestorationFromKeysVM(
158 + return WalletRestorationFromKeysVM(getIt.get<AppStore>(),
159 getIt.get<WalletCreationService>(param1: type), walletInfoSource,
160 type: type, language: language);
161 });
@@ -189,7 +166,7 @@ Future setup(
166 getIt.registerFactory(() => BalanceViewModel(
167 wallet: getIt.get<AppStore>().wallet,
168 settingsStore: getIt.get<SettingsStore>(),
192 - fiatConvertationStore: getIt.get<FiatConvertationStore>()));
169 + fiatConvertationStore: getIt.get<FiatConversionStore>()));
170
171 getIt.registerFactory(() => DashboardViewModel(
172 balanceViewModel: getIt.get<BalanceViewModel>(),
@@ -203,38 +180,24 @@ Future setup(
180 sharedPreferences: getIt.get<SharedPreferences>()));
181
182 getIt.registerFactory<AuthViewModel>(() => AuthViewModel(
206 - authService: getIt.get<AuthService>(),
207 - sharedPreferences: getIt.get<SharedPreferences>()));
183 + getIt.get<AuthService>(),
184 + getIt.get<SharedPreferences>(),
185 + getIt.get<SettingsStore>(),
186 + BiometricAuth()));
187
188 getIt.registerFactory<AuthPage>(
210 - () => AuthPage(
211 - allowBiometricalAuthentication: getIt
212 - .get<AppStore>()
213 - .settingsStore
214 - .allowBiometricalAuthentication,
215 - authViewModel: getIt.get<AuthViewModel>(),
216 - onAuthenticationFinished: (isAuthenticated, __) {
189 + () => AuthPage(getIt.get<AuthViewModel>(),
190 + onAuthenticationFinished: (isAuthenticated, __) {
191 if (isAuthenticated) {
192 getIt.get<AuthenticationStore>().allowed();
193 }
220 - },
221 - closable: false),
194 + }, closable: false),
195 instanceName: 'login');
196
197 getIt
198 .registerFactoryParam<AuthPage, void Function(bool, AuthPageState), void>(
226 - (onAuthFinished, _) {
227 - final allowBiometricalAuthentication =
228 - getIt.get<AppStore>().settingsStore.allowBiometricalAuthentication;
229 -
230 - print('allowBiometricalAuthentication $allowBiometricalAuthentication');
231 -
232 - return AuthPage(
233 - allowBiometricalAuthentication: allowBiometricalAuthentication,
234 - authViewModel: getIt.get<AuthViewModel>(),
235 - onAuthenticationFinished: onAuthFinished,
236 - closable: false);
237 - });
199 + (onAuthFinished, _) => AuthPage(getIt.get<AuthViewModel>(),
200 + onAuthenticationFinished: onAuthFinished, closable: false));
201
202 getIt.registerFactory<DashboardPage>(() => DashboardPage(
203 walletViewModel: getIt.get<DashboardViewModel>(),
@@ -256,13 +219,13 @@ Future setup(
219 getIt.registerFactory<SendViewModel>(() => SendViewModel(
220 getIt.get<AppStore>().wallet,
221 getIt.get<AppStore>().settingsStore,
259 - getIt.get<FiatConvertationStore>()));
222 + getIt.get<FiatConversionStore>()));
223
224 getIt.registerFactory(
225 () => SendPage(sendViewModel: getIt.get<SendViewModel>()));
226
227 getIt.registerFactory(
265 - () => SendTemplatePage(sendViewModel: getIt.get<SendViewModel>()));
228 + () => SendTemplatePage(sendViewModel: getIt.get<SendViewModel>()));
229
230 getIt.registerFactory(() => WalletListViewModel(
231 walletInfoSource, getIt.get<AppStore>(), getIt.get<KeyService>()));
@@ -387,6 +350,19 @@ Future setup(
350 return null;
351 }
352 });
353 +
354 + getIt.registerFactory<SetupPinCodeViewModel>(() => SetupPinCodeViewModel(
355 + getIt.get<AuthService>(), getIt.get<SettingsStore>()));
356 +
357 + getIt.registerFactoryParam<SetupPinCodePage,
358 + void Function(BuildContext, String), void>(
359 + (onSuccessfulPinSetup, _) => SetupPinCodePage(
360 + getIt.get<SetupPinCodeViewModel>(),
361 + onSuccessfulPinSetup: onSuccessfulPinSetup));
362 +
363 + getIt.registerFactory(() => RescanViewModel(getIt.get<AppStore>().wallet));
364 +
365 + getIt.registerFactory(() => RescanPage(getIt.get<RescanViewModel>()));
366 }
367
368 void setupThemeChangerStore(ThemeChanger themeChanger) {
lib/entities/action_list_display_mode.dart renamed
lib/entities/balance.dart renamed
lib/entities/balance_display_mode.dart renamed
+1 -1
@@ -1,6 +1,6 @@
1 import 'package:flutter/foundation.dart';
2 import 'package:cake_wallet/generated/i18n.dart';
3 -import 'package:cake_wallet/src/domain/common/enumerable_item.dart';
3 +import 'package:cake_wallet/entities/enumerable_item.dart';
4
5 class BalanceDisplayMode extends EnumerableItem<int> with Serializable<int> {
6 const BalanceDisplayMode({@required String title, @required int raw})
lib/entities/biometric_auth.dart renamed
lib/entities/calculate_estimated_fee.dart renamed
+1 -1
@@ -1,4 +1,4 @@
1 -import 'package:cake_wallet/src/domain/common/transaction_priority.dart';
1 +import 'package:cake_wallet/entities/transaction_priority.dart';
2
3 double calculateEstimatedFee({TransactionPriority priority}) {
4 if (priority == TransactionPriority.slow) {
lib/entities/calculate_fiat_amount.dart renamed
lib/entities/calculate_fiat_amount_raw.dart renamed
lib/entities/contact.dart renamed
+1 -1
@@ -1,6 +1,6 @@
1 import 'package:flutter/foundation.dart';
2 import 'package:hive/hive.dart';
3 -import 'package:cake_wallet/src/domain/common/crypto_currency.dart';
3 +import 'package:cake_wallet/entities/crypto_currency.dart';
4 import 'package:cake_wallet/utils/mobx.dart';
5
6 part 'contact.g.dart';
lib/entities/contact_model.dart renamed
+2 -2
@@ -1,7 +1,7 @@
1 // import 'package:hive/hive.dart';
2 // import 'package:mobx/mobx.dart';
3 -// import 'package:cake_wallet/src/domain/common/contact.dart';
4 -// import 'package:cake_wallet/src/domain/common/crypto_currency.dart';
3 +// import 'package:cake_wallet/entities/contact.dart';
4 +// import 'package:cake_wallet/entities/crypto_currency.dart';
5
6 // part 'contact_model.g.dart';
7
lib/entities/crypto_amount_format.dart renamed
lib/entities/crypto_currency.dart renamed
+1 -1
@@ -1,4 +1,4 @@
1 -import 'package:cake_wallet/src/domain/common/enumerable_item.dart';
1 +import 'package:cake_wallet/entities/enumerable_item.dart';
2 import 'package:hive/hive.dart';
3
4 part 'crypto_currency.g.dart';
lib/entities/currency_for_wallet_type.dart new
+13
@@ -0,0 +1,13 @@
1 +import 'package:cake_wallet/entities/crypto_currency.dart';
2 +import 'package:cake_wallet/entities/wallet_type.dart';
3 +
4 +CryptoCurrency currencyForWalletType(WalletType type) {
5 + switch (type) {
6 + case WalletType.bitcoin:
7 + return CryptoCurrency.btc;
8 + case WalletType.monero:
9 + return CryptoCurrency.xmr;
10 + default:
11 + return null;
12 + }
13 +}
\ No newline at end of file
lib/entities/currency_formatter.dart renamed
+1 -1
@@ -1,4 +1,4 @@
1 -import 'package:cake_wallet/src/domain/common/crypto_currency.dart';
1 +import 'package:cake_wallet/entities/crypto_currency.dart';
2
3 String cryptoToString(CryptoCurrency crypto) {
4 switch (crypto) {
lib/entities/default_settings_migration.dart renamed
+10 -10
@@ -1,13 +1,13 @@
1 -import 'package:cake_wallet/src/domain/common/wallet_type.dart';
2 -import 'package:cake_wallet/store/settings_store.dart';
1 import 'package:flutter/foundation.dart';
2 import 'package:hive/hive.dart';
3 import 'package:shared_preferences/shared_preferences.dart';
6 -import 'package:cake_wallet/src/domain/common/node.dart';
7 -import 'package:cake_wallet/src/domain/common/balance_display_mode.dart';
8 -import 'package:cake_wallet/src/domain/common/fiat_currency.dart';
9 -import 'package:cake_wallet/src/domain/common/node_list.dart';
10 -import 'package:cake_wallet/src/domain/common/transaction_priority.dart';
4 +import 'package:cake_wallet/entities/preferences_key.dart';
5 +import 'package:cake_wallet/entities/wallet_type.dart';
6 +import 'package:cake_wallet/entities/node.dart';
7 +import 'package:cake_wallet/entities/balance_display_mode.dart';
8 +import 'package:cake_wallet/entities/fiat_currency.dart';
9 +import 'package:cake_wallet/entities/node_list.dart';
10 +import 'package:cake_wallet/entities/transaction_priority.dart';
11
12 Future defaultSettingsMigration(
13 {@required int version,
@@ -29,13 +29,13 @@ Future defaultSettingsMigration(
29 switch (version) {
30 case 1:
31 await sharedPreferences.setString(
32 - SettingsStoreBase.currentFiatCurrencyKey,
32 + PreferencesKey.currentFiatCurrencyKey,
33 FiatCurrency.usd.toString());
34 await sharedPreferences.setInt(
35 - SettingsStoreBase.currentTransactionPriorityKey,
35 + PreferencesKey.currentTransactionPriorityKey,
36 TransactionPriority.standart.raw);
37 await sharedPreferences.setInt(
38 - SettingsStoreBase.currentBalanceDisplayModeKey,
38 + PreferencesKey.currentBalanceDisplayModeKey,
39 BalanceDisplayMode.availableBalance.raw);
40 await sharedPreferences.setBool('save_recipient_address', true);
41 await resetToDefault(nodes);
lib/entities/digest_request.dart renamed
lib/entities/encrypt.dart renamed
lib/entities/enumerable_item.dart renamed
lib/entities/fiat_currency.dart renamed
+1 -1
@@ -1,4 +1,4 @@
1 -import 'package:cake_wallet/src/domain/common/enumerable_item.dart';
1 +import 'package:cake_wallet/entities/enumerable_item.dart';
2
3 class FiatCurrency extends EnumerableItem<String> with Serializable<String> {
4 const FiatCurrency({String symbol}) : super(title: symbol, raw: symbol);
lib/entities/format_amount.dart renamed
lib/entities/fs_migration.dart renamed
+5 -5
@@ -1,10 +1,10 @@
1 import 'dart:io';
2 import 'dart:convert';
3 -import 'package:cake_wallet/src/domain/common/contact.dart';
4 -import 'package:cake_wallet/src/domain/common/crypto_currency.dart';
5 -import 'package:cake_wallet/src/domain/common/wallet_info.dart';
6 -import 'package:cake_wallet/src/domain/common/wallet_type.dart';
7 -import 'package:cake_wallet/src/domain/exchange/trade.dart';
3 +import 'package:cake_wallet/entities/contact.dart';
4 +import 'package:cake_wallet/entities/crypto_currency.dart';
5 +import 'package:cake_wallet/entities/wallet_info.dart';
6 +import 'package:cake_wallet/entities/wallet_type.dart';
7 +import 'package:cake_wallet/exchange/trade.dart';
8 import 'package:flutter/foundation.dart';
9 import 'package:hive/hive.dart';
10 import 'package:path_provider/path_provider.dart';
lib/entities/get_encryption_key.dart renamed
lib/entities/language.dart renamed
lib/entities/load_current_wallet.dart new
+23
@@ -0,0 +1,23 @@
1 +import 'package:cake_wallet/di.dart';
2 +import 'package:shared_preferences/shared_preferences.dart';
3 +import 'package:cake_wallet/store/app_store.dart';
4 +import 'package:cake_wallet/core/key_service.dart';
5 +import 'package:cake_wallet/core/wallet_service.dart';
6 +import 'package:cake_wallet/entities/preferences_key.dart';
7 +import 'package:cake_wallet/entities/wallet_type.dart';
8 +
9 +Future<void> loadCurrentWallet() async {
10 + final appStore = getIt.get<AppStore>();
11 + final name = getIt
12 + .get<SharedPreferences>()
13 + .getString(PreferencesKey.currentWalletName);
14 + final typeRaw =
15 + getIt.get<SharedPreferences>().getInt(PreferencesKey.currentWalletType) ??
16 + 0;
17 + final type = deserializeFromInt(typeRaw);
18 + final password =
19 + await getIt.get<KeyService>().getWalletPassword(walletName: name);
20 + final _service = getIt.get<WalletService>(param1: type);
21 + final wallet = await _service.openWallet(name, password);
22 + appStore.wallet = wallet;
23 +}
lib/entities/mnemonic_item.dart renamed
lib/entities/node.dart renamed
+2 -2
@@ -3,8 +3,8 @@ import 'package:flutter/foundation.dart';
3 import 'dart:convert';
4 import 'package:http/http.dart' as http;
5 import 'package:hive/hive.dart';
6 -import 'package:cake_wallet/src/domain/common/wallet_type.dart';
7 -import 'package:cake_wallet/src/domain/common/digest_request.dart';
6 +import 'package:cake_wallet/entities/wallet_type.dart';
7 +import 'package:cake_wallet/entities/digest_request.dart';
8
9 part 'node.g.dart';
10
lib/entities/node_list.dart renamed
+2 -2
@@ -1,8 +1,8 @@
1 import 'package:flutter/services.dart';
2 import 'package:hive/hive.dart';
3 import "package:yaml/yaml.dart";
4 -import 'package:cake_wallet/src/domain/common/node.dart';
5 -import 'package:cake_wallet/src/domain/common/wallet_type.dart';
4 +import 'package:cake_wallet/entities/node.dart';
5 +import 'package:cake_wallet/entities/wallet_type.dart';
6
7 Future<List<Node>> loadDefaultNodes() async {
8 final nodesRaw = await rootBundle.loadString('assets/node_list.yml');
lib/entities/openalias_record.dart renamed
lib/entities/parseBoolFromString.dart renamed
lib/entities/pathForWallet.dart renamed
+1 -1
@@ -1,5 +1,5 @@
1 import 'dart:io';
2 -import 'package:cake_wallet/src/domain/common/wallet_type.dart';
2 +import 'package:cake_wallet/entities/wallet_type.dart';
3 import 'package:flutter/foundation.dart';
4 import 'package:path_provider/path_provider.dart';
5
lib/entities/pending_transaction.dart renamed
+1 -1
@@ -1,7 +1,7 @@
1 import 'package:flutter/foundation.dart';
2 import 'package:cw_monero/transaction_history.dart' as transaction_history;
3 import 'package:cw_monero/structs/pending_transaction.dart';
4 -import 'package:cake_wallet/src/domain/monero/monero_amount_format.dart';
4 +import 'package:cake_wallet/monero/monero_amount_format.dart';
5
6 class PendingTransaction {
7 PendingTransaction(
lib/entities/preferences_key.dart new
+16
@@ -0,0 +1,16 @@
1 +class PreferencesKey {
2 + static const currentWalletType ='current_wallet_type';
3 + static const currentWalletName ='current_wallet_name';
4 + static const currentNodeIdKey = 'current_node_id';
5 + static const currentBitcoinElectrumSererIdKey = 'current_node_id_btc';
6 + static const currentFiatCurrencyKey = 'current_fiat_currency';
7 + static const currentTransactionPriorityKey = 'current_fee_priority';
8 + static const currentBalanceDisplayModeKey = 'current_balance_display_mode';
9 + static const shouldSaveRecipientAddressKey = 'save_recipient_address';
10 + static const allowBiometricalAuthenticationKey =
11 + 'allow_biometrical_authentication';
12 + static const currentDarkTheme = 'dark_theme';
13 + static const displayActionListModeKey = 'display_list_mode';
14 + static const currentPinLength = 'current_pin_length';
15 + static const currentLanguageCode = 'language_code';
16 +}
\ No newline at end of file
lib/entities/qr_scanner.dart renamed
lib/entities/secret_store_key.dart renamed
lib/entities/sync_status.dart renamed
lib/entities/template.dart renamed
lib/entities/transaction_creation_credentials.dart renamed
lib/entities/transaction_description.dart renamed
+1
@@ -7,6 +7,7 @@ class TransactionDescription extends HiveObject {
7 TransactionDescription({this.id, this.recipientAddress});
8
9 static const boxName = 'TransactionDescriptions';
10 + static const boxKey = 'transactionDescriptionsBoxKey';
11
12 @HiveField(0)
13 String id;
lib/entities/transaction_direction.dart renamed
lib/entities/transaction_history.dart renamed
+1 -1
@@ -1,5 +1,5 @@
1 import 'package:rxdart/rxdart.dart';
2 -import 'package:cake_wallet/src/domain/common/transaction_info.dart';
2 +import 'package:cake_wallet/entities/transaction_info.dart';
3
4 abstract class TransactionHistory {
5 Observable<List<TransactionInfo>> transactions;
lib/entities/transaction_info.dart renamed
+1 -1
@@ -1,4 +1,4 @@
1 -import 'package:cake_wallet/src/domain/common/transaction_direction.dart';
1 +import 'package:cake_wallet/entities/transaction_direction.dart';
2
3 abstract class TransactionInfo extends Object {
4 String id;
lib/entities/transaction_priority.dart renamed
+1 -1
@@ -1,5 +1,5 @@
1 import 'package:cake_wallet/generated/i18n.dart';
2 -import 'package:cake_wallet/src/domain/common/enumerable_item.dart';
2 +import 'package:cake_wallet/entities/enumerable_item.dart';
3
4 class TransactionPriority extends EnumerableItem<int> with Serializable<int> {
5 const TransactionPriority({String title, int raw})
lib/entities/wallet.dart renamed
+7 -7
@@ -1,11 +1,11 @@
1 import 'package:rxdart/rxdart.dart';
2 -import 'package:cake_wallet/src/domain/common/sync_status.dart';
3 -import 'package:cake_wallet/src/domain/common/transaction_history.dart';
4 -import 'package:cake_wallet/src/domain/common/wallet_type.dart';
5 -import 'package:cake_wallet/src/domain/common/transaction_creation_credentials.dart';
6 -import 'package:cake_wallet/src/domain/common/pending_transaction.dart';
7 -import 'package:cake_wallet/src/domain/common/balance.dart';
8 -import 'package:cake_wallet/src/domain/common/node.dart';
2 +import 'package:cake_wallet/entities/sync_status.dart';
3 +import 'package:cake_wallet/entities/transaction_history.dart';
4 +import 'package:cake_wallet/entities/wallet_type.dart';
5 +import 'package:cake_wallet/entities/transaction_creation_credentials.dart';
6 +import 'package:cake_wallet/entities/pending_transaction.dart';
7 +import 'package:cake_wallet/entities/balance.dart';
8 +import 'package:cake_wallet/entities/node.dart';
9
10 abstract class Wallet {
11 WalletType getType();
lib/entities/wallet_description.dart renamed
+1 -1
@@ -1,4 +1,4 @@
1 -import 'package:cake_wallet/src/domain/common/wallet_type.dart';
1 +import 'package:cake_wallet/entities/wallet_type.dart';
2
3 class WalletDescription {
4 WalletDescription({this.name, this.type});
lib/entities/wallet_info.dart renamed
+1 -1
@@ -1,6 +1,6 @@
1 import 'package:flutter/foundation.dart';
2 import 'package:hive/hive.dart';
3 -import 'package:cake_wallet/src/domain/common/wallet_type.dart';
3 +import 'package:cake_wallet/entities/wallet_type.dart';
4
5 part 'wallet_info.g.dart';
6
lib/entities/wallet_type.dart renamed
lib/entities/wallets_manager.dart renamed
+2 -2
@@ -1,5 +1,5 @@
1 -import 'package:cake_wallet/src/domain/common/wallet.dart';
2 -import 'package:cake_wallet/src/domain/common/wallet_description.dart';
1 +import 'package:cake_wallet/entities/wallet.dart';
2 +import 'package:cake_wallet/entities/wallet_description.dart';
3
4 abstract class WalletsManager {
5 Future<Wallet> create(String name, String password, String language);
lib/exchange/changenow/changenow_exchange_provider.dart renamed
+11 -11
@@ -1,18 +1,18 @@
1 import 'dart:convert';
2 -import 'package:cake_wallet/src/domain/exchange/trade_not_found_exeption.dart';
2 +import 'package:cake_wallet/exchange/trade_not_found_exeption.dart';
3 import 'package:flutter/foundation.dart';
4 import 'package:http/http.dart';
5 import 'package:cake_wallet/.secrets.g.dart' as secrets;
6 -import 'package:cake_wallet/src/domain/common/crypto_currency.dart';
7 -import 'package:cake_wallet/src/domain/exchange/exchange_pair.dart';
8 -import 'package:cake_wallet/src/domain/exchange/exchange_provider.dart';
9 -import 'package:cake_wallet/src/domain/exchange/limits.dart';
10 -import 'package:cake_wallet/src/domain/exchange/trade.dart';
11 -import 'package:cake_wallet/src/domain/exchange/trade_request.dart';
12 -import 'package:cake_wallet/src/domain/exchange/trade_state.dart';
13 -import 'package:cake_wallet/src/domain/exchange/changenow/changenow_request.dart';
14 -import 'package:cake_wallet/src/domain/exchange/exchange_provider_description.dart';
15 -import 'package:cake_wallet/src/domain/exchange/trade_not_created_exeption.dart';
6 +import 'package:cake_wallet/entities/crypto_currency.dart';
7 +import 'package:cake_wallet/exchange/exchange_pair.dart';
8 +import 'package:cake_wallet/exchange/exchange_provider.dart';
9 +import 'package:cake_wallet/exchange/limits.dart';
10 +import 'package:cake_wallet/exchange/trade.dart';
11 +import 'package:cake_wallet/exchange/trade_request.dart';
12 +import 'package:cake_wallet/exchange/trade_state.dart';
13 +import 'package:cake_wallet/exchange/changenow/changenow_request.dart';
14 +import 'package:cake_wallet/exchange/exchange_provider_description.dart';
15 +import 'package:cake_wallet/exchange/trade_not_created_exeption.dart';
16
17 class ChangeNowExchangeProvider extends ExchangeProvider {
18 ChangeNowExchangeProvider()
lib/exchange/changenow/changenow_request.dart renamed
+2 -2
@@ -1,6 +1,6 @@
1 import 'package:flutter/foundation.dart';
2 -import 'package:cake_wallet/src/domain/common/crypto_currency.dart';
3 -import 'package:cake_wallet/src/domain/exchange/trade_request.dart';
2 +import 'package:cake_wallet/entities/crypto_currency.dart';
3 +import 'package:cake_wallet/exchange/trade_request.dart';
4
5 class ChangeNowRequest extends TradeRequest {
6 ChangeNowRequest(
lib/exchange/exchange_pair.dart renamed
+1 -1
@@ -1,4 +1,4 @@
1 -import 'package:cake_wallet/src/domain/common/crypto_currency.dart';
1 +import 'package:cake_wallet/entities/crypto_currency.dart';
2
3 class ExchangePair {
4 ExchangePair({this.from, this.to, this.reverse = true});
lib/exchange/exchange_provider.dart renamed
+6 -6
@@ -1,10 +1,10 @@
1 import 'package:flutter/foundation.dart';
2 -import 'package:cake_wallet/src/domain/common/crypto_currency.dart';
3 -import 'package:cake_wallet/src/domain/exchange/trade_request.dart';
4 -import 'package:cake_wallet/src/domain/exchange/exchange_pair.dart';
5 -import 'package:cake_wallet/src/domain/exchange/limits.dart';
6 -import 'package:cake_wallet/src/domain/exchange/trade.dart';
7 -import 'package:cake_wallet/src/domain/exchange/exchange_provider_description.dart';
2 +import 'package:cake_wallet/entities/crypto_currency.dart';
3 +import 'package:cake_wallet/exchange/trade_request.dart';
4 +import 'package:cake_wallet/exchange/exchange_pair.dart';
5 +import 'package:cake_wallet/exchange/limits.dart';
6 +import 'package:cake_wallet/exchange/trade.dart';
7 +import 'package:cake_wallet/exchange/exchange_provider_description.dart';
8
9 abstract class ExchangeProvider {
10 ExchangeProvider({this.pairList});
lib/exchange/exchange_provider_description.dart renamed
+1 -1
@@ -1,4 +1,4 @@
1 -import 'package:cake_wallet/src/domain/common/enumerable_item.dart';
1 +import 'package:cake_wallet/entities/enumerable_item.dart';
2
3 class ExchangeProviderDescription extends EnumerableItem<int>
4 with Serializable<int> {
lib/exchange/exchange_template.dart renamed
lib/exchange/exchange_trade_state.dart renamed
+1 -1
@@ -1,5 +1,5 @@
1 import 'package:flutter/foundation.dart';
2 -import 'package:cake_wallet/src/domain/exchange/trade.dart';
2 +import 'package:cake_wallet/exchange/trade.dart';
3
4 abstract class ExchangeTradeState {}
5
lib/exchange/limits.dart renamed
lib/exchange/limits_state.dart renamed
+1 -1
@@ -1,5 +1,5 @@
1 import 'package:flutter/foundation.dart';
2 -import 'package:cake_wallet/src/domain/exchange/limits.dart';
2 +import 'package:cake_wallet/exchange/limits.dart';
3
4 abstract class LimitsState {}
5
lib/exchange/morphtoken/morphtoken_exchange_provider.dart new
+202
@@ -0,0 +1,202 @@
1 +import 'dart:convert';
2 +import 'package:cake_wallet/core/amount_converter.dart';
3 +import 'package:cake_wallet/monero/monero_amount_format.dart';
4 +import 'package:hive/hive.dart';
5 +import 'package:cake_wallet/exchange/trade_not_found_exeption.dart';
6 +import 'package:flutter/foundation.dart';
7 +import 'package:http/http.dart';
8 +import 'package:cake_wallet/entities/crypto_currency.dart';
9 +import 'package:cake_wallet/exchange/exchange_pair.dart';
10 +import 'package:cake_wallet/exchange/exchange_provider.dart';
11 +import 'package:cake_wallet/exchange/limits.dart';
12 +import 'package:cake_wallet/exchange/trade.dart';
13 +import 'package:cake_wallet/exchange/trade_request.dart';
14 +import 'package:cake_wallet/exchange/trade_state.dart';
15 +import 'package:cake_wallet/exchange/morphtoken/morphtoken_request.dart';
16 +import 'package:cake_wallet/exchange/exchange_provider_description.dart';
17 +import 'package:cake_wallet/exchange/trade_not_created_exeption.dart';
18 +
19 +class MorphTokenExchangeProvider extends ExchangeProvider {
20 + MorphTokenExchangeProvider({@required this.trades})
21 + : super(pairList: [
22 + ExchangePair(from: CryptoCurrency.xmr, to: CryptoCurrency.eth),
23 + ExchangePair(from: CryptoCurrency.xmr, to: CryptoCurrency.bch),
24 + ExchangePair(from: CryptoCurrency.xmr, to: CryptoCurrency.ltc),
25 + ExchangePair(from: CryptoCurrency.xmr, to: CryptoCurrency.dash),
26 + ExchangePair(from: CryptoCurrency.dash, to: CryptoCurrency.btc),
27 + ExchangePair(from: CryptoCurrency.dash, to: CryptoCurrency.eth),
28 + ExchangePair(from: CryptoCurrency.dash, to: CryptoCurrency.bch),
29 + ExchangePair(from: CryptoCurrency.dash, to: CryptoCurrency.ltc),
30 + ExchangePair(from: CryptoCurrency.dash, to: CryptoCurrency.xmr),
31 + ExchangePair(from: CryptoCurrency.ltc, to: CryptoCurrency.btc),
32 + ExchangePair(from: CryptoCurrency.ltc, to: CryptoCurrency.eth),
33 + ExchangePair(from: CryptoCurrency.ltc, to: CryptoCurrency.bch),
34 + ExchangePair(from: CryptoCurrency.ltc, to: CryptoCurrency.dash),
35 + ExchangePair(from: CryptoCurrency.ltc, to: CryptoCurrency.xmr),
36 + ExchangePair(from: CryptoCurrency.bch, to: CryptoCurrency.btc),
37 + ExchangePair(from: CryptoCurrency.bch, to: CryptoCurrency.eth),
38 + ExchangePair(from: CryptoCurrency.bch, to: CryptoCurrency.ltc),
39 + ExchangePair(from: CryptoCurrency.bch, to: CryptoCurrency.dash),
40 + ExchangePair(from: CryptoCurrency.bch, to: CryptoCurrency.xmr),
41 + ExchangePair(from: CryptoCurrency.eth, to: CryptoCurrency.btc),
42 + ExchangePair(from: CryptoCurrency.eth, to: CryptoCurrency.bch),
43 + ExchangePair(from: CryptoCurrency.eth, to: CryptoCurrency.ltc),
44 + ExchangePair(from: CryptoCurrency.eth, to: CryptoCurrency.dash),
45 + ExchangePair(from: CryptoCurrency.eth, to: CryptoCurrency.xmr),
46 + ExchangePair(from: CryptoCurrency.btc, to: CryptoCurrency.eth),
47 + ExchangePair(from: CryptoCurrency.btc, to: CryptoCurrency.bch),
48 + ExchangePair(from: CryptoCurrency.btc, to: CryptoCurrency.ltc),
49 + ExchangePair(from: CryptoCurrency.btc, to: CryptoCurrency.dash),
50 + ExchangePair(from: CryptoCurrency.btc, to: CryptoCurrency.xmr)
51 + ]);
52 +
53 + Box<Trade> trades;
54 +
55 + static const apiUri = 'https://api.morphtoken.com';
56 + static const _morphURISuffix = '/morph';
57 + static const _limitsURISuffix = '/limits';
58 + static const _ratesURISuffix = '/rates';
59 + static const weight = 10000;
60 +
61 + @override
62 + String get title => 'MorphToken';
63 +
64 + @override
65 + ExchangeProviderDescription get description =>
66 + ExchangeProviderDescription.morphToken;
67 +
68 + @override
69 + Future<Limits> fetchLimits({CryptoCurrency from, CryptoCurrency to}) async {
70 + final url = apiUri + _limitsURISuffix;
71 + final headers = {'Content-type': 'application/json'};
72 + final body = json.encode({
73 + "input": {"asset": from.toString()},
74 + "output": [
75 + {"asset": to.toString(), "weight": weight}
76 + ]
77 + });
78 + final response = await post(url, headers: headers, body: body);
79 + final responseJSON = json.decode(response.body) as Map<String, dynamic>;
80 +
81 + final min = responseJSON['input']['limits']['min'] as int;
82 + int max;
83 + double ethMax;
84 +
85 + if (from == CryptoCurrency.eth) {
86 + ethMax = responseJSON['input']['limits']['max'] as double;
87 + } else {
88 + max = responseJSON['input']['limits']['max'] as int;
89 + }
90 +
91 + double minFormatted = AmountConverter.amountIntToDouble(from, min);
92 + double maxFormatted = AmountConverter.amountIntToDouble(from, max);
93 +
94 + return Limits(min: minFormatted, max: maxFormatted);
95 + }
96 +
97 + @override
98 + Future<Trade> createTrade({TradeRequest request}) async {
99 + const url = apiUri + _morphURISuffix;
100 + final _request = request as MorphTokenRequest;
101 + final body = {
102 + "input": {
103 + "asset": _request.from.toString(),
104 + "refund": _request.refundAddress
105 + },
106 + "output": [
107 + {
108 + "asset": _request.to.toString(),
109 + "weight": weight,
110 + "address": _request.address
111 + }
112 + ],
113 + "tag": "cakewallet"
114 + };
115 +
116 + final response = await post(url,
117 + headers: {'Content-Type': 'application/json'}, body: json.encode(body));
118 +
119 + if (response.statusCode != 200) {
120 + if (response.statusCode == 400) {
121 + final responseJSON = json.decode(response.body) as Map<String, dynamic>;
122 + final error = responseJSON['description'] as String;
123 +
124 + throw TradeNotCreatedException(description, description: error);
125 + }
126 +
127 + throw TradeNotCreatedException(description);
128 + }
129 +
130 + final responseJSON = json.decode(response.body) as Map<String, dynamic>;
131 + final id = responseJSON['id'] as String;
132 +
133 + return Trade(
134 + id: id,
135 + provider: description,
136 + from: _request.from,
137 + to: _request.to,
138 + state: TradeState.created,
139 + amount: _request.amount,
140 + createdAt: DateTime.now());
141 + }
142 +
143 + @override
144 + Future<Trade> findTradeById({@required String id}) async {
145 + final url = apiUri + _morphURISuffix + '/' + id;
146 + final response = await get(url);
147 +
148 + if (response.statusCode != 200) {
149 + if (response.statusCode == 400) {
150 + final responseJSON = json.decode(response.body) as Map<String, dynamic>;
151 + final error = responseJSON['description'] as String;
152 +
153 + throw TradeNotFoundException(id,
154 + provider: description, description: error);
155 + }
156 +
157 + throw TradeNotFoundException(id, provider: description);
158 + }
159 +
160 + final responseJSON = json.decode(response.body) as Map<String, dynamic>;
161 + final fromCurrency = responseJSON['input']['asset'] as String;
162 + final from = CryptoCurrency.fromString(fromCurrency.toLowerCase());
163 + final toCurrency = responseJSON['output'][0]['asset'] as String;
164 + final to = CryptoCurrency.fromString(toCurrency.toLowerCase());
165 + final inputAddress = responseJSON['input']['deposit_address'] as String;
166 + final status = responseJSON['state'] as String;
167 + final state = TradeState.deserialize(raw: status.toLowerCase());
168 +
169 + String amount = "";
170 + for (final trade in trades.values) {
171 + if (trade.id == id) {
172 + amount = trade.amount;
173 + break;
174 + }
175 + }
176 +
177 + return Trade(
178 + id: id,
179 + from: from,
180 + to: to,
181 + provider: description,
182 + inputAddress: inputAddress,
183 + amount: amount,
184 + state: state);
185 + }
186 +
187 + @override
188 + Future<double> calculateAmount(
189 + {CryptoCurrency from, CryptoCurrency to, double amount}) async {
190 + final url = apiUri + _ratesURISuffix;
191 + final response = await get(url);
192 + final responseJSON = json.decode(response.body) as Map<String, dynamic>;
193 + final rate = responseJSON['data'][from.toString()][to.toString()] as String;
194 +
195 + try {
196 + final estimatedAmount = double.parse(rate) * amount;
197 + return estimatedAmount;
198 + } catch (e) {
199 + return 0.0;
200 + }
201 + }
202 +}
lib/exchange/morphtoken/morphtoken_request.dart renamed
+2 -2
@@ -1,6 +1,6 @@
1 import 'package:flutter/foundation.dart';
2 -import 'package:cake_wallet/src/domain/common/crypto_currency.dart';
3 -import 'package:cake_wallet/src/domain/exchange/trade_request.dart';
2 +import 'package:cake_wallet/entities/crypto_currency.dart';
3 +import 'package:cake_wallet/exchange/trade_request.dart';
4
5 class MorphTokenRequest extends TradeRequest {
6 MorphTokenRequest(
lib/exchange/trade.dart renamed
+5 -4
@@ -1,8 +1,8 @@
1 import 'package:hive/hive.dart';
2 -import 'package:cake_wallet/src/domain/common/crypto_currency.dart';
3 -import 'package:cake_wallet/src/domain/exchange/exchange_provider_description.dart';
4 -import 'package:cake_wallet/src/domain/exchange/trade_state.dart';
5 -import 'package:cake_wallet/src/domain/common/format_amount.dart';
2 +import 'package:cake_wallet/entities/crypto_currency.dart';
3 +import 'package:cake_wallet/exchange/exchange_provider_description.dart';
4 +import 'package:cake_wallet/exchange/trade_state.dart';
5 +import 'package:cake_wallet/entities/format_amount.dart';
6
7 part 'trade.g.dart';
8
@@ -28,6 +28,7 @@ class Trade extends HiveObject {
28 stateRaw = state?.raw;
29
30 static const boxName = 'Trades';
31 + static const boxKey = 'tradesBoxKey';
32
33 @HiveField(0)
34 String id;
lib/exchange/trade_not_created_exeption.dart renamed
+1 -1
@@ -1,4 +1,4 @@
1 -import 'package:cake_wallet/src/domain/exchange/exchange_provider_description.dart';
1 +import 'package:cake_wallet/exchange/exchange_provider_description.dart';
2 import 'package:cake_wallet/generated/i18n.dart';
3
4 class TradeNotCreatedException implements Exception {
lib/exchange/trade_not_found_exeption.dart renamed
+1 -1
@@ -1,4 +1,4 @@
1 -import 'package:cake_wallet/src/domain/exchange/exchange_provider_description.dart';
1 +import 'package:cake_wallet/exchange/exchange_provider_description.dart';
2 import 'package:cake_wallet/generated/i18n.dart';
3
4 class TradeNotFoundException implements Exception {
lib/exchange/trade_request.dart renamed
lib/exchange/trade_state.dart renamed
+1 -1
@@ -1,5 +1,5 @@
1 import 'package:flutter/foundation.dart';
2 -import 'package:cake_wallet/src/domain/common/enumerable_item.dart';
2 +import 'package:cake_wallet/entities/enumerable_item.dart';
3
4 class TradeState extends EnumerableItem<String> with Serializable<String> {
5 const TradeState({@required String raw, @required String title})
lib/exchange/xmrto/xmrto_exchange_provider.dart renamed
+11 -11
@@ -1,17 +1,17 @@
1 import 'dart:convert';
2 import 'package:flutter/foundation.dart';
3 import 'package:http/http.dart';
4 -import 'package:cake_wallet/src/domain/common/crypto_currency.dart';
5 -import 'package:cake_wallet/src/domain/exchange/exchange_pair.dart';
6 -import 'package:cake_wallet/src/domain/exchange/exchange_provider.dart';
7 -import 'package:cake_wallet/src/domain/exchange/limits.dart';
8 -import 'package:cake_wallet/src/domain/exchange/trade.dart';
9 -import 'package:cake_wallet/src/domain/exchange/trade_request.dart';
10 -import 'package:cake_wallet/src/domain/exchange/trade_state.dart';
11 -import 'package:cake_wallet/src/domain/exchange/xmrto/xmrto_trade_request.dart';
12 -import 'package:cake_wallet/src/domain/exchange/trade_not_created_exeption.dart';
13 -import 'package:cake_wallet/src/domain/exchange/exchange_provider_description.dart';
14 -import 'package:cake_wallet/src/domain/exchange/trade_not_found_exeption.dart';
4 +import 'package:cake_wallet/entities/crypto_currency.dart';
5 +import 'package:cake_wallet/exchange/exchange_pair.dart';
6 +import 'package:cake_wallet/exchange/exchange_provider.dart';
7 +import 'package:cake_wallet/exchange/limits.dart';
8 +import 'package:cake_wallet/exchange/trade.dart';
9 +import 'package:cake_wallet/exchange/trade_request.dart';
10 +import 'package:cake_wallet/exchange/trade_state.dart';
11 +import 'package:cake_wallet/exchange/xmrto/xmrto_trade_request.dart';
12 +import 'package:cake_wallet/exchange/trade_not_created_exeption.dart';
13 +import 'package:cake_wallet/exchange/exchange_provider_description.dart';
14 +import 'package:cake_wallet/exchange/trade_not_found_exeption.dart';
15
16 class XMRTOExchangeProvider extends ExchangeProvider {
17 XMRTOExchangeProvider()
lib/exchange/xmrto/xmrto_trade_request.dart renamed
+2 -2
@@ -1,6 +1,6 @@
1 import 'package:flutter/foundation.dart';
2 -import 'package:cake_wallet/src/domain/common/crypto_currency.dart';
3 -import 'package:cake_wallet/src/domain/exchange/trade_request.dart';
2 +import 'package:cake_wallet/entities/crypto_currency.dart';
3 +import 'package:cake_wallet/exchange/trade_request.dart';
4
5 class XMRTOTradeRequest extends TradeRequest {
6 XMRTOTradeRequest(
lib/main.dart
+95 -137
@@ -1,3 +1,5 @@
1 +import 'package:cake_wallet/entities/transaction_description.dart';
2 +import 'package:cake_wallet/entities/transaction_description.dart';
3 import 'package:cake_wallet/reactions/bootstrap.dart';
4 import 'package:cake_wallet/routes.dart';
5 import 'package:cake_wallet/store/app_store.dart';
@@ -21,38 +23,41 @@ import 'package:cw_monero/wallet.dart' as monero_wallet;
23 import 'package:cake_wallet/router.dart';
24 import 'theme_changer.dart';
25 import 'themes.dart';
24 -import 'package:cake_wallet/src/domain/common/get_encryption_key.dart';
25 -import 'package:cake_wallet/src/domain/common/contact.dart';
26 -import 'package:cake_wallet/src/domain/common/node.dart';
27 -import 'package:cake_wallet/src/domain/common/wallet_info.dart';
28 -import 'package:cake_wallet/src/domain/exchange/trade.dart';
29 -import 'package:cake_wallet/src/domain/monero/transaction_description.dart';
26 +import 'package:cake_wallet/entities/get_encryption_key.dart';
27 +import 'package:cake_wallet/entities/contact.dart';
28 +import 'package:cake_wallet/entities/node.dart';
29 +import 'package:cake_wallet/entities/wallet_info.dart';
30 +import 'package:cake_wallet/exchange/trade.dart';
31 +
32 +// import 'package:cake_wallet/monero/transaction_description.dart';
33 import 'package:cake_wallet/src/reactions/set_reactions.dart';
31 -import 'package:cake_wallet/src/stores/login/login_store.dart';
32 -import 'package:cake_wallet/src/stores/balance/balance_store.dart';
33 -import 'package:cake_wallet/src/stores/sync/sync_store.dart';
34 -import 'package:cake_wallet/src/stores/wallet/wallet_store.dart';
35 -import 'package:cake_wallet/src/stores/send_template/send_template_store.dart';
36 -import 'package:cake_wallet/src/stores/exchange_template/exchange_template_store.dart';
34 +
35 +// import 'package:cake_wallet/src/stores/login/login_store.dart';
36 +// import 'package:cake_wallet/src/stores/balance/balance_store.dart';
37 +// import 'package:cake_wallet/src/stores/sync/sync_store.dart';
38 +// import 'package:cake_wallet/src/stores/wallet/wallet_store.dart';
39 +// import 'package:cake_wallet/src/stores/send_template/send_template_store.dart';
40 +// import 'package:cake_wallet/src/stores/exchange_template/exchange_template_store.dart';
41 import 'package:cake_wallet/src/screens/root/root.dart';
42
43 //import 'package:cake_wallet/src/stores/authentication/authentication_store.dart';
40 -import 'package:cake_wallet/src/stores/settings/settings_store.dart';
41 -import 'package:cake_wallet/src/stores/price/price_store.dart';
42 -import 'package:cake_wallet/src/domain/services/user_service.dart';
43 -import 'package:cake_wallet/src/domain/services/wallet_list_service.dart';
44 -import 'package:cake_wallet/src/domain/common/balance_display_mode.dart';
45 -import 'package:cake_wallet/src/domain/common/default_settings_migration.dart';
46 -import 'package:cake_wallet/src/domain/common/fiat_currency.dart';
47 -import 'package:cake_wallet/src/domain/common/transaction_priority.dart';
48 -import 'package:cake_wallet/src/domain/common/wallet_type.dart';
49 -import 'package:cake_wallet/src/domain/common/template.dart';
50 -import 'package:cake_wallet/src/domain/exchange/exchange_template.dart';
51 -import 'package:cake_wallet/src/domain/services/wallet_service.dart';
52 -import 'package:cake_wallet/src/domain/services/fiat_convertation_service.dart';
44 +// import 'package:cake_wallet/src/stores/settings/settings_store.dart';
45 +// import 'package:cake_wallet/src/stores/price/price_store.dart';
46 +// import 'package:cake_wallet/src/domain/services/user_service.dart';
47 +// import 'package:cake_wallet/src/domain/services/wallet_list_service.dart';
48 +import 'package:cake_wallet/entities/balance_display_mode.dart';
49 +import 'package:cake_wallet/entities/default_settings_migration.dart';
50 +import 'package:cake_wallet/entities/fiat_currency.dart';
51 +import 'package:cake_wallet/entities/transaction_priority.dart';
52 +import 'package:cake_wallet/entities/wallet_type.dart';
53 +import 'package:cake_wallet/entities/template.dart';
54 +import 'package:cake_wallet/exchange/exchange_template.dart';
55 +
56 +// import 'package:cake_wallet/src/domain/services/wallet_service.dart';
57 +// import 'package:cake_wallet/src/domain/services/fiat_convertation_service.dart';
58 import 'package:cake_wallet/generated/i18n.dart';
54 -import 'package:cake_wallet/src/domain/common/language.dart';
55 -import 'package:cake_wallet/src/stores/seed_language/seed_language_store.dart';
59 +import 'package:cake_wallet/entities/language.dart';
60 +// import 'package:cake_wallet/src/stores/seed_language/seed_language_store.dart';
61
62 bool isThemeChangerRegistered = false;
63
@@ -74,12 +79,9 @@ void main() async {
79
80 final secureStorage = FlutterSecureStorage();
81 final transactionDescriptionsBoxKey = await getEncryptionKey(
77 - secureStorage: secureStorage,
78 - forKey: 'transactionDescriptionsBoxKey'); // FIXME: Unnamed constant
82 + secureStorage: secureStorage, forKey: TransactionDescription.boxKey);
83 final tradesBoxKey = await getEncryptionKey(
80 - secureStorage: secureStorage,
81 - forKey: 'tradesBoxKey'); // FIXME: Unnamed constant
82 -
84 + secureStorage: secureStorage, forKey: Trade.boxKey);
85 final contacts = await Hive.openBox<Contact>(Contact.boxName);
86 final nodes = await Hive.openBox<Node>(Node.boxName);
87 final transactionDescriptions = await Hive.openBox<TransactionDescription>(
@@ -93,35 +95,35 @@ void main() async {
95 await Hive.openBox<ExchangeTemplate>(ExchangeTemplate.boxName);
96
97 final sharedPreferences = await SharedPreferences.getInstance();
96 - final walletService = WalletService();
97 - final fiatConvertationService = FiatConvertationService();
98 - final walletListService = WalletListService(
99 - secureStorage: secureStorage,
100 - walletInfoSource: walletInfoSource,
101 - walletService: walletService,
102 - sharedPreferences: sharedPreferences);
103 - final userService = UserService(
104 - sharedPreferences: sharedPreferences, secureStorage: secureStorage);
105 - final settingsStore = await SettingsStoreBase.load(
106 - nodes: nodes,
107 - sharedPreferences: sharedPreferences,
108 - initialFiatCurrency: FiatCurrency.usd,
109 - initialTransactionPriority: TransactionPriority.slow,
110 - initialBalanceDisplayMode: BalanceDisplayMode.availableBalance);
111 - final priceStore = PriceStore();
112 - final walletStore =
113 - WalletStore(walletService: walletService, settingsStore: settingsStore);
114 - final syncStore = SyncStore(walletService: walletService);
115 - final balanceStore = BalanceStore(
116 - walletService: walletService,
117 - settingsStore: settingsStore,
118 - priceStore: priceStore);
119 - final loginStore = LoginStore(
120 - sharedPreferences: sharedPreferences, walletsService: walletListService);
121 - final seedLanguageStore = SeedLanguageStore();
122 - final sendTemplateStore = SendTemplateStore(templateSource: templates);
123 - final exchangeTemplateStore =
124 - ExchangeTemplateStore(templateSource: exchangeTemplates);
98 + // final walletService = WalletService();
99 + // final fiatConvertationService = FiatConvertationService();
100 + // final walletListService = WalletListService(
101 + // secureStorage: secureStorage,
102 + // walletInfoSource: walletInfoSource,
103 + // walletService: walletService,
104 + // sharedPreferences: sharedPreferences);
105 + // final userService = UserService(
106 + // sharedPreferences: sharedPreferences, secureStorage: secureStorage);
107 + // final settingsStore = await SettingsStoreBase.load(
108 + // nodes: nodes,
109 + // sharedPreferences: sharedPreferences,
110 + // initialFiatCurrency: FiatCurrency.usd,
111 + // initialTransactionPriority: TransactionPriority.slow,
112 + // initialBalanceDisplayMode: BalanceDisplayMode.availableBalance);
113 + // final priceStore = PriceStore();
114 + // final walletStore =
115 + // WalletStore(walletService: walletService, settingsStore: settingsStore);
116 + // final syncStore = SyncStore(walletService: walletService);
117 + // final balanceStore = BalanceStore(
118 + // walletService: walletService,
119 + // settingsStore: settingsStore,
120 + // priceStore: priceStore);
121 + // final loginStore = LoginStore(
122 + // sharedPreferences: sharedPreferences, walletsService: walletListService);
123 + // final seedLanguageStore = SeedLanguageStore();
124 + // final sendTemplateStore = SendTemplateStore(templateSource: templates);
125 + // final exchangeTemplateStore =
126 + // ExchangeTemplateStore(templateSource: exchangeTemplates);
127
128 final walletCreationService = WalletCreationService();
129 final authService = AuthService();
@@ -132,42 +134,21 @@ void main() async {
134 walletInfoSource: walletInfoSource,
135 contactSource: contacts,
136 tradesSource: trades,
135 - fiatConvertationService: fiatConvertationService,
137 + // fiatConvertationService: fiatConvertationService,
138 templates: templates,
139 exchangeTemplates: exchangeTemplates,
140 initialMigrationVersion: 4);
141
140 - setReactions(
141 - settingsStore: settingsStore,
142 - priceStore: priceStore,
143 - syncStore: syncStore,
144 - walletStore: walletStore,
145 - walletService: walletService,
146 -// authenticationStore: authenticationStore,
147 - loginStore: loginStore);
142 +// setReactions(
143 +// settingsStore: settingsStore,
144 +// priceStore: priceStore,
145 +// syncStore: syncStore,
146 +// walletStore: walletStore,
147 +// walletService: walletService,
148 +// // authenticationStore: authenticationStore,
149 +// loginStore: loginStore);
150
149 - runApp(MultiProvider(providers: [
150 - Provider(create: (_) => sharedPreferences),
151 - Provider(create: (_) => walletService),
152 - Provider(create: (_) => walletListService),
153 - Provider(create: (_) => userService),
154 - Provider(create: (_) => settingsStore),
155 - Provider(create: (_) => priceStore),
156 - Provider(create: (_) => walletStore),
157 - Provider(create: (_) => syncStore),
158 - Provider(create: (_) => balanceStore),
159 -// Provider(create: (_) => authenticationStore),
160 - Provider(create: (_) => contacts),
161 - Provider(create: (_) => nodes),
162 - Provider(create: (_) => transactionDescriptions),
163 - Provider(create: (_) => trades),
164 - Provider(create: (_) => seedLanguageStore),
165 - Provider(create: (_) => sendTemplateStore),
166 - Provider(create: (_) => exchangeTemplateStore),
167 -// Provider(create: (_) => appStore),
168 - Provider(create: (_) => walletCreationService),
169 - Provider(create: (_) => authService)
170 - ], child: CakeWalletApp()));
151 + runApp(CakeWalletApp());
152 }
153
154 Future<void> initialSetup(
@@ -176,7 +157,7 @@ Future<void> initialSetup(
157 @required Box<WalletInfo> walletInfoSource,
158 @required Box<Contact> contactSource,
159 @required Box<Trade> tradesSource,
179 - @required FiatConvertationService fiatConvertationService,
160 + // @required FiatConvertationService fiatConvertationService,
161 @required Box<Template> templates,
162 @required Box<ExchangeTemplate> exchangeTemplates,
163 int initialMigrationVersion = 4}) async {
@@ -191,9 +172,7 @@ Future<void> initialSetup(
172 tradesSource: tradesSource,
173 templates: templates,
174 exchangeTemplates: exchangeTemplates);
194 - await bootstrap(
195 - fiatConvertationService: fiatConvertationService,
196 - navigatorKey: navigatorKey);
175 + await bootstrap(navigatorKey);
176 monero_wallet.onStartup();
177 }
178
@@ -220,22 +199,22 @@ class CakeWalletApp extends StatelessWidget {
199 class MaterialAppWithTheme extends StatelessWidget {
200 @override
201 Widget build(BuildContext context) {
223 - final sharedPreferences = Provider.of<SharedPreferences>(context);
224 - final walletService = Provider.of<WalletService>(context);
225 - final walletListService = Provider.of<WalletListService>(context);
226 - final userService = Provider.of<UserService>(context);
227 - final settingsStore = Provider.of<SettingsStore>(context);
228 - final priceStore = Provider.of<PriceStore>(context);
229 - final walletStore = Provider.of<WalletStore>(context);
230 - final syncStore = Provider.of<SyncStore>(context);
231 - final balanceStore = Provider.of<BalanceStore>(context);
202 + // final sharedPreferences = Provider.of<SharedPreferences>(context);
203 + // final walletService = Provider.of<WalletService>(context);
204 + // final walletListService = Provider.of<WalletListService>(context);
205 + // final userService = Provider.of<UserService>(context);
206 + // final settingsStore = Provider.of<SettingsStore>(context);
207 + // final priceStore = Provider.of<PriceStore>(context);
208 + // final walletStore = Provider.of<WalletStore>(context);
209 + // final syncStore = Provider.of<SyncStore>(context);
210 + // final balanceStore = Provider.of<BalanceStore>(context);
211 final theme = Provider.of<ThemeChanger>(context);
233 - final currentLanguage = Provider.of<Language>(context);
234 - final contacts = Provider.of<Box<Contact>>(context);
235 - final nodes = Provider.of<Box<Node>>(context);
236 - final trades = Provider.of<Box<Trade>>(context);
237 - final transactionDescriptions =
238 - Provider.of<Box<TransactionDescription>>(context);
212 + // final currentLanguage = Provider.of<Language>(context);
213 + // final contacts = Provider.of<Box<Contact>>(context);
214 + // final nodes = Provider.of<Box<Node>>(context);
215 + // final trades = Provider.of<Box<Trade>>(context);
216 + // final transactionDescriptions =
217 + // Provider.of<Box<TransactionDescription>>(context);
218
219 if (!isThemeChangerRegistered) {
220 setupThemeChangerStore(theme);
@@ -252,16 +231,9 @@ class MaterialAppWithTheme extends StatelessWidget {
231 final statusBarIconBrightness =
232 _settingsStore.isDarkTheme ? Brightness.light : Brightness.dark;
233 final authenticationStore = getIt.get<AuthenticationStore>();
255 - String initialRoute;
256 -
257 - switch (authenticationStore.state) {
258 - case AuthenticationState.denied:
259 - initialRoute = Routes.welcome;
260 - break;
261 - default:
262 - initialRoute = Routes.login;
263 - break;
264 - }
234 + final initialRoute = authenticationStore.state == AuthenticationState.denied
235 + ? Routes.welcome
236 + : Routes.login;
237
238 SystemChrome.setSystemUIOverlayStyle(SystemUiOverlayStyle(
239 statusBarColor: statusBarColor,
@@ -281,22 +253,8 @@ class MaterialAppWithTheme extends StatelessWidget {
253 GlobalWidgetsLocalizations.delegate,
254 ],
255 supportedLocales: S.delegate.supportedLocales,
284 - locale: Locale(currentLanguage.getCurrentLanguage()),
285 - onGenerateRoute: (settings) => Router.generateRoute(
286 - sharedPreferences: sharedPreferences,
287 - walletListService: walletListService,
288 - walletService: walletService,
289 - userService: userService,
290 - settings: settings,
291 - priceStore: priceStore,
292 - walletStore: walletStore,
293 - syncStore: syncStore,
294 - balanceStore: balanceStore,
295 - settingsStore: settingsStore,
296 - contacts: contacts,
297 - nodes: nodes,
298 - trades: trades,
299 - transactionDescriptions: transactionDescriptions),
256 + // locale: Locale(currentLanguage.getCurrentLanguage()),
257 + onGenerateRoute: (settings) => Router.generateRoute(settings),
258 initialRoute: initialRoute,
259 ));
260 }
lib/monero/account.dart renamed
lib/monero/get_height_by_date.dart renamed
+2
@@ -1,5 +1,7 @@
1 import 'package:intl/intl.dart';
2
3 +// FIXME: Hardcoded values; Works only for monero
4 +
5 final dateFormat = DateFormat('yyyy-MM');
6 final dates = {
7 "2014-5": 18844,
lib/monero/mnemonics/chinese_simplified.dart renamed
lib/monero/mnemonics/dutch.dart renamed
lib/monero/mnemonics/english.dart renamed
lib/monero/mnemonics/german.dart renamed
lib/monero/mnemonics/japanese.dart renamed
lib/monero/mnemonics/portuguese.dart renamed
lib/monero/mnemonics/russian.dart renamed
lib/monero/mnemonics/spanish.dart renamed
lib/monero/monero_account_list.dart
+1 -1
@@ -1,5 +1,5 @@
1 import 'package:mobx/mobx.dart';
2 -import 'package:cake_wallet/src/domain/monero/account.dart';
2 +import 'package:cake_wallet/monero/account.dart';
3 import 'package:cw_monero/account_list.dart' as account_list;
4
5 part 'monero_account_list.g.dart';
lib/monero/monero_amount_format.dart renamed
+1 -1
@@ -1,5 +1,5 @@
1 import 'package:intl/intl.dart';
2 -import 'package:cake_wallet/src/domain/common/crypto_amount_format.dart';
2 +import 'package:cake_wallet/entities/crypto_amount_format.dart';
3
4 const moneroAmountLength = 12;
5 const moneroAmountDivider = 1000000000000;
lib/monero/monero_balance.dart
+1 -1
@@ -1,5 +1,5 @@
1 import 'package:flutter/foundation.dart';
2 -import 'package:cake_wallet/src/domain/monero/monero_amount_format.dart';
2 +import 'package:cake_wallet/monero/monero_amount_format.dart';
3
4 class MoneroBalance {
5 MoneroBalance({@required this.fullBalance, @required this.unlockedBalance})
lib/monero/monero_subaddress_list.dart
+1 -1
@@ -1,7 +1,7 @@
1 import 'package:flutter/services.dart';
2 import 'package:mobx/mobx.dart';
3 import 'package:cw_monero/subaddress_list.dart' as subaddress_list;
4 -import 'package:cake_wallet/src/domain/monero/subaddress.dart';
4 +import 'package:cake_wallet/monero/subaddress.dart';
5
6 part 'monero_subaddress_list.g.dart';
7
lib/monero/monero_transaction_creation_credentials.dart renamed
+2 -2
@@ -1,5 +1,5 @@
1 -import 'package:cake_wallet/src/domain/common/transaction_creation_credentials.dart';
2 -import 'package:cake_wallet/src/domain/common/transaction_priority.dart';
1 +import 'package:cake_wallet/entities/transaction_creation_credentials.dart';
2 +import 'package:cake_wallet/entities/transaction_priority.dart';
3
4 class MoneroTransactionCreationCredentials
5 extends TransactionCreationCredentials {
lib/monero/monero_transaction_history.dart
+2 -2
@@ -3,8 +3,8 @@ import 'package:mobx/mobx.dart';
3 import 'package:cw_monero/transaction_history.dart'
4 as monero_transaction_history;
5 import 'package:cake_wallet/core/transaction_history.dart';
6 -import 'package:cake_wallet/src/domain/common/transaction_info.dart';
7 -import 'package:cake_wallet/src/domain/monero/monero_transaction_info.dart';
6 +import 'package:cake_wallet/entities/transaction_info.dart';
7 +import 'package:cake_wallet/monero/monero_transaction_info.dart';
8
9 part 'monero_transaction_history.g.dart';
10
lib/monero/monero_transaction_info.dart renamed
+5 -5
@@ -1,9 +1,9 @@
1 -import 'package:cake_wallet/src/domain/common/transaction_info.dart';
2 -import 'package:cake_wallet/src/domain/monero/monero_amount_format.dart';
1 +import 'package:cake_wallet/entities/transaction_info.dart';
2 +import 'package:cake_wallet/monero/monero_amount_format.dart';
3 import 'package:cw_monero/structs/transaction_info_row.dart';
4 -import 'package:cake_wallet/src/domain/common/parseBoolFromString.dart';
5 -import 'package:cake_wallet/src/domain/common/transaction_direction.dart';
6 -import 'package:cake_wallet/src/domain/common/format_amount.dart';
4 +import 'package:cake_wallet/entities/parseBoolFromString.dart';
5 +import 'package:cake_wallet/entities/transaction_direction.dart';
6 +import 'package:cake_wallet/entities/format_amount.dart';
7
8 class MoneroTransactionInfo extends TransactionInfo {
9 MoneroTransactionInfo(this.id, this.height, this.direction, this.date,
lib/monero/monero_wallet.dart
+12 -8
@@ -1,5 +1,5 @@
1 -import 'package:cake_wallet/src/domain/common/wallet_info.dart';
2 -import 'package:cake_wallet/src/domain/monero/monero_transaction_creation_credentials.dart';
1 +import 'package:cake_wallet/entities/wallet_info.dart';
2 +import 'package:cake_wallet/monero/monero_transaction_creation_credentials.dart';
3 import 'package:flutter/foundation.dart';
4 import 'package:mobx/mobx.dart';
5 import 'package:cw_monero/wallet.dart';
@@ -10,12 +10,12 @@ import 'package:cake_wallet/monero/monero_transaction_history.dart';
10 import 'package:cake_wallet/monero/monero_subaddress_list.dart';
11 import 'package:cake_wallet/monero/monero_account_list.dart';
12 import 'package:cake_wallet/core/wallet_base.dart';
13 -import 'package:cake_wallet/src/domain/common/sync_status.dart';
14 -import 'package:cake_wallet/src/domain/monero/account.dart';
15 -import 'package:cake_wallet/src/domain/monero/subaddress.dart';
16 -import 'package:cake_wallet/src/domain/common/node.dart';
13 +import 'package:cake_wallet/entities/sync_status.dart';
14 +import 'package:cake_wallet/monero/account.dart';
15 +import 'package:cake_wallet/monero/subaddress.dart';
16 +import 'package:cake_wallet/entities/node.dart';
17 import 'package:cake_wallet/core/pending_transaction.dart';
18 -import 'package:cake_wallet/src/domain/common/transaction_priority.dart';
18 +import 'package:cake_wallet/entities/transaction_priority.dart';
19
20 part 'monero_wallet.g.dart';
21
@@ -186,6 +186,11 @@ abstract class MoneroWalletBase extends WalletBase<MoneroBalance> with Store {
186 await walletInfo.save();
187 }
188
189 + @override
190 + Future<void> rescan({int height}) async {
191 + // FIXME: Unimplemented
192 + }
193 +
194 void _setListeners() {
195 _listener?.stop();
196 _listener = monero_wallet.setListeners(
@@ -199,7 +204,6 @@ abstract class MoneroWalletBase extends WalletBase<MoneroBalance> with Store {
204 }
205
206 final currentHeight = getCurrentHeight();
202 - print('currentHeight $currentHeight');
207
208 if (currentHeight <= 1) {
209 final height = _getHeightByDate(walletInfo.date);
lib/monero/monero_wallet_service.dart
+3 -3
@@ -6,9 +6,9 @@ import 'package:cw_monero/wallet.dart' as monero_wallet;
6 import 'package:cake_wallet/monero/monero_wallet.dart';
7 import 'package:cake_wallet/core/wallet_credentials.dart';
8 import 'package:cake_wallet/core/wallet_service.dart';
9 -import 'package:cake_wallet/src/domain/common/pathForWallet.dart';
10 -import 'package:cake_wallet/src/domain/common/wallet_info.dart';
11 -import 'package:cake_wallet/src/domain/common/wallet_type.dart';
9 +import 'package:cake_wallet/entities/pathForWallet.dart';
10 +import 'package:cake_wallet/entities/wallet_info.dart';
11 +import 'package:cake_wallet/entities/wallet_type.dart';
12
13 class MoneroNewWalletCredentials extends WalletCredentials {
14 MoneroNewWalletCredentials({String name, String password, this.language})
lib/monero/subaddress.dart renamed
lib/reactions/bootstrap.dart
+18 -123
@@ -1,139 +1,34 @@
1 import 'dart:async';
2 import 'package:flutter/cupertino.dart';
3 import 'package:flutter/widgets.dart';
4 -import 'package:mobx/mobx.dart';
5 -import 'package:cake_wallet/di.dart';
4 import 'package:shared_preferences/shared_preferences.dart';
7 -import 'package:flutter_secure_storage/flutter_secure_storage.dart';
8 -import 'package:connectivity/connectivity.dart';
9 -import 'package:cake_wallet/core/key_service.dart';
10 -import 'package:cake_wallet/router.dart';
11 -import 'package:cake_wallet/src/domain/common/sync_status.dart';
12 -import 'package:cake_wallet/core/wallet_base.dart';
13 -import 'package:cake_wallet/core/wallet_service.dart';
5 +import 'package:cake_wallet/di.dart';
6 +import 'package:cake_wallet/entities/preferences_key.dart';
7 +import 'package:cake_wallet/reactions/on_authentication_state_change.dart';
8 +import 'package:cake_wallet/reactions/on_current_fiat_change.dart';
9 +import 'package:cake_wallet/reactions/on_current_wallet_change.dart';
10 import 'package:cake_wallet/store/app_store.dart';
11 import 'package:cake_wallet/store/settings_store.dart';
12 import 'package:cake_wallet/store/authentication_store.dart';
17 -import 'package:cake_wallet/src/domain/common/wallet_type.dart';
18 -import 'package:cake_wallet/src/domain/services/fiat_convertation_service.dart';
19 -import 'package:cake_wallet/src/domain/common/fiat_currency.dart';
20 -import 'package:cake_wallet/store/dashboard/fiat_convertation_store.dart';
13 +import 'package:cake_wallet/store/dashboard/fiat_conversion_store.dart';
14
22 -// FIXME: move me
23 -Future<void> loadCurrentWallet() async {
15 +Future<void> bootstrap(GlobalKey<NavigatorState> navigatorKey) async {
16 final appStore = getIt.get<AppStore>();
25 - final name = getIt.get<SharedPreferences>().getString('current_wallet_name');
26 - final typeRaw =
27 - getIt.get<SharedPreferences>().getInt('current_wallet_type') ?? 0;
28 - final type = deserializeFromInt(typeRaw);
29 - final password =
30 - await getIt.get<KeyService>().getWalletPassword(walletName: name);
31 - final _service = getIt.get<WalletService>(param1: type);
32 - final wallet = await _service.openWallet(name, password);
33 - appStore.wallet = wallet;
34 -}
35 -
36 -ReactionDisposer _initialAuthReaction;
37 -ReactionDisposer _onCurrentWalletChangeReaction;
38 -ReactionDisposer _onWalletSyncStatusChangeReaction;
39 -ReactionDisposer _onCurrentFiatCurrencyChangeDisposer;
40 -Timer _reconnectionTimer;
41 -
42 -Future<void> bootstrap(
43 - {FiatConvertationService fiatConvertationService,
44 - GlobalKey<NavigatorState> navigatorKey}) async {
17 final authenticationStore = getIt.get<AuthenticationStore>();
18 final settingsStore = getIt.get<SettingsStore>();
47 - final fiatConvertationStore = getIt.get<FiatConvertationStore>();
19 + final fiatConversionStore = getIt.get<FiatConversionStore>();
20
21 if (authenticationStore.state == AuthenticationState.uninitialized) {
50 - authenticationStore.state =
51 - getIt.get<SharedPreferences>().getString('current_wallet_name') == null
52 - ? AuthenticationState.denied
53 - : AuthenticationState.installed;
22 + authenticationStore.state = getIt
23 + .get<SharedPreferences>()
24 + .getString(PreferencesKey.currentWalletName) ==
25 + null
26 + ? AuthenticationState.denied
27 + : AuthenticationState.installed;
28 }
29
56 - _initialAuthReaction ??= autorun((_) async {
57 - final state = authenticationStore.state;
58 - print(state);
59 -
60 - if (state == AuthenticationState.installed) {
61 - await loadCurrentWallet();
62 - await navigatorKey.currentState
63 - .pushAndRemoveUntil(createLoginRoute(), (_) => false);
64 - }
65 -
66 - if (state == AuthenticationState.allowed) {
67 - await navigatorKey.currentState
68 - .pushAndRemoveUntil(createDashboardRoute(), (_) => false);
69 - }
70 -
71 - if (state == AuthenticationState.denied) {
72 - await navigatorKey.currentState
73 - .pushAndRemoveUntil(createWelcomeRoute(), (_) => false);
74 - }
75 - });
76 -
77 - _onCurrentWalletChangeReaction ??=
78 - reaction((_) => getIt.get<AppStore>().wallet, (WalletBase wallet) async {
79 - _onWalletSyncStatusChangeReaction?.reaction?.dispose();
80 - _reconnectionTimer?.cancel();
81 - _onWalletSyncStatusChangeReaction =
82 - reaction((_) => wallet.syncStatus, (SyncStatus status) async {
83 - if (status is ConnectedSyncStatus) {
84 - await wallet.startSync();
85 - }
86 - });
87 -
88 - _reconnectionTimer = Timer.periodic(Duration(seconds: 5), (_) async {
89 - final connectivityResult = await (Connectivity().checkConnectivity());
90 -
91 - if (connectivityResult == ConnectivityResult.none) {
92 - wallet.syncStatus = FailedSyncStatus();
93 - return;
94 - }
95 -
96 - if (wallet.syncStatus is LostConnectionSyncStatus ||
97 - wallet.syncStatus is FailedSyncStatus) {
98 - try {
99 - final alive =
100 - await settingsStore.getCurrentNode(wallet.type).requestNode();
101 -
102 - if (alive) {
103 - await wallet.connectToNode(
104 - node: settingsStore.getCurrentNode(wallet.type));
105 - }
106 - } catch (_) {}
107 - }
108 - });
109 -
110 - await getIt
111 - .get<SharedPreferences>()
112 - .setString('current_wallet_name', wallet.name);
113 -
114 - await getIt
115 - .get<SharedPreferences>()
116 - .setInt('current_wallet_type', serializeToInt(wallet.type));
117 -
118 - final node = settingsStore.getCurrentNode(wallet.type);
119 - final cryptoCurrency = wallet.currency;
120 - final fiatCurrency = settingsStore.fiatCurrency;
121 -
122 - await wallet.connectToNode(node: node);
123 -
124 - final price = await fiatConvertationService.getPrice(
125 - crypto: cryptoCurrency, fiat: fiatCurrency);
126 -
127 - fiatConvertationStore.setPrice(price);
128 - });
129 -
130 - _onCurrentFiatCurrencyChangeDisposer ??= reaction(
131 - (_) => settingsStore.fiatCurrency, (FiatCurrency fiatCurrency) async {
132 - final cryptoCurrency = getIt.get<AppStore>().wallet.currency;
133 -
134 - final price = await fiatConvertationService.getPrice(
135 - crypto: cryptoCurrency, fiat: fiatCurrency);
136 -
137 - fiatConvertationStore.setPrice(price);
138 - });
30 + startAuthenticationStateChange(authenticationStore, navigatorKey);
31 + startCurrentWalletChangeReaction(
32 + appStore, settingsStore, fiatConversionStore);
33 + startCurrentFiatChangeReaction(appStore, settingsStore);
34 }
lib/reactions/check_connection.dart new
+35
@@ -0,0 +1,35 @@
1 +import 'dart:async';
2 +
3 +import 'package:cake_wallet/core/wallet_base.dart';
4 +import 'package:cake_wallet/entities/sync_status.dart';
5 +import 'package:cake_wallet/store/settings_store.dart';
6 +import 'package:connectivity/connectivity.dart';
7 +
8 +Timer _checkConnectionTimer;
9 +
10 +void startCheckConnectionReaction(WalletBase wallet, SettingsStore settingsStore, {int timeInterval = 5}) {
11 + _checkConnectionTimer?.cancel();
12 + _checkConnectionTimer = Timer.periodic(Duration(seconds: timeInterval), (_) async {
13 + final connectivityResult = await (Connectivity().checkConnectivity());
14 +
15 + if (connectivityResult == ConnectivityResult.none) {
16 + wallet.syncStatus = FailedSyncStatus();
17 + return;
18 + }
19 +
20 + if (wallet.syncStatus is LostConnectionSyncStatus ||
21 + wallet.syncStatus is FailedSyncStatus) {
22 + try {
23 + final alive =
24 + await settingsStore.getCurrentNode(wallet.type).requestNode();
25 +
26 + if (alive) {
27 + await wallet.connectToNode(
28 + node: settingsStore.getCurrentNode(wallet.type));
29 + }
30 + } catch (_) {
31 + // FIXME: empty catch clojure
32 + }
33 + }
34 + });
35 +}
lib/reactions/fiat_rate_update.dart new
+23
@@ -0,0 +1,23 @@
1 +import 'dart:async';
2 +import 'package:cake_wallet/core/fiat_conversion_service.dart';
3 +import 'package:cake_wallet/store/app_store.dart';
4 +import 'package:cake_wallet/store/dashboard/fiat_conversion_store.dart';
5 +import 'package:cake_wallet/store/settings_store.dart';
6 +
7 +Timer _timer;
8 +
9 +Future<void> startFiatRateUpdate(AppStore appStore, SettingsStore settingsStore,
10 + FiatConversionStore fiatConversionStore) async {
11 + if (_timer != null) {
12 + return;
13 + }
14 +
15 + fiatConversionStore.price = await FiatConversionService.fetchPrice(
16 + appStore.wallet.currency, settingsStore.fiatCurrency);
17 +
18 + _timer = Timer.periodic(
19 + Duration(seconds: 30),
20 + (_) async => fiatConversionStore.price =
21 + await FiatConversionService.fetchPrice(
22 + appStore.wallet.currency, settingsStore.fiatCurrency));
23 +}
lib/reactions/on_authentication_state_change.dart new
+31
@@ -0,0 +1,31 @@
1 +import 'package:cake_wallet/routes.dart';
2 +import 'package:flutter/widgets.dart';
3 +import 'package:mobx/mobx.dart';
4 +import 'package:cake_wallet/router.dart';
5 +import 'package:cake_wallet/entities/load_current_wallet.dart';
6 +import 'package:cake_wallet/store/authentication_store.dart';
7 +
8 +ReactionDisposer _onAuthenticationStateChange;
9 +
10 +void startAuthenticationStateChange(AuthenticationStore authenticationStore,
11 + GlobalKey<NavigatorState> navigatorKey) {
12 + _onAuthenticationStateChange ??= autorun((_) async {
13 + final state = authenticationStore.state;
14 +
15 + if (state == AuthenticationState.installed) {
16 + await loadCurrentWallet();
17 + // await navigatorKey.currentState
18 + // .pushNamedAndRemoveUntil(Routes.login, (_) => false);
19 + }
20 +
21 + if (state == AuthenticationState.allowed) {
22 + await navigatorKey.currentState
23 + .pushNamedAndRemoveUntil(Routes.dashboard, (route) => false);
24 + }
25 +
26 + if (state == AuthenticationState.denied) {
27 + await navigatorKey.currentState
28 + .pushNamedAndRemoveUntil(Routes.welcome, (_) => false);
29 + }
30 + });
31 +}
lib/reactions/on_current_fiat_change.dart new
+18
@@ -0,0 +1,18 @@
1 +import 'package:mobx/mobx.dart';
2 +import 'package:cake_wallet/store/settings_store.dart';
3 +import 'package:cake_wallet/store/app_store.dart';
4 +import 'package:cake_wallet/entities/fiat_currency.dart';
5 +
6 +ReactionDisposer _onCurrentFiatCurrencyChangeDisposer;
7 +
8 +void startCurrentFiatChangeReaction(AppStore appStore, SettingsStore settingsStore) {
9 + _onCurrentFiatCurrencyChangeDisposer?.reaction?.dispose();
10 + _onCurrentFiatCurrencyChangeDisposer = reaction(
11 + (_) => settingsStore.fiatCurrency, (FiatCurrency fiatCurrency) async {
12 + final cryptoCurrency = appStore.wallet.currency;
13 + // final price = await fiatConvertationService.getPrice(
14 + // crypto: cryptoCurrency, fiat: fiatCurrency);
15 + //
16 + // fiatConvertationStore.setPrice(price);
17 + });
18 +}
\ No newline at end of file
lib/reactions/on_current_wallet_change.dart new
+39
@@ -0,0 +1,39 @@
1 +import 'package:mobx/mobx.dart';
2 +import 'package:shared_preferences/shared_preferences.dart';
3 +import 'package:cake_wallet/di.dart';
4 +import 'package:cake_wallet/entities/preferences_key.dart';
5 +import 'package:cake_wallet/reactions/check_connection.dart';
6 +import 'package:cake_wallet/reactions/on_wallet_sync_status_change.dart';
7 +import 'package:cake_wallet/store/dashboard/fiat_conversion_store.dart';
8 +import 'package:cake_wallet/store/app_store.dart';
9 +import 'package:cake_wallet/store/settings_store.dart';
10 +import 'package:cake_wallet/core/fiat_conversion_service.dart';
11 +import 'package:cake_wallet/core/wallet_base.dart';
12 +import 'package:cake_wallet/entities/wallet_type.dart';
13 +
14 +ReactionDisposer _onCurrentWalletChangeReaction;
15 +
16 +void startCurrentWalletChangeReaction(AppStore appStore,
17 + SettingsStore settingsStore, FiatConversionStore fiatConversionStore) {
18 + _onCurrentWalletChangeReaction?.reaction?.dispose();
19 +
20 + _onCurrentWalletChangeReaction =
21 + reaction((_) => appStore.wallet, (WalletBase wallet) async {
22 + try {
23 + final node = settingsStore.getCurrentNode(wallet.type);
24 + startWalletSyncStatusChangeReaction(wallet);
25 + startCheckConnectionReaction(wallet, settingsStore);
26 + await getIt
27 + .get<SharedPreferences>()
28 + .setString(PreferencesKey.currentWalletName, wallet.name);
29 + await getIt.get<SharedPreferences>().setInt(
30 + PreferencesKey.currentWalletType, serializeToInt(wallet.type));
31 + await wallet.connectToNode(node: node);
32 +
33 + fiatConversionStore.price = await FiatConversionService.fetchPrice(
34 + wallet.currency, settingsStore.fiatCurrency);
35 + } catch (e) {
36 + print(e.toString());
37 + }
38 + });
39 +}
lib/reactions/on_wallet_sync_status_change.dart new
+15
@@ -0,0 +1,15 @@
1 +import 'package:mobx/mobx.dart';
2 +import 'package:cake_wallet/core/wallet_base.dart';
3 +import 'package:cake_wallet/entities/sync_status.dart';
4 +
5 +ReactionDisposer _onWalletSyncStatusChangeReaction;
6 +
7 +void startWalletSyncStatusChangeReaction(WalletBase wallet) {
8 + _onWalletSyncStatusChangeReaction?.reaction?.dispose();
9 + _onWalletSyncStatusChangeReaction =
10 + reaction((_) => wallet.syncStatus, (SyncStatus status) async {
11 + if (status is ConnectedSyncStatus) {
12 + await wallet.startSync();
13 + }
14 + });
15 +}
\ No newline at end of file
lib/router.dart
+38 -158
@@ -1,62 +1,18 @@
1 -import 'package:cake_wallet/src/screens/dashboard/dashboard_page.dart';
2 -import 'package:cake_wallet/src/screens/seed/wallet_seed_page.dart';
3 -import 'package:cake_wallet/view_model/wallet_new_vm.dart';
4 -import 'package:cake_wallet/view_model/wallet_restoration_from_seed_vm.dart';
5 -import 'package:cake_wallet/view_model/wallet_restoration_from_keys_vm.dart';
1 import 'package:flutter/cupertino.dart';
2 import 'package:flutter/material.dart';
8 -import 'package:flutter_secure_storage/flutter_secure_storage.dart';
9 -import 'package:shared_preferences/shared_preferences.dart';
10 -import 'package:provider/provider.dart';
11 -import 'package:hive/hive.dart';
3 import 'package:cake_wallet/routes.dart';
4 import 'package:cake_wallet/generated/i18n.dart';
14 -import 'di.dart';
15 -// MARK: Import domains
16 -
17 -import 'package:cake_wallet/src/domain/common/contact.dart';
18 -import 'package:cake_wallet/src/domain/services/user_service.dart';
19 -import 'package:cake_wallet/src/domain/services/wallet_list_service.dart';
20 -import 'package:cake_wallet/src/domain/services/wallet_service.dart';
21 -import 'package:cake_wallet/src/domain/common/crypto_currency.dart';
22 -import 'package:cake_wallet/src/domain/exchange/changenow/changenow_exchange_provider.dart';
23 -import 'package:cake_wallet/src/domain/exchange/xmrto/xmrto_exchange_provider.dart';
24 -import 'package:cake_wallet/src/domain/exchange/morphtoken/morphtoken_exchange_provider.dart';
25 -import 'package:cake_wallet/src/domain/common/node.dart';
26 -import 'package:cake_wallet/src/domain/monero/transaction_description.dart';
27 -import 'package:cake_wallet/src/domain/exchange/trade.dart';
28 -import 'package:cake_wallet/src/domain/monero/account.dart';
29 -import 'package:cake_wallet/src/domain/common/mnemonic_item.dart';
30 -import 'package:cake_wallet/src/domain/common/transaction_info.dart';
31 -import 'package:cake_wallet/src/domain/monero/subaddress.dart';
32 -import 'package:cake_wallet/src/domain/common/wallet_type.dart';
33 -
34 -// MARK: Import stores
35 -
36 -import 'package:cake_wallet/src/stores/authentication/authentication_store.dart';
37 -import 'package:cake_wallet/src/stores/node_list/node_list_store.dart';
38 -import 'package:cake_wallet/src/stores/auth/auth_store.dart';
39 -import 'package:cake_wallet/src/stores/balance/balance_store.dart';
40 -import 'package:cake_wallet/src/stores/send/send_store.dart';
41 -import 'package:cake_wallet/src/stores/subaddress_creation/subaddress_creation_store.dart';
42 -import 'package:cake_wallet/src/stores/subaddress_list/subaddress_list_store.dart';
43 -import 'package:cake_wallet/src/stores/sync/sync_store.dart';
44 -import 'package:cake_wallet/src/stores/user/user_store.dart';
45 -import 'package:cake_wallet/src/stores/wallet/wallet_store.dart';
46 -import 'package:cake_wallet/src/stores/wallet_creation/wallet_creation_store.dart';
47 -import 'package:cake_wallet/src/stores/wallet_list/wallet_list_store.dart';
48 -import 'package:cake_wallet/src/stores/wallet_restoration/wallet_restoration_store.dart';
49 -import 'package:cake_wallet/src/stores/account_list/account_list_store.dart';
50 -import 'package:cake_wallet/src/stores/address_book/address_book_store.dart';
51 -import 'package:cake_wallet/src/stores/settings/settings_store.dart';
52 -import 'package:cake_wallet/src/stores/wallet/wallet_keys_store.dart';
53 -import 'package:cake_wallet/src/stores/exchange_trade/exchange_trade_store.dart';
54 -import 'package:cake_wallet/src/stores/exchange/exchange_store.dart';
55 -import 'package:cake_wallet/src/stores/rescan/rescan_wallet_store.dart';
56 -import 'package:cake_wallet/src/stores/price/price_store.dart';
57 -
58 -// MARK: Import screens
59 -
5 +import 'package:cake_wallet/di.dart';
6 +import 'package:cake_wallet/utils/language_list.dart';
7 +import 'package:cake_wallet/view_model/wallet_new_vm.dart';
8 +import 'package:cake_wallet/view_model/wallet_restoration_from_seed_vm.dart';
9 +import 'package:cake_wallet/view_model/wallet_restoration_from_keys_vm.dart';
10 +import 'package:cake_wallet/entities/contact.dart';
11 +import 'package:cake_wallet/exchange/trade.dart';
12 +import 'package:cake_wallet/entities/transaction_info.dart';
13 +import 'package:cake_wallet/entities/wallet_type.dart';
14 +import 'package:cake_wallet/src/screens/dashboard/dashboard_page.dart';
15 +import 'package:cake_wallet/src/screens/seed/wallet_seed_page.dart';
16 import 'package:cake_wallet/src/screens/auth/auth_page.dart';
17 import 'package:cake_wallet/src/screens/nodes/node_create_or_edit_page.dart';
18 import 'package:cake_wallet/src/screens/nodes/nodes_list_page.dart';
@@ -77,9 +33,6 @@ import 'package:cake_wallet/src/screens/monero_accounts/monero_account_edit_or_c
33 import 'package:cake_wallet/src/screens/contact/contact_list_page.dart';
34 import 'package:cake_wallet/src/screens/contact/contact_page.dart';
35 import 'package:cake_wallet/src/screens/wallet_keys/wallet_keys_page.dart';
80 -import 'package:cake_wallet/src/screens/exchange_trade/exchange_confirm_page.dart';
81 -import 'package:cake_wallet/src/screens/exchange_trade/exchange_trade_page.dart';
82 -import 'package:cake_wallet/src/screens/subaddress/subaddress_list_page.dart';
36 import 'package:cake_wallet/src/screens/settings/change_language.dart';
37 import 'package:cake_wallet/src/screens/restore/restore_wallet_from_seed_details.dart';
38 import 'package:cake_wallet/src/screens/exchange/exchange_page.dart';
@@ -87,63 +40,31 @@ import 'package:cake_wallet/src/screens/settings/settings.dart';
40 import 'package:cake_wallet/src/screens/rescan/rescan_page.dart';
41 import 'package:cake_wallet/src/screens/faq/faq_page.dart';
42 import 'package:cake_wallet/src/screens/trade_details/trade_details_page.dart';
90 -import 'package:cake_wallet/src/screens/auth/create_unlock_page.dart';
91 -import 'package:cake_wallet/src/screens/auth/create_login_page.dart';
92 -import 'package:cake_wallet/src/screens/dashboard/create_dashboard_page.dart';
43 import 'package:cake_wallet/src/screens/welcome/create_welcome_page.dart';
44 import 'package:cake_wallet/src/screens/new_wallet/new_wallet_type_page.dart';
45 import 'package:cake_wallet/src/screens/send/send_template_page.dart';
46 import 'package:cake_wallet/src/screens/exchange/exchange_template_page.dart';
97 -
98 -CupertinoPageRoute<void> createDashboardRoute() =>
99 - CupertinoPageRoute<void>(builder: (_) => getIt.get<DashboardPage>());
100 -
101 -CupertinoPageRoute<void> createLoginRoute() => CupertinoPageRoute<void>(
102 - builder: (context) => getIt.get<AuthPage>(instanceName: 'login'));
103 -
104 -MaterialPageRoute<void> createWelcomeRoute() =>
105 - MaterialPageRoute<void>(builder: (_) => createWelcomePage());
47 +import 'package:cake_wallet/src/screens/exchange_trade/exchange_confirm_page.dart';
48 +import 'package:cake_wallet/src/screens/exchange_trade/exchange_trade_page.dart';
49
50 class Router {
108 - static Route<dynamic> generateRoute(
109 - {SharedPreferences sharedPreferences,
110 - WalletListService walletListService,
111 - WalletService walletService,
112 - UserService userService,
113 - RouteSettings settings,
114 - PriceStore priceStore,
115 - WalletStore walletStore,
116 - SyncStore syncStore,
117 - BalanceStore balanceStore,
118 - SettingsStore settingsStore,
119 - Box<Contact> contacts,
120 - Box<Node> nodes,
121 - Box<TransactionDescription> transactionDescriptions,
122 - Box<Trade> trades}) {
51 + static Route<dynamic> generateRoute(RouteSettings settings) {
52 switch (settings.name) {
53 case Routes.welcome:
54 return MaterialPageRoute<void>(builder: (_) => createWelcomePage());
55
56 case Routes.newWalletFromWelcome:
128 - final type = settings.arguments as WalletType;
129 - walletListService.changeWalletManger(walletType: type);
130 -
57 return CupertinoPageRoute<void>(
132 - builder: (_) => Provider(
133 - create: (_) => UserStore(
134 - accountService: UserService(
135 - secureStorage: FlutterSecureStorage(),
136 - sharedPreferences: sharedPreferences)),
137 - child: SetupPinCodePage(
138 - onPinCodeSetup: (context, _) =>
139 - Navigator.pushNamed(context, Routes.newWalletType))));
58 + builder: (_) => getIt.get<SetupPinCodePage>(
59 + param1: (BuildContext context, dynamic _) =>
60 + Navigator.pushNamed(context, Routes.newWalletType)),
61 + fullscreenDialog: true);
62
63 case Routes.newWalletType:
64 return CupertinoPageRoute<void>(
65 builder: (_) => NewWalletTypePage(
144 - onTypeSelected: (context, type) => Navigator.of(context)
145 - .pushNamed(Routes.newWallet, arguments: type),
146 - ));
66 + onTypeSelected: (context, type) => Navigator.of(context)
67 + .pushNamed(Routes.newWallet, arguments: type)));
68
69 case Routes.newWallet:
70 final type = settings.arguments as WalletType;
@@ -160,15 +81,7 @@ class Router {
81 }
82
83 return CupertinoPageRoute<void>(
163 - builder: (_) => Provider(
164 - create: (_) => UserStore(
165 - accountService: UserService(
166 - secureStorage: FlutterSecureStorage(),
167 - sharedPreferences: sharedPreferences)),
168 - child: SetupPinCodePage(
169 - onPinCodeSetup: (context, pin) =>
170 - callback == null ? null : callback(context, pin))),
171 - fullscreenDialog: true);
84 + builder: (_) => getIt.get<SetupPinCodePage>(param1: callback));
85
86 case Routes.restoreWalletType:
87 return CupertinoPageRoute<void>(
@@ -180,14 +93,11 @@ class Router {
93
94 case Routes.restoreOptions:
95 final type = settings.arguments as WalletType;
183 - walletListService.changeWalletManger(walletType: type);
184 -
96 return CupertinoPageRoute<void>(
97 builder: (_) => RestoreOptionsPage(type: type));
98
99 case Routes.restoreWalletOptions:
100 final type = settings.arguments as WalletType;
190 - walletListService.changeWalletManger(walletType: type);
101
102 return CupertinoPageRoute<void>(
103 builder: (_) => RestoreWalletOptionsPage(
@@ -215,26 +125,22 @@ class Router {
125
126 case Routes.restoreWalletOptionsFromWelcome:
127 return CupertinoPageRoute<void>(
218 - builder: (_) => Provider(
219 - create: (_) => UserStore(
220 - accountService: UserService(
221 - secureStorage: FlutterSecureStorage(),
222 - sharedPreferences: sharedPreferences)),
223 - child: SetupPinCodePage(
224 - onPinCodeSetup: (context, _) => Navigator.pushNamed(
225 - context, Routes.restoreWalletType))));
128 + builder: (_) => getIt.get<SetupPinCodePage>(
129 + param1: (BuildContext context, dynamic _) =>
130 + Navigator.pushNamed(context, Routes.restoreWalletType)),
131 + fullscreenDialog: true);
132
133 case Routes.seed:
134 return MaterialPageRoute<void>(
229 - builder: (_) => getIt.get<WalletSeedPage>(
230 - param1: settings.arguments as bool));
135 + builder: (_) =>
136 + getIt.get<WalletSeedPage>(param1: settings.arguments as bool));
137
138 case Routes.restoreWalletFromSeed:
139 final args = settings.arguments as List<dynamic>;
140 final type = args.first as WalletType;
141 final language = type == WalletType.monero
142 ? args[1] as String
237 - : 'English'; // FIXME: Unnamed constant; English default and only one language for bitcoin.
143 + : LanguageList.english;
144
145 return CupertinoPageRoute<void>(
146 builder: (_) =>
@@ -245,7 +151,7 @@ class Router {
151 final type = args.first as WalletType;
152 final language = type == WalletType.monero
153 ? args[1] as String
248 - : 'English'; // FIXME: Unnamed constant; English default and only one language for bitcoin.
154 + : LanguageList.english;
155
156 final walletRestorationFromKeysVM =
157 getIt.get<WalletRestorationFromKeysVM>(param1: [type, language]);
@@ -274,8 +180,8 @@ class Router {
180 case Routes.transactionDetails:
181 return CupertinoPageRoute<void>(
182 fullscreenDialog: true,
277 - builder: (_) => TransactionDetailsPage(
278 - transactionInfo: settings.arguments as TransactionInfo));
183 + builder: (_) =>
184 + TransactionDetailsPage(settings.arguments as TransactionInfo));
185
186 case Routes.newSubaddress:
187 return CupertinoPageRoute<void>(
@@ -314,12 +220,8 @@ class Router {
220 case Routes.unlock:
221 return MaterialPageRoute<void>(
222 fullscreenDialog: true,
317 - builder: (_) => createUnlockPage(
318 - sharedPreferences: sharedPreferences,
319 - userService: userService,
320 - walletService: walletService,
321 - onAuthenticationFinished:
322 - settings.arguments as OnAuthenticationFinished));
223 + builder: (_) => getIt.get<AuthPage>(
224 + param1: settings.arguments as OnAuthenticationFinished));
225
226 case Routes.nodeList:
227 return CupertinoPageRoute<void>(
@@ -363,27 +265,9 @@ class Router {
265 return MaterialPageRoute<void>(
266 builder: (_) => getIt.get<ExchangeConfirmPage>());
267
366 - //ExchangeConfirmPage(trade: settings.arguments as Trade));
367 -
268 case Routes.tradeDetails:
369 - return MaterialPageRoute<void>(builder: (context) {
370 - return MultiProvider(providers: [
371 - ProxyProvider<SettingsStore, ExchangeTradeStore>(
372 - update: (_, settingsStore, __) => ExchangeTradeStore(
373 - trade: settings.arguments as Trade,
374 - walletStore: walletStore,
375 - trades: trades),
376 - )
377 - ], child: TradeDetailsPage());
378 - });
379 -
380 - case Routes.subaddressList:
381 - return MaterialPageRoute<Subaddress>(
382 - builder: (_) => MultiProvider(providers: [
383 - Provider(
384 - create: (_) =>
385 - SubaddressListStore(walletService: walletService))
386 - ], child: SubaddressListPage()));
269 + return MaterialPageRoute<void>(
270 + builder: (_) => TradeDetailsPage(settings.arguments as Trade));
271
272 case Routes.restoreWalletFromSeedDetails:
273 final args = settings.arguments as List;
@@ -407,10 +291,7 @@ class Router {
291 builder: (_) => getIt.get<SettingsPage>());
292
293 case Routes.rescan:
410 - return MaterialPageRoute<void>(
411 - builder: (_) => Provider(
412 - create: (_) => RescanWalletStore(walletService: walletService),
413 - child: RescanPage()));
294 + return MaterialPageRoute<void>(builder: (_) => getIt.get<RescanPage>());
295
296 case Routes.faq:
297 return MaterialPageRoute<void>(builder: (_) => FaqPage());
@@ -421,9 +302,8 @@ class Router {
302 default:
303 return MaterialPageRoute<void>(
304 builder: (_) => Scaffold(
424 - body: Center(
425 - child: Text(S.current.router_no_route(settings.name))),
426 - ));
305 + body: Center(
306 + child: Text(S.current.router_no_route(settings.name)))));
307 }
308 }
309 }
lib/routes.dart
-1
@@ -35,7 +35,6 @@ class Routes {
35 static const tradeDetails = '/trade_details';
36 static const exchangeFunds = '/exchange_funds';
37 static const exchangeTrade = '/exchange_trade';
38 - static const subaddressList = '/subaddress_list';
38 static const restoreWalletFromSeedDetails = '/restore_from_seed_details';
39 static const exchange = '/exchange';
40 static const settings = '/settings';
lib/src/domain/bitcoin/bitcoin_amount_format.dart deleted
-9
@@ -1,9 +0,0 @@
1 -import 'package:cake_wallet/src/domain/common/crypto_amount_format.dart';
2 -
3 -const bitcoinAmountDivider = 100000000;
4 -
5 -double bitcoinAmountToDouble({int amount}) =>
6 - cryptoAmountToDouble(amount: amount, divider: bitcoinAmountDivider);
7 -
8 -int doubleToBitcoinAmount(double amount) =>
9 - (amount * bitcoinAmountDivider).toInt();
lib/src/domain/bitcoin_cash/bitcoin_cash_amount_format.dart deleted
-6
@@ -1,6 +0,0 @@
1 -import 'package:cake_wallet/src/domain/common/crypto_amount_format.dart';
2 -
3 -const bitcoinCashAmountDivider = 100000000;
4 -
5 -double bitcoinCashAmountToDouble({int amount}) =>
6 - cryptoAmountToDouble(amount: amount, divider: bitcoinCashAmountDivider);
\ No newline at end of file
lib/src/domain/dash/dash_amount_format.dart deleted
-6
@@ -1,6 +0,0 @@
1 -import 'package:cake_wallet/src/domain/common/crypto_amount_format.dart';
2 -
3 -const dashAmountDivider = 100000000;
4 -
5 -double dashAmountToDouble({int amount}) =>
6 - cryptoAmountToDouble(amount: amount, divider: dashAmountDivider);
\ No newline at end of file
lib/src/domain/ethereum/ethereum_amount_format.dart deleted
-6
@@ -1,6 +0,0 @@
1 -import 'package:cake_wallet/src/domain/common/crypto_amount_format.dart';
2 -
3 -const ethereumAmountDivider = 1000000000000000000;
4 -
5 -double ethereumAmountToDouble({num amount}) =>
6 - cryptoAmountToDouble(amount: amount, divider: ethereumAmountDivider);
\ No newline at end of file
lib/src/domain/exchange/morphtoken/morphtoken_exchange_provider.dart deleted
-241
@@ -1,241 +0,0 @@
1 -import 'dart:convert';
2 -import 'package:hive/hive.dart';
3 -import 'package:cake_wallet/src/domain/exchange/trade_not_found_exeption.dart';
4 -import 'package:flutter/foundation.dart';
5 -import 'package:http/http.dart';
6 -import 'package:cake_wallet/src/domain/common/crypto_currency.dart';
7 -import 'package:cake_wallet/src/domain/exchange/exchange_pair.dart';
8 -import 'package:cake_wallet/src/domain/exchange/exchange_provider.dart';
9 -import 'package:cake_wallet/src/domain/exchange/limits.dart';
10 -import 'package:cake_wallet/src/domain/exchange/trade.dart';
11 -import 'package:cake_wallet/src/domain/exchange/trade_request.dart';
12 -import 'package:cake_wallet/src/domain/exchange/trade_state.dart';
13 -import 'package:cake_wallet/src/domain/exchange/morphtoken/morphtoken_request.dart';
14 -import 'package:cake_wallet/src/domain/exchange/exchange_provider_description.dart';
15 -import 'package:cake_wallet/src/domain/exchange/trade_not_created_exeption.dart';
16 -import 'package:cake_wallet/src/domain/monero/monero_amount_format.dart';
17 -import 'package:cake_wallet/src/domain/bitcoin/bitcoin_amount_format.dart';
18 -import 'package:cake_wallet/src/domain/bitcoin_cash/bitcoin_cash_amount_format.dart';
19 -import 'package:cake_wallet/src/domain/dash/dash_amount_format.dart';
20 -import 'package:cake_wallet/src/domain/ethereum/ethereum_amount_format.dart';
21 -import 'package:cake_wallet/src/domain/litecoin/litecoin_amount_format.dart';
22 -
23 -class MorphTokenExchangeProvider extends ExchangeProvider {
24 - MorphTokenExchangeProvider({@required this.trades})
25 - : super(
26 - pairList: [
27 - ExchangePair(from: CryptoCurrency.xmr, to: CryptoCurrency.eth),
28 - ExchangePair(from: CryptoCurrency.xmr, to: CryptoCurrency.bch),
29 - ExchangePair(from: CryptoCurrency.xmr, to: CryptoCurrency.ltc),
30 - ExchangePair(from: CryptoCurrency.xmr, to: CryptoCurrency.dash),
31 -
32 - ExchangePair(from: CryptoCurrency.dash, to: CryptoCurrency.btc),
33 - ExchangePair(from: CryptoCurrency.dash, to: CryptoCurrency.eth),
34 - ExchangePair(from: CryptoCurrency.dash, to: CryptoCurrency.bch),
35 - ExchangePair(from: CryptoCurrency.dash, to: CryptoCurrency.ltc),
36 - ExchangePair(from: CryptoCurrency.dash, to: CryptoCurrency.xmr),
37 -
38 - ExchangePair(from: CryptoCurrency.ltc, to: CryptoCurrency.btc),
39 - ExchangePair(from: CryptoCurrency.ltc, to: CryptoCurrency.eth),
40 - ExchangePair(from: CryptoCurrency.ltc, to: CryptoCurrency.bch),
41 - ExchangePair(from: CryptoCurrency.ltc, to: CryptoCurrency.dash),
42 - ExchangePair(from: CryptoCurrency.ltc, to: CryptoCurrency.xmr),
43 -
44 - ExchangePair(from: CryptoCurrency.bch, to: CryptoCurrency.btc),
45 - ExchangePair(from: CryptoCurrency.bch, to: CryptoCurrency.eth),
46 - ExchangePair(from: CryptoCurrency.bch, to: CryptoCurrency.ltc),
47 - ExchangePair(from: CryptoCurrency.bch, to: CryptoCurrency.dash),
48 - ExchangePair(from: CryptoCurrency.bch, to: CryptoCurrency.xmr),
49 -
50 - ExchangePair(from: CryptoCurrency.eth, to: CryptoCurrency.btc),
51 - ExchangePair(from: CryptoCurrency.eth, to: CryptoCurrency.bch),
52 - ExchangePair(from: CryptoCurrency.eth, to: CryptoCurrency.ltc),
53 - ExchangePair(from: CryptoCurrency.eth, to: CryptoCurrency.dash),
54 - ExchangePair(from: CryptoCurrency.eth, to: CryptoCurrency.xmr),
55 -
56 - ExchangePair(from: CryptoCurrency.btc, to: CryptoCurrency.eth),
57 - ExchangePair(from: CryptoCurrency.btc, to: CryptoCurrency.bch),
58 - ExchangePair(from: CryptoCurrency.btc, to: CryptoCurrency.ltc),
59 - ExchangePair(from: CryptoCurrency.btc, to: CryptoCurrency.dash),
60 - ExchangePair(from: CryptoCurrency.btc, to: CryptoCurrency.xmr)
61 - ]);
62 -
63 - Box<Trade> trades;
64 -
65 - static const apiUri = 'https://api.morphtoken.com';
66 - static const _morphURISuffix = '/morph';
67 - static const _limitsURISuffix = '/limits';
68 - static const _ratesURISuffix = '/rates';
69 - static const weight = 10000;
70 -
71 - @override
72 - String get title => 'MorphToken';
73 -
74 - @override
75 - ExchangeProviderDescription get description =>
76 - ExchangeProviderDescription.morphToken;
77 -
78 - @override
79 - Future<Limits> fetchLimits({CryptoCurrency from, CryptoCurrency to}) async {
80 - final url = apiUri + _limitsURISuffix;
81 - final headers = {'Content-type': 'application/json'};
82 - final body =
83 - json.encode({
84 - "input": {
85 - "asset": from.toString()
86 - },
87 - "output": [{
88 - "asset": to.toString(),
89 - "weight": weight
90 - }]});
91 - final response =
92 - await post(url, headers: headers, body: body);
93 - final responseJSON = json.decode(response.body) as Map<String, dynamic>;
94 -
95 - final min = responseJSON['input']['limits']['min'] as int;
96 - int max;
97 - double ethMax;
98 -
99 - if (from == CryptoCurrency.eth) {
100 - ethMax = responseJSON['input']['limits']['max'] as double;
101 - } else {
102 - max = responseJSON['input']['limits']['max'] as int;
103 - }
104 -
105 - double minFormatted;
106 - double maxFormatted;
107 -
108 - switch (from) {
109 - case CryptoCurrency.xmr:
110 - minFormatted = moneroAmountToDouble(amount: min);
111 - maxFormatted = moneroAmountToDouble(amount: max);
112 - break;
113 - case CryptoCurrency.btc:
114 - minFormatted = bitcoinAmountToDouble(amount: min);
115 - maxFormatted = bitcoinAmountToDouble(amount: max);
116 - break;
117 - case CryptoCurrency.bch:
118 - minFormatted = bitcoinCashAmountToDouble(amount: min);
119 - maxFormatted = bitcoinCashAmountToDouble(amount: max);
120 - break;
121 - case CryptoCurrency.dash:
122 - minFormatted = dashAmountToDouble(amount: min);
123 - maxFormatted = dashAmountToDouble(amount: max);
124 - break;
125 - case CryptoCurrency.eth:
126 - minFormatted = ethereumAmountToDouble(amount: min);
127 - maxFormatted = ethereumAmountToDouble(amount: ethMax);
128 - break;
129 - case CryptoCurrency.ltc:
130 - minFormatted = litecoinAmountToDouble(amount: min);
131 - maxFormatted = litecoinAmountToDouble(amount: max);
132 - break;
133 - }
134 -
135 - return Limits(min: minFormatted, max: maxFormatted);
136 - }
137 -
138 - @override
139 - Future<Trade> createTrade({TradeRequest request}) async {
140 - const url = apiUri + _morphURISuffix;
141 - final _request = request as MorphTokenRequest;
142 - final body = {
143 - "input": {
144 - "asset": _request.from.toString(),
145 - "refund": _request.refundAddress
146 - },
147 - "output": [{
148 - "asset": _request.to.toString(),
149 - "weight": weight,
150 - "address": _request.address
151 - }],
152 - "tag": "cakewallet"
153 - };
154 -
155 - final response = await post(url,
156 - headers: {'Content-Type': 'application/json'}, body: json.encode(body));
157 -
158 - if (response.statusCode != 200) {
159 - if (response.statusCode == 400) {
160 - final responseJSON = json.decode(response.body) as Map<String, dynamic>;
161 - final error = responseJSON['description'] as String;
162 -
163 - throw TradeNotCreatedException(description, description: error);
164 - }
165 -
166 - throw TradeNotCreatedException(description);
167 - }
168 -
169 - final responseJSON = json.decode(response.body) as Map<String, dynamic>;
170 - final id = responseJSON['id'] as String;
171 -
172 - return Trade(
173 - id: id,
174 - provider: description,
175 - from: _request.from,
176 - to: _request.to,
177 - state: TradeState.created,
178 - amount: _request.amount,
179 - createdAt: DateTime.now());
180 - }
181 -
182 - @override
183 - Future<Trade> findTradeById({@required String id}) async {
184 - final url = apiUri + _morphURISuffix + '/' + id;
185 - final response = await get(url);
186 -
187 - if (response.statusCode != 200) {
188 - if (response.statusCode == 400) {
189 - final responseJSON = json.decode(response.body) as Map<String, dynamic>;
190 - final error = responseJSON['description'] as String;
191 -
192 - throw TradeNotFoundException(id,
193 - provider: description, description: error);
194 - }
195 -
196 - throw TradeNotFoundException(id, provider: description);
197 - }
198 -
199 - final responseJSON = json.decode(response.body) as Map<String, dynamic>;
200 - final fromCurrency = responseJSON['input']['asset'] as String;
201 - final from = CryptoCurrency.fromString(fromCurrency.toLowerCase());
202 - final toCurrency = responseJSON['output'][0]['asset'] as String;
203 - final to = CryptoCurrency.fromString(toCurrency.toLowerCase());
204 - final inputAddress = responseJSON['input']['deposit_address'] as String;
205 - final status = responseJSON['state'] as String;
206 - final state = TradeState.deserialize(raw: status.toLowerCase());
207 -
208 - String amount = "";
209 - for (final trade in trades.values) {
210 - if (trade.id == id) {
211 - amount = trade.amount;
212 - break;
213 - }
214 - }
215 -
216 - return Trade(
217 - id: id,
218 - from: from,
219 - to: to,
220 - provider: description,
221 - inputAddress: inputAddress,
222 - amount: amount,
223 - state: state);
224 - }
225 -
226 - @override
227 - Future<double> calculateAmount(
228 - {CryptoCurrency from, CryptoCurrency to, double amount}) async {
229 - final url = apiUri + _ratesURISuffix;
230 - final response = await get(url);
231 - final responseJSON = json.decode(response.body) as Map<String, dynamic>;
232 - final rate = responseJSON['data'][from.toString()][to.toString()] as String;
233 -
234 - try {
235 - final estimatedAmount = double.parse(rate) * amount;
236 - return estimatedAmount;
237 - } catch(e) {
238 - return 0.0;
239 - }
240 - }
241 -}
lib/src/domain/litecoin/litecoin_amount_format.dart deleted
-6
@@ -1,6 +0,0 @@
1 -import 'package:cake_wallet/src/domain/common/crypto_amount_format.dart';
2 -
3 -const litecoinAmountDivider = 100000000;
4 -
5 -double litecoinAmountToDouble({int amount}) =>
6 - cryptoAmountToDouble(amount: amount, divider: litecoinAmountDivider);
\ No newline at end of file
lib/src/domain/monero/account_list.dart deleted
-68
@@ -1,68 +0,0 @@
1 -import 'package:rxdart/rxdart.dart';
2 -import 'package:cw_monero/account_list.dart' as account_list;
3 -import 'package:cake_wallet/src/domain/monero/account.dart';
4 -
5 -class AccountList {
6 - AccountList() {
7 - _isRefreshing = false;
8 - _isUpdating = false;
9 - _accounts = BehaviorSubject<List<Account>>();
10 - }
11 -
12 - Observable<List<Account>> get accounts => _accounts.stream;
13 -
14 - BehaviorSubject<List<Account>> _accounts;
15 - bool _isRefreshing;
16 - bool _isUpdating;
17 -
18 - Future update() async {
19 - if (_isUpdating) {
20 - return;
21 - }
22 -
23 - try {
24 - _isUpdating = true;
25 - refresh();
26 - final accounts = getAll();
27 - _accounts.add(accounts);
28 - _isUpdating = false;
29 - } catch (e) {
30 - _isUpdating = false;
31 - rethrow;
32 - }
33 - }
34 -
35 - List<Account> getAll() {
36 - return account_list
37 - .getAllAccount()
38 - .map((accountRow) => Account.fromRow(accountRow))
39 - .toList();
40 - }
41 -
42 - Future addAccount({String label}) async {
43 - await account_list.addAccount(label: label);
44 - await update();
45 - }
46 -
47 - Future setLabelSubaddress({int accountIndex, String label}) async {
48 - await account_list.setLabelForAccount(
49 - accountIndex: accountIndex, label: label);
50 - await update();
51 - }
52 -
53 - void refresh() {
54 - if (_isRefreshing) {
55 - return;
56 - }
57 -
58 - try {
59 - _isRefreshing = true;
60 - account_list.refreshAccounts();
61 - _isRefreshing = false;
62 - } catch (e) {
63 - _isRefreshing = false;
64 - print(e);
65 - rethrow;
66 - }
67 - }
68 -}
lib/src/domain/monero/monero_balance.dart deleted
-9
@@ -1,9 +0,0 @@
1 -import 'package:flutter/foundation.dart';
2 -import 'package:cake_wallet/src/domain/common/balance.dart';
3 -
4 -class MoneroBalance extends Balance {
5 - MoneroBalance({@required this.fullBalance, @required this.unlockedBalance});
6 -
7 - final String fullBalance;
8 - final String unlockedBalance;
9 -}
lib/src/domain/monero/monero_transaction_history.dart deleted
-70
@@ -1,70 +0,0 @@
1 -import 'dart:core';
2 -import 'package:cake_wallet/src/domain/monero/monero_transaction_info.dart';
3 -import 'package:flutter/services.dart';
4 -import 'package:rxdart/rxdart.dart';
5 -import 'package:cw_monero/transaction_history.dart'
6 - as monero_transaction_history;
7 -import 'package:cake_wallet/src/domain/common/transaction_history.dart';
8 -import 'package:cake_wallet/src/domain/common/transaction_info.dart';
9 -
10 -List<TransactionInfo> _getAllTransactions(dynamic _) =>
11 - monero_transaction_history
12 - .getAllTransations()
13 - .map((row) => MoneroTransactionInfo.fromRow(row))
14 - .toList();
15 -
16 -class MoneroTransactionHistory extends TransactionHistory {
17 - MoneroTransactionHistory()
18 - : _transactions = BehaviorSubject<List<TransactionInfo>>.seeded([]);
19 -
20 - @override
21 - Observable<List<TransactionInfo>> get transactions => _transactions.stream;
22 -
23 - final BehaviorSubject<List<TransactionInfo>> _transactions;
24 - bool _isUpdating = false;
25 - bool _isRefreshing = false;
26 - bool _needToCheckForRefresh = false;
27 -
28 - @override
29 - Future update() async {
30 - if (_isUpdating) {
31 - return;
32 - }
33 -
34 - try {
35 - _isUpdating = true;
36 - _transactions.value = await getAll(force: true);
37 - _isUpdating = false;
38 -
39 - if (!_needToCheckForRefresh) {
40 - _needToCheckForRefresh = true;
41 - }
42 - } catch (e) {
43 - _isUpdating = false;
44 - print(e);
45 - rethrow;
46 - }
47 - }
48 -
49 - @override
50 - Future<List<TransactionInfo>> getAll({bool force = false}) async {
51 - await refresh();
52 - return _getAllTransactions(null);
53 - }
54 -
55 - Future refresh() async {
56 - if (_isRefreshing) {
57 - return;
58 - }
59 -
60 - try {
61 - _isRefreshing = true;
62 - monero_transaction_history.refreshTransactions();
63 - _isRefreshing = false;
64 - } on PlatformException catch (e) {
65 - _isRefreshing = false;
66 - print(e);
67 - rethrow;
68 - }
69 - }
70 -}
lib/src/domain/monero/monero_wallet.dart deleted
-421
@@ -1,421 +0,0 @@
1 -import 'dart:async';
2 -import 'package:flutter/foundation.dart';
3 -import 'package:flutter/services.dart';
4 -import 'package:hive/hive.dart';
5 -import 'package:rxdart/rxdart.dart';
6 -import 'package:cw_monero/wallet.dart' as monero_wallet;
7 -import 'package:cw_monero/transaction_history.dart' as transaction_history;
8 -import 'package:cake_wallet/src/domain/common/wallet_info.dart';
9 -import 'package:cake_wallet/src/domain/common/wallet.dart';
10 -import 'package:cake_wallet/src/domain/common/sync_status.dart';
11 -import 'package:cake_wallet/src/domain/common/transaction_history.dart';
12 -import 'package:cake_wallet/src/domain/common/transaction_creation_credentials.dart';
13 -import 'package:cake_wallet/src/domain/common/pending_transaction.dart';
14 -import 'package:cake_wallet/src/domain/common/wallet_type.dart';
15 -import 'package:cake_wallet/src/domain/common/node.dart';
16 -import 'package:cake_wallet/src/domain/monero/monero_amount_format.dart';
17 -import 'package:cake_wallet/src/domain/monero/account.dart';
18 -import 'package:cake_wallet/src/domain/monero/account_list.dart';
19 -import 'package:cake_wallet/src/domain/monero/subaddress_list.dart';
20 -import 'package:cake_wallet/src/domain/monero/monero_transaction_creation_credentials.dart';
21 -import 'package:cake_wallet/src/domain/monero/monero_transaction_history.dart';
22 -import 'package:cake_wallet/src/domain/monero/subaddress.dart';
23 -import 'package:cake_wallet/src/domain/common/balance.dart';
24 -import 'package:cake_wallet/src/domain/monero/monero_balance.dart';
25 -
26 -const moneroBlockSize = 1000;
27 -
28 -class MoneroWallet extends Wallet {
29 - MoneroWallet({this.walletInfoSource, this.walletInfo}) {
30 - _cachedBlockchainHeight = 0;
31 - _isSaving = false;
32 - _lastSaveTime = 0;
33 - _lastRefreshTime = 0;
34 - _refreshHeight = 0;
35 - _lastSyncHeight = 0;
36 - _name = BehaviorSubject<String>();
37 - _address = BehaviorSubject<String>();
38 - _syncStatus = BehaviorSubject<SyncStatus>();
39 - _onBalanceChange = BehaviorSubject<MoneroBalance>();
40 - _account = BehaviorSubject<Account>()..add(Account(id: 0));
41 - _subaddress = BehaviorSubject<Subaddress>();
42 - setListeners();
43 - }
44 -
45 - static Future<MoneroWallet> createdWallet(
46 - {Box<WalletInfo> walletInfoSource,
47 - String name,
48 - bool isRecovery = false,
49 - int restoreHeight = 0}) async {
50 - // const type = WalletType.monero;
51 - // final id = walletTypeToString(type).toLowerCase() + '_' + name;
52 - // final walletInfo = WalletInfo(
53 - // id: id,
54 - // name: name,
55 - // type: type,
56 - // isRecovery: isRecovery,
57 - // restoreHeight: restoreHeight);
58 - // await walletInfoSource.add(walletInfo);
59 -
60 - // return await configured(
61 - // walletInfo: walletInfo, walletInfoSource: walletInfoSource);
62 - return null;
63 - }
64 -
65 - static Future<MoneroWallet> load(
66 - Box<WalletInfo> walletInfoSource, String name, WalletType type) async {
67 - final id = walletTypeToString(type).toLowerCase() + '_' + name;
68 - final walletInfo = walletInfoSource.values
69 - .firstWhere((info) => info.id == id, orElse: () => null);
70 - return await configured(
71 - walletInfoSource: walletInfoSource, walletInfo: walletInfo);
72 - }
73 -
74 - static Future<MoneroWallet> configured(
75 - {@required Box<WalletInfo> walletInfoSource,
76 - @required WalletInfo walletInfo}) async {
77 - final wallet = MoneroWallet(
78 - walletInfoSource: walletInfoSource, walletInfo: walletInfo);
79 -
80 - if (walletInfo.isRecovery) {
81 - wallet.setRecoveringFromSeed();
82 -
83 - if (walletInfo.restoreHeight != null) {
84 - wallet.setRefreshFromBlockHeight(height: walletInfo.restoreHeight);
85 - }
86 - }
87 -
88 - return wallet;
89 - }
90 -
91 - @override
92 - String get address => _address.value;
93 -
94 - @override
95 - String get name => _name.value;
96 -
97 - @override
98 - WalletType getType() => WalletType.monero;
99 -
100 - @override
101 - Observable<SyncStatus> get syncStatus => _syncStatus.stream;
102 -
103 - @override
104 - Observable<Balance> get onBalanceChange => _onBalanceChange.stream;
105 -
106 - @override
107 - Observable<String> get onNameChange => _name.stream;
108 -
109 - @override
110 - Observable<String> get onAddressChange => _address.stream;
111 -
112 - Observable<Account> get onAccountChange => _account.stream;
113 -
114 - Observable<Subaddress> get subaddress => _subaddress.stream;
115 -
116 - bool get isRecovery => walletInfo.isRecovery;
117 -
118 - Account get account => _account.value;
119 -
120 - Box<WalletInfo> walletInfoSource;
121 - WalletInfo walletInfo;
122 -
123 - BehaviorSubject<Account> _account;
124 - BehaviorSubject<MoneroBalance> _onBalanceChange;
125 - BehaviorSubject<SyncStatus> _syncStatus;
126 - BehaviorSubject<String> _name;
127 - BehaviorSubject<String> _address;
128 - BehaviorSubject<Subaddress> _subaddress;
129 - int _cachedBlockchainHeight;
130 - bool _isSaving;
131 - int _lastSaveTime;
132 - int _lastRefreshTime;
133 - int _refreshHeight;
134 - int _lastSyncHeight;
135 -
136 - TransactionHistory _cachedTransactionHistory;
137 - SubaddressList _cachedSubaddressList;
138 - AccountList _cachedAccountList;
139 -
140 - @override
141 - Future updateInfo() async {
142 - _name.value = await getName();
143 - final acccountList = getAccountList()..refresh();
144 - _account.value = acccountList.getAll().first;
145 - final subaddressList = getSubaddress();
146 - subaddressList.refresh(
147 - accountIndex: _account.value != null ? _account.value.id : 0);
148 - final subaddresses = subaddressList.getAll();
149 - _subaddress.value = subaddresses.first;
150 - _address.value = await getAddress();
151 - }
152 -
153 - @override
154 - Future<String> getFilename() async => monero_wallet.getFilename();
155 -
156 - @override
157 - Future<String> getName() async => getFilename()
158 - .then((filename) => filename.split('/'))
159 - .then((splitted) => splitted.last);
160 -
161 - @override
162 - Future<String> getAddress() async => monero_wallet.getAddress(
163 - accountIndex: _account.value.id, addressIndex: _subaddress.value.id);
164 -
165 - @override
166 - Future<String> getSeed() async => monero_wallet.getSeed();
167 -
168 - @override
169 - Future<String> getFullBalance() async => moneroAmountToString(
170 - amount: monero_wallet.getFullBalance(accountIndex: _account.value.id));
171 -
172 - @override
173 - Future<String> getUnlockedBalance() async => moneroAmountToString(
174 - amount:
175 - monero_wallet.getUnlockedBalance(accountIndex: _account.value.id));
176 -
177 - @override
178 - Future<int> getCurrentHeight() async => monero_wallet.getCurrentHeight();
179 -
180 - @override
181 - Future<int> getNodeHeight() async => monero_wallet.getNodeHeight();
182 -
183 - @override
184 - Future<bool> isConnected() async => monero_wallet.isConnected();
185 -
186 - @override
187 - Future<Map<String, String>> getKeys() async => {
188 - 'publicViewKey': monero_wallet.getPublicViewKey(),
189 - 'privateViewKey': monero_wallet.getSecretViewKey(),
190 - 'publicSpendKey': monero_wallet.getPublicSpendKey(),
191 - 'privateSpendKey': monero_wallet.getSecretSpendKey()
192 - };
193 -
194 - @override
195 - TransactionHistory getHistory() {
196 - if (_cachedTransactionHistory == null) {
197 - _cachedTransactionHistory = MoneroTransactionHistory();
198 - }
199 -
200 - return _cachedTransactionHistory;
201 - }
202 -
203 - SubaddressList getSubaddress() {
204 - if (_cachedSubaddressList == null) {
205 - _cachedSubaddressList = SubaddressList();
206 - }
207 -
208 - return _cachedSubaddressList;
209 - }
210 -
211 - AccountList getAccountList() {
212 - if (_cachedAccountList == null) {
213 - _cachedAccountList = AccountList();
214 - }
215 -
216 - return _cachedAccountList;
217 - }
218 -
219 - @override
220 - Future close() async {
221 -// monero_wallet.closeListeners();
222 - monero_wallet.closeCurrentWallet();
223 - await _name.close();
224 - await _address.close();
225 - await _subaddress.close();
226 - }
227 -
228 - @override
229 - Future connectToNode(
230 - {Node node, bool useSSL = false, bool isLightWallet = false}) async {
231 - try {
232 - _syncStatus.value = ConnectingSyncStatus();
233 - await monero_wallet.setupNode(
234 - address: node.uri,
235 - login: node.login,
236 - password: node.password,
237 - useSSL: useSSL,
238 - isLightWallet: isLightWallet);
239 - _syncStatus.value = ConnectedSyncStatus();
240 - } catch (e) {
241 - _syncStatus.value = FailedSyncStatus();
242 - print(e);
243 - }
244 - }
245 -
246 - @override
247 - Future startSync() async {
248 - try {
249 - _syncStatus.value = StartingSyncStatus();
250 - monero_wallet.startRefresh();
251 - } on PlatformException catch (e) {
252 - _syncStatus.value = FailedSyncStatus();
253 - print(e);
254 - rethrow;
255 - }
256 - }
257 -
258 - Future askForSave() async {
259 - final diff = DateTime.now().millisecondsSinceEpoch - _lastSaveTime;
260 -
261 - if (_lastSaveTime != 0 && diff < 120000) {
262 - return;
263 - }
264 -
265 - await store();
266 - }
267 -
268 - Future<int> getNodeHeightOrUpdate(int baseHeight) async {
269 - if (_cachedBlockchainHeight < baseHeight) {
270 - _cachedBlockchainHeight = await getNodeHeight();
271 - }
272 -
273 - return _cachedBlockchainHeight;
274 - }
275 -
276 - @override
277 - Future<PendingTransaction> createTransaction(
278 - TransactionCreationCredentials credentials) async {
279 - final _credentials = credentials as MoneroTransactionCreationCredentials;
280 - final transactionDescription = await transaction_history.createTransaction(
281 - address: _credentials.address,
282 - paymentId: _credentials.paymentId,
283 - amount: _credentials.amount,
284 - priorityRaw: _credentials.priority.serialize(),
285 - accountIndex: _account.value.id);
286 -
287 - return PendingTransaction.fromTransactionDescription(
288 - transactionDescription);
289 - }
290 -
291 - @override
292 - Future rescan({int restoreHeight = 0}) async {
293 - _syncStatus.value = StartingSyncStatus();
294 - setRefreshFromBlockHeight(height: restoreHeight);
295 - monero_wallet.rescanBlockchainAsync();
296 - _syncStatus.value = StartingSyncStatus();
297 - }
298 -
299 - void setRecoveringFromSeed() =>
300 - monero_wallet.setRecoveringFromSeed(isRecovery: true);
301 -
302 - void setRefreshFromBlockHeight({int height}) =>
303 - monero_wallet.setRefreshFromBlockHeight(height: height);
304 -
305 - Future setAsRecovered() async {
306 - walletInfo.isRecovery = false;
307 - await walletInfo.save();
308 - }
309 -
310 - Future askForUpdateBalance() async {
311 - final fullBalance = await getFullBalance();
312 - final unlockedBalance = await getUnlockedBalance();
313 - final needToChange = _onBalanceChange.value != null
314 - ? _onBalanceChange.value.fullBalance != fullBalance ||
315 - _onBalanceChange.value.unlockedBalance != unlockedBalance
316 - : true;
317 -
318 - if (!needToChange) {
319 - return;
320 - }
321 -
322 - _onBalanceChange.add(MoneroBalance(
323 - fullBalance: fullBalance, unlockedBalance: unlockedBalance));
324 - }
325 -
326 - Future askForUpdateTransactionHistory() async => await getHistory().update();
327 -
328 - void changeCurrentSubaddress(Subaddress subaddress) =>
329 - _subaddress.value = subaddress;
330 -
331 - void changeAccount(Account account) {
332 - _account.add(account);
333 - final subaddress = getSubaddress()..refresh(accountIndex: account.id);
334 - _subaddress.value = subaddress.getAll().first;
335 - }
336 -
337 - Future store() async {
338 - if (_isSaving) {
339 - return;
340 - }
341 -
342 - try {
343 - _isSaving = true;
344 - await monero_wallet.store();
345 - _isSaving = false;
346 - } on PlatformException catch (e) {
347 - print(e);
348 - _isSaving = false;
349 - rethrow;
350 - }
351 - }
352 -
353 - void setListeners() => null;
354 -// monero_wallet.setListeners(
355 -// _onNewBlock, _onNeedToRefresh, _onNewTransaction);
356 -
357 -// Future _onNewBlock(int height) async {
358 -// try {
359 -// final nodeHeight = await getNodeHeightOrUpdate(height);
360 -//
361 -// if (isRecovery && _refreshHeight <= 0) {
362 -// _refreshHeight = height;
363 -// }
364 -//
365 -// if (isRecovery &&
366 -// (_lastSyncHeight == 0 ||
367 -// (height - _lastSyncHeight) > moneroBlockSize)) {
368 -// _lastSyncHeight = height;
369 -// await askForUpdateBalance();
370 -// await askForUpdateTransactionHistory();
371 -// }
372 -//
373 -// if (height > 0 && ((nodeHeight - height) < moneroBlockSize)) {
374 -// _syncStatus.add(SyncedSyncStatus());
375 -// } else {
376 -// _syncStatus.add(SyncingSyncStatus(height, nodeHeight, _refreshHeight));
377 -// }
378 -// } catch (e) {
379 -// print(e);
380 -// }
381 -// }
382 -
383 -// Future _onNeedToRefresh() async {
384 -// try {
385 -//
386 -//
387 -// if (_syncStatus.value is FailedSyncStatus) {
388 -// return;
389 -// }
390 -//
391 -// await askForUpdateBalance();
392 -//
393 -// _syncStatus.add(SyncedSyncStatus());
394 -//
395 -// if (isRecovery) {
396 -// await askForUpdateTransactionHistory();
397 -// }
398 -//
399 -//// if (isRecovery && (nodeHeight - currentHeight < moneroBlockSize)) {
400 -//// await setAsRecovered();
401 -//// }
402 -//
403 -// final now = DateTime.now().millisecondsSinceEpoch;
404 -// final diff = now - _lastRefreshTime;
405 -//
406 -// if (diff >= 0 && diff < 60000) {
407 -// return;
408 -// }
409 -//
410 -// await store();
411 -// _lastRefreshTime = now;
412 -// } catch (e) {
413 -// print(e);
414 -// }
415 -// }
416 -
417 -// Future _onNewTransaction() async {
418 -// await askForUpdateBalance();
419 -// await askForUpdateTransactionHistory();
420 -// }
421 -}
lib/src/domain/monero/monero_wallets_manager.dart deleted
-163
@@ -1,163 +0,0 @@
1 -import 'dart:async';
2 -import 'dart:io';
3 -import 'package:cake_wallet/src/domain/common/pathForWallet.dart';
4 -import 'package:flutter/foundation.dart';
5 -import 'package:hive/hive.dart';
6 -import 'package:path_provider/path_provider.dart';
7 -import 'package:cw_monero/wallet_manager.dart' as monero_wallet_manager;
8 -import 'package:cake_wallet/src/domain/common/wallet_info.dart';
9 -import 'package:cake_wallet/src/domain/common/wallet_type.dart';
10 -import 'package:cake_wallet/src/domain/common/wallets_manager.dart';
11 -import 'package:cake_wallet/src/domain/common/wallet.dart';
12 -import 'package:cake_wallet/src/domain/monero/monero_wallet.dart';
13 -import 'package:cake_wallet/src/domain/common/wallet_description.dart';
14 -
15 -class MoneroWalletsManager extends WalletsManager {
16 - MoneroWalletsManager({@required this.walletInfoSource});
17 -
18 - static const type = WalletType.monero;
19 -
20 - Box<WalletInfo> walletInfoSource;
21 -
22 - @override
23 - Future<Wallet> create(String name, String password, String language) async {
24 - try {
25 - const isRecovery = false;
26 - final path = await pathForWallet(name: name, type: WalletType.monero);
27 -
28 - await monero_wallet_manager.createWallet(
29 - path: path, password: password, language: language);
30 -
31 - final wallet = await MoneroWallet.createdWallet(
32 - walletInfoSource: walletInfoSource,
33 - name: name,
34 - isRecovery: isRecovery);
35 - await wallet.updateInfo();
36 -
37 - return wallet;
38 - } catch (e) {
39 - print('MoneroWalletsManager Error: $e');
40 - rethrow;
41 - }
42 - }
43 -
44 - @override
45 - Future<Wallet> restoreFromSeed(
46 - String name, String password, String seed, int restoreHeight) async {
47 - try {
48 - const isRecovery = true;
49 - final path = await pathForWallet(name: name, type: WalletType.monero);
50 -
51 - await monero_wallet_manager.restoreFromSeed(
52 - path: path,
53 - password: password,
54 - seed: seed,
55 - restoreHeight: restoreHeight);
56 -
57 - final wallet = await MoneroWallet.createdWallet(
58 - walletInfoSource: walletInfoSource,
59 - name: name,
60 - isRecovery: isRecovery,
61 - restoreHeight: restoreHeight);
62 - await wallet.updateInfo();
63 -
64 - return wallet;
65 - } catch (e) {
66 - print('MoneroWalletsManager Error: $e');
67 - rethrow;
68 - }
69 - }
70 -
71 - @override
72 - Future<Wallet> restoreFromKeys(
73 - String name,
74 - String password,
75 - String language,
76 - int restoreHeight,
77 - String address,
78 - String viewKey,
79 - String spendKey) async {
80 - try {
81 - const isRecovery = true;
82 - final path = await pathForWallet(name: name, type: WalletType.monero);
83 -
84 - await monero_wallet_manager.restoreFromKeys(
85 - path: path,
86 - password: password,
87 - language: language,
88 - restoreHeight: restoreHeight,
89 - address: address,
90 - viewKey: viewKey,
91 - spendKey: spendKey);
92 -
93 - final wallet = await MoneroWallet.createdWallet(
94 - walletInfoSource: walletInfoSource,
95 - name: name,
96 - isRecovery: isRecovery,
97 - restoreHeight: restoreHeight);
98 - await wallet.updateInfo();
99 -
100 - return wallet;
101 - } catch (e) {
102 - print('MoneroWalletsManager Error: $e');
103 - rethrow;
104 - }
105 - }
106 -
107 - @override
108 - Future<Wallet> openWallet(String name, String password) async {
109 - try {
110 - final path = await pathForWallet(name: name, type: WalletType.monero);
111 - monero_wallet_manager.openWallet(path: path, password: password);
112 - final wallet = await MoneroWallet.load(walletInfoSource, name, type);
113 - await wallet.updateInfo();
114 -
115 - return wallet;
116 - } catch (e) {
117 - print('MoneroWalletsManager Error: $e');
118 - rethrow;
119 - }
120 - }
121 -
122 - @override
123 - Future<bool> isWalletExit(String name) async {
124 - try {
125 - final path = await pathForWallet(name: name, type: WalletType.monero);
126 - return monero_wallet_manager.isWalletExist(path: path);
127 - } catch (e) {
128 - print('MoneroWalletsManager Error: $e');
129 - rethrow;
130 - }
131 - }
132 -
133 - @override
134 - Future remove(WalletDescription wallet) async {
135 - final dir = await getApplicationDocumentsDirectory();
136 - final root = dir.path.replaceAll('app_flutter', 'files');
137 - final walletFilePath = root + '/cw_monero/' + wallet.name;
138 - final keyPath = walletFilePath + '.keys';
139 - final addressFilePath = walletFilePath + '.address.txt';
140 - final walletFile = File(walletFilePath);
141 - final keyFile = File(keyPath);
142 - final addressFile = File(addressFilePath);
143 -
144 - if (await walletFile.exists()) {
145 - await walletFile.delete();
146 - }
147 -
148 - if (await keyFile.exists()) {
149 - await keyFile.delete();
150 - }
151 -
152 - if (await addressFile.exists()) {
153 - await addressFile.delete();
154 - }
155 -
156 - final id =
157 - walletTypeToString(wallet.type).toLowerCase() + '_' + wallet.name;
158 - final info = walletInfoSource.values
159 - .firstWhere((info) => info.id == id, orElse: () => null);
160 -
161 - await info?.delete();
162 - }
163 -}
lib/src/domain/monero/subaddress_list.dart deleted
-70
@@ -1,70 +0,0 @@
1 -import 'package:flutter/services.dart';
2 -import 'package:rxdart/rxdart.dart';
3 -import 'package:cw_monero/subaddress_list.dart' as subaddress_list;
4 -import 'package:cake_wallet/src/domain/monero/subaddress.dart';
5 -
6 -class SubaddressList {
7 - SubaddressList() {
8 - _isRefreshing = false;
9 - _isUpdating = false;
10 - _subaddress = BehaviorSubject<List<Subaddress>>();
11 - }
12 -
13 - Observable<List<Subaddress>> get subaddresses => _subaddress.stream;
14 -
15 - BehaviorSubject<List<Subaddress>> _subaddress;
16 - bool _isRefreshing;
17 - bool _isUpdating;
18 -
19 - void update({int accountIndex}) {
20 - if (_isUpdating) {
21 - return;
22 - }
23 -
24 - try {
25 - _isUpdating = true;
26 - refresh(accountIndex: accountIndex);
27 - _subaddress.add(getAll());
28 - _isUpdating = false;
29 - } catch (e) {
30 - _isUpdating = false;
31 - rethrow;
32 - }
33 - }
34 -
35 - List<Subaddress> getAll() {
36 - return subaddress_list
37 - .getAllSubaddresses()
38 - .map((subaddressRow) => Subaddress.fromRow(subaddressRow))
39 - .toList();
40 - }
41 -
42 - Future addSubaddress({int accountIndex, String label}) async {
43 - await subaddress_list.addSubaddress(
44 - accountIndex: accountIndex, label: label);
45 - await update(accountIndex: accountIndex);
46 - }
47 -
48 - Future setLabelSubaddress(
49 - {int accountIndex, int addressIndex, String label}) async {
50 - await subaddress_list.setLabelForSubaddress(
51 - accountIndex: accountIndex, addressIndex: addressIndex, label: label);
52 - await update(accountIndex: accountIndex);
53 - }
54 -
55 - void refresh({int accountIndex}) {
56 - if (_isRefreshing) {
57 - return;
58 - }
59 -
60 - try {
61 - _isRefreshing = true;
62 - subaddress_list.refreshSubaddresses(accountIndex: accountIndex);
63 - _isRefreshing = false;
64 - } on PlatformException catch (e) {
65 - _isRefreshing = false;
66 - print(e);
67 - rethrow;
68 - }
69 - }
70 -}
lib/src/domain/services/fiat_convertation_service.dart deleted
-10
@@ -1,10 +0,0 @@
1 -import 'dart:async';
2 -import 'package:cake_wallet/src/domain/common/fiat_currency.dart';
3 -import 'package:cake_wallet/src/domain/common/crypto_currency.dart';
4 -import 'package:cake_wallet/src/domain/common/fetch_price.dart';
5 -
6 -class FiatConvertationService {
7 - Future<double> getPrice({CryptoCurrency crypto, FiatCurrency fiat}) async {
8 - return await fetchPriceFor(crypto: crypto, fiat: fiat);
9 - }
10 -}
\ No newline at end of file
lib/src/domain/services/user_service.dart deleted
-46
@@ -1,46 +0,0 @@
1 -import 'package:flutter_secure_storage/flutter_secure_storage.dart';
2 -import 'package:shared_preferences/shared_preferences.dart';
3 -import 'package:cake_wallet/src/domain/common/secret_store_key.dart';
4 -import 'package:cake_wallet/src/domain/common/encrypt.dart';
5 -
6 -class UserService {
7 - UserService({this.sharedPreferences, this.secureStorage});
8 -
9 - final FlutterSecureStorage secureStorage;
10 - final SharedPreferences sharedPreferences;
11 -
12 - Future setPassword(String password) async {
13 - final key = generateStoreKeyFor(key: SecretStoreKey.pinCodePassword);
14 -
15 - try {
16 - final encodedPassord = encodedPinCode(pin: password);
17 -
18 - await secureStorage.write(key: key, value: encodedPassord);
19 - } catch (e) {
20 - print(e);
21 - }
22 - }
23 -
24 - Future<bool> canAuthenticate() async {
25 - final key = generateStoreKeyFor(key: SecretStoreKey.pinCodePassword);
26 - final sharedPreferences = await SharedPreferences.getInstance();
27 - final walletName = sharedPreferences.getString("current_wallet_name") ?? "";
28 - var password = '';
29 -
30 - try {
31 - password = await secureStorage.read(key: key);
32 - } catch (e) {
33 - print(e);
34 - }
35 -
36 - return walletName.isNotEmpty && password.isNotEmpty;
37 - }
38 -
39 - Future<bool> authenticate(String pin) async {
40 - final key = generateStoreKeyFor(key: SecretStoreKey.pinCodePassword);
41 - final encodedPin = await secureStorage.read(key: key);
42 - final decodedPin = decodedPinCode(pin: encodedPin);
43 -
44 - return decodedPin == pin;
45 - }
46 -}
lib/src/domain/services/wallet_list_service.dart deleted
-163
@@ -1,163 +0,0 @@
1 -import 'dart:async';
2 -import 'package:cake_wallet/bitcoin/key.dart';
3 -import 'package:cake_wallet/src/domain/common/wallet_info.dart';
4 -import 'package:flutter/foundation.dart';
5 -import 'package:hive/hive.dart';
6 -import 'package:flutter_secure_storage/flutter_secure_storage.dart';
7 -import 'package:uuid/uuid.dart';
8 -import 'package:shared_preferences/shared_preferences.dart';
9 -import 'package:cake_wallet/src/domain/common/encrypt.dart';
10 -import 'package:cake_wallet/src/domain/common/wallet.dart';
11 -import 'package:cake_wallet/src/domain/common/wallet_description.dart';
12 -import 'package:cake_wallet/src/domain/common/wallets_manager.dart';
13 -import 'package:cake_wallet/src/domain/common/secret_store_key.dart';
14 -import 'package:cake_wallet/src/domain/common/wallet_type.dart';
15 -import 'package:cake_wallet/src/domain/monero/monero_wallets_manager.dart';
16 -import 'package:cake_wallet/src/domain/services/wallet_service.dart';
17 -
18 -class WalletIsExistException implements Exception {
19 - WalletIsExistException(this.name);
20 -
21 - String name;
22 -
23 - @override
24 - String toString() => "Wallet with name $name is already exist!";
25 -}
26 -
27 -class WalletListService {
28 - WalletListService(
29 - {this.secureStorage,
30 - this.walletInfoSource,
31 - this.walletsManager,
32 - @required this.walletService,
33 - @required this.sharedPreferences})
34 - : _type = WalletType.monero;
35 -
36 - final FlutterSecureStorage secureStorage;
37 - final WalletService walletService;
38 - final Box<WalletInfo> walletInfoSource;
39 - final SharedPreferences sharedPreferences;
40 - WalletsManager walletsManager;
41 - WalletType _type;
42 -
43 - Future<List<WalletDescription>> getAll() async => walletInfoSource.values
44 - .map((info) => WalletDescription(name: info.name, type: info.type))
45 - .toList();
46 -
47 - Future create(String name, String language) async {
48 - if (await walletsManager.isWalletExit(name)) {
49 - throw WalletIsExistException(name);
50 - }
51 -
52 - if (walletService.currentWallet != null) {
53 - await walletService.close();
54 - }
55 -
56 - final password = _generatePassword();
57 - await saveWalletPassword(password: password, walletName: name);
58 -
59 - final wallet = await walletsManager.create(name, password, language);
60 -
61 - await onWalletChange(wallet);
62 - }
63 -
64 - Future restoreFromSeed(String name, String seed, int restoreHeight) async {
65 - if (await walletsManager.isWalletExit(name)) {
66 - throw WalletIsExistException(name);
67 - }
68 -
69 - if (walletService.currentWallet != null) {
70 - await walletService.close();
71 - }
72 -
73 - final password = _generatePassword();
74 - await saveWalletPassword(password: password, walletName: name);
75 -
76 - final wallet = await walletsManager.restoreFromSeed(
77 - name, password, seed, restoreHeight);
78 -
79 - await onWalletChange(wallet);
80 - }
81 -
82 - Future restoreFromKeys(String name, String language, int restoreHeight,
83 - String address, String viewKey, String spendKey) async {
84 - if (await walletsManager.isWalletExit(name)) {
85 - throw WalletIsExistException(name);
86 - }
87 -
88 - if (walletService.currentWallet != null) {
89 - await walletService.close();
90 - }
91 -
92 - final password = _generatePassword();
93 - await saveWalletPassword(password: password, walletName: name);
94 -
95 - final wallet = await walletsManager.restoreFromKeys(
96 - name, password, language, restoreHeight, address, viewKey, spendKey);
97 -
98 - await onWalletChange(wallet);
99 - }
100 -
101 - Future openWallet(String name) async {
102 - if (walletService.currentWallet != null) {
103 - await walletService.close();
104 - }
105 -
106 - final password = await getWalletPassword(walletName: name);
107 - final wallet = await walletsManager.openWallet(name, password);
108 -
109 - await onWalletChange(wallet);
110 - }
111 -
112 - Future changeWalletManger({WalletType walletType}) async {
113 - _type = walletType;
114 -
115 - switch (walletType) {
116 - case WalletType.monero:
117 - walletsManager =
118 - MoneroWalletsManager(walletInfoSource: walletInfoSource);
119 - break;
120 - case WalletType.bitcoin:
121 -// walletsManager = BitcoinWalletManager();
122 - break;
123 - case WalletType.none:
124 - walletsManager = null;
125 - break;
126 - }
127 - }
128 -
129 - Future onWalletChange(Wallet wallet) async {
130 - walletService.currentWallet = wallet;
131 - final walletName = await wallet.getName();
132 - print('walletName $walletName ');
133 - await sharedPreferences.setString('current_wallet_name', walletName);
134 - }
135 -
136 - Future remove(WalletDescription wallet) async =>
137 - await walletsManager.remove(wallet);
138 -
139 - Future<String> getWalletPassword({String walletName}) async {
140 - final key = generateStoreKeyFor(
141 - key: SecretStoreKey.moneroWalletPassword, walletName: walletName);
142 - final encodedPassword = await secureStorage.read(key: key);
143 -
144 - return decodeWalletPassword(password: encodedPassword);
145 - }
146 -
147 - Future saveWalletPassword({String walletName, String password}) async {
148 - final key = generateStoreKeyFor(
149 - key: SecretStoreKey.moneroWalletPassword, walletName: walletName);
150 - final encodedPassword = encodeWalletPassword(password: password);
151 -
152 - await secureStorage.write(key: key, value: encodedPassword);
153 - }
154 -
155 - String _generatePassword() {
156 - switch (_type) {
157 - case WalletType.bitcoin:
158 - return generateKey();
159 - default:
160 - return Uuid().v4();
161 - }
162 - }
163 -}
lib/src/domain/services/wallet_service.dart deleted
-131
@@ -1,131 +0,0 @@
1 -import 'package:rxdart/rxdart.dart';
2 -import 'package:cake_wallet/src/domain/common/balance.dart';
3 -import 'package:cake_wallet/src/domain/common/wallet_description.dart';
4 -import 'package:cake_wallet/src/domain/common/wallet.dart';
5 -import 'package:cake_wallet/src/domain/common/transaction_history.dart';
6 -import 'package:cake_wallet/src/domain/common/wallet_type.dart';
7 -import 'package:cake_wallet/src/domain/common/sync_status.dart';
8 -import 'package:cake_wallet/src/domain/common/transaction_creation_credentials.dart';
9 -import 'package:cake_wallet/src/domain/common/pending_transaction.dart';
10 -import 'package:cake_wallet/src/domain/common/node.dart';
11 -
12 -class WalletService extends Wallet {
13 - WalletService() {
14 - _currentWallet = null;
15 - walletType = WalletType.none;
16 - _syncStatus = BehaviorSubject<SyncStatus>();
17 - _onBalanceChange = BehaviorSubject<Balance>();
18 - _onWalletChanged = BehaviorSubject<Wallet>();
19 - }
20 -
21 - @override
22 - Observable<Balance> get onBalanceChange => _onBalanceChange.stream;
23 -
24 - @override
25 - Observable<SyncStatus> get syncStatus => _syncStatus.stream;
26 -
27 - @override
28 - Observable<String> get onAddressChange => _currentWallet.onAddressChange;
29 -
30 - @override
31 - Observable<String> get onNameChange => _currentWallet.onNameChange;
32 -
33 - @override
34 - String get address => _currentWallet.address;
35 -
36 - @override
37 - String get name => _currentWallet.name;
38 -
39 - @override
40 - WalletType get walletType => _currentWallet.walletType;
41 -
42 - Observable<Wallet> get onWalletChange => _onWalletChanged.stream;
43 -
44 - SyncStatus get syncStatusValue => _syncStatus.value;
45 -
46 - Wallet get currentWallet => _currentWallet;
47 -
48 - set currentWallet(Wallet wallet) {
49 - _currentWallet = wallet;
50 -
51 - if (wallet == null) {
52 - return;
53 - }
54 -
55 - _currentWallet.onBalanceChange
56 - .listen((wallet) => _onBalanceChange.add(wallet));
57 - _currentWallet.syncStatus.listen((status) => _syncStatus.add(status));
58 - _onWalletChanged.add(wallet);
59 -
60 - final type = wallet.getType();
61 - wallet.getName().then(
62 - (name) => description = WalletDescription(name: name, type: type));
63 - }
64 -
65 - BehaviorSubject<Wallet> _onWalletChanged;
66 - BehaviorSubject<Balance> _onBalanceChange;
67 - BehaviorSubject<SyncStatus> _syncStatus;
68 - Wallet _currentWallet;
69 -
70 - WalletDescription description;
71 -
72 - @override
73 - WalletType getType() => _currentWallet.getType();
74 -
75 - @override
76 - Future<String> getFilename() => _currentWallet.getFilename();
77 -
78 - @override
79 - Future<String> getName() => _currentWallet.getName();
80 -
81 - @override
82 - Future<String> getAddress() => _currentWallet.getAddress();
83 -
84 - @override
85 - Future<String> getSeed() => _currentWallet.getSeed();
86 -
87 - @override
88 - Future<Map<String, String>> getKeys() => _currentWallet.getKeys();
89 -
90 - @override
91 - Future<String> getFullBalance() => _currentWallet.getFullBalance();
92 -
93 - @override
94 - Future<String> getUnlockedBalance() => _currentWallet.getUnlockedBalance();
95 -
96 - @override
97 - Future<int> getCurrentHeight() => _currentWallet.getCurrentHeight();
98 -
99 - @override
100 - Future<int> getNodeHeight() => _currentWallet.getNodeHeight();
101 -
102 - @override
103 - Future<bool> isConnected() => _currentWallet.isConnected();
104 -
105 - @override
106 - Future close() => _currentWallet.close();
107 -
108 - @override
109 - Future connectToNode(
110 - {Node node, bool useSSL = false, bool isLightWallet = false}) =>
111 - _currentWallet.connectToNode(
112 - node: node, useSSL: useSSL, isLightWallet: isLightWallet);
113 -
114 - @override
115 - Future startSync() => _currentWallet.startSync();
116 -
117 - @override
118 - TransactionHistory getHistory() => _currentWallet.getHistory();
119 -
120 - @override
121 - Future<PendingTransaction> createTransaction(
122 - TransactionCreationCredentials credentials) =>
123 - _currentWallet.createTransaction(credentials);
124 -
125 - @override
126 - Future updateInfo() async => _currentWallet.updateInfo();
127 -
128 - @override
129 - Future rescan({int restoreHeight = 0}) async =>
130 - _currentWallet.rescan(restoreHeight: restoreHeight);
131 -}
lib/src/reactions/set_reactions.dart
+98 -98
@@ -1,98 +1,98 @@
1 -import 'dart:async';
2 -import 'package:flutter/foundation.dart';
3 -import 'package:mobx/mobx.dart';
4 -import 'package:cake_wallet/src/domain/common/node.dart';
5 -import 'package:cake_wallet/src/domain/common/sync_status.dart';
6 -import 'package:cake_wallet/src/domain/services/wallet_service.dart';
7 -import 'package:cake_wallet/src/start_updating_price.dart';
8 -import 'package:cake_wallet/src/stores/sync/sync_store.dart';
9 -import 'package:cake_wallet/src/stores/wallet/wallet_store.dart';
10 -import 'package:cake_wallet/src/stores/settings/settings_store.dart';
11 -import 'package:cake_wallet/src/stores/price/price_store.dart';
12 -import 'package:cake_wallet/src/stores/authentication/authentication_store.dart';
13 -import 'package:cake_wallet/src/stores/login/login_store.dart';
14 -
15 -Timer _reconnectionTimer;
16 -ReactionDisposer _connectToNodeDisposer;
17 -ReactionDisposer _onSyncStatusChangeDisposer;
18 -ReactionDisposer _onCurrentWalletChangeDisposer;
19 -
20 -void setReactions(
21 - {@required SettingsStore settingsStore,
22 - @required PriceStore priceStore,
23 - @required SyncStore syncStore,
24 - @required WalletStore walletStore,
25 - @required WalletService walletService,
26 -// @required AuthenticationStore authenticationStore,
27 - @required LoginStore loginStore}) {
28 - connectToNode(settingsStore: settingsStore, walletStore: walletStore);
29 - onSyncStatusChange(
30 - syncStore: syncStore,
31 - walletStore: walletStore,
32 - settingsStore: settingsStore);
33 - onCurrentWalletChange(
34 - walletStore: walletStore,
35 - settingsStore: settingsStore,
36 - priceStore: priceStore);
37 - autorun((_) async {
38 -// if (authenticationStore.state == AuthenticationState.allowed) {
39 -// await loginStore.loadCurrentWallet();
40 -// authenticationStore.state = AuthenticationState.readyToLogin;
41 -// }
42 - });
43 -}
44 -
45 -void connectToNode({SettingsStore settingsStore, WalletStore walletStore}) {
46 - _connectToNodeDisposer?.call();
47 -
48 - _connectToNodeDisposer = reaction((_) => settingsStore.node,
49 - (Node node) async => await walletStore.connectToNode(node: node));
50 -}
51 -
52 -void onCurrentWalletChange(
53 - {WalletStore walletStore,
54 - SettingsStore settingsStore,
55 - PriceStore priceStore}) {
56 - _onCurrentWalletChangeDisposer?.call();
57 -
58 - reaction((_) => walletStore.name, (String _) {
59 - walletStore.connectToNode(node: settingsStore.node);
60 - startUpdatingPrice(settingsStore: settingsStore, priceStore: priceStore);
61 - });
62 -}
63 -
64 -void onSyncStatusChange(
65 - {SyncStore syncStore,
66 - WalletStore walletStore,
67 - SettingsStore settingsStore}) {
68 - // _onSyncStatusChangeDisposer?.call();
69 -
70 - // reaction((_) => syncStore.status, (SyncStatus status) async {
71 - // if (status is ConnectedSyncStatus) {
72 - // await walletStore.startSync();
73 - // }
74 -
75 - // // Reconnect to the node if the app is not started sync after 30 seconds
76 - // if (status is StartingSyncStatus) {
77 - // startReconnectionObserver(syncStore: syncStore, walletStore: walletStore);
78 - // }
79 - // });
80 -}
81 -
82 -void startReconnectionObserver({SyncStore syncStore, WalletStore walletStore}) {
83 - if (_reconnectionTimer != null) {
84 - _reconnectionTimer.cancel();
85 - }
86 -
87 - _reconnectionTimer = Timer.periodic(Duration(minutes: 1), (_) async {
88 - try {
89 - final isConnected = await walletStore.isConnected();
90 -
91 - if (!isConnected) {
92 - await walletStore.reconnect();
93 - }
94 - } catch (e) {
95 - print(e);
96 - }
97 - });
98 -}
1 +// import 'dart:async';
2 +// import 'package:flutter/foundation.dart';
3 +// import 'package:mobx/mobx.dart';
4 +// import 'package:cake_wallet/entities/node.dart';
5 +// import 'package:cake_wallet/entities/sync_status.dart';
6 +// import 'package:cake_wallet/src/domain/services/wallet_service.dart';
7 +// import 'package:cake_wallet/src/start_updating_price.dart';
8 +// import 'package:cake_wallet/src/stores/sync/sync_store.dart';
9 +// import 'package:cake_wallet/src/stores/wallet/wallet_store.dart';
10 +// import 'package:cake_wallet/src/stores/settings/settings_store.dart';
11 +// import 'package:cake_wallet/src/stores/price/price_store.dart';
12 +// import 'package:cake_wallet/src/stores/authentication/authentication_store.dart';
13 +// import 'package:cake_wallet/src/stores/login/login_store.dart';
14 +//
15 +// Timer _reconnectionTimer;
16 +// ReactionDisposer _connectToNodeDisposer;
17 +// ReactionDisposer _onSyncStatusChangeDisposer;
18 +// ReactionDisposer _onCurrentWalletChangeDisposer;
19 +//
20 +// void setReactions(
21 +// {@required SettingsStore settingsStore,
22 +// @required PriceStore priceStore,
23 +// @required SyncStore syncStore,
24 +// @required WalletStore walletStore,
25 +// @required WalletService walletService,
26 +// // @required AuthenticationStore authenticationStore,
27 +// @required LoginStore loginStore}) {
28 +// connectToNode(settingsStore: settingsStore, walletStore: walletStore);
29 +// onSyncStatusChange(
30 +// syncStore: syncStore,
31 +// walletStore: walletStore,
32 +// settingsStore: settingsStore);
33 +// onCurrentWalletChange(
34 +// walletStore: walletStore,
35 +// settingsStore: settingsStore,
36 +// priceStore: priceStore);
37 +// autorun((_) async {
38 +// // if (authenticationStore.state == AuthenticationState.allowed) {
39 +// // await loginStore.loadCurrentWallet();
40 +// // authenticationStore.state = AuthenticationState.readyToLogin;
41 +// // }
42 +// });
43 +// }
44 +//
45 +// void connectToNode({SettingsStore settingsStore, WalletStore walletStore}) {
46 +// _connectToNodeDisposer?.call();
47 +//
48 +// _connectToNodeDisposer = reaction((_) => settingsStore.node,
49 +// (Node node) async => await walletStore.connectToNode(node: node));
50 +// }
51 +//
52 +// void onCurrentWalletChange(
53 +// {WalletStore walletStore,
54 +// SettingsStore settingsStore,
55 +// PriceStore priceStore}) {
56 +// _onCurrentWalletChangeDisposer?.call();
57 +//
58 +// reaction((_) => walletStore.name, (String _) {
59 +// walletStore.connectToNode(node: settingsStore.node);
60 +// startUpdatingPrice(settingsStore: settingsStore, priceStore: priceStore);
61 +// });
62 +// }
63 +//
64 +// void onSyncStatusChange(
65 +// {SyncStore syncStore,
66 +// WalletStore walletStore,
67 +// SettingsStore settingsStore}) {
68 +// // _onSyncStatusChangeDisposer?.call();
69 +//
70 +// // reaction((_) => syncStore.status, (SyncStatus status) async {
71 +// // if (status is ConnectedSyncStatus) {
72 +// // await walletStore.startSync();
73 +// // }
74 +//
75 +// // // Reconnect to the node if the app is not started sync after 30 seconds
76 +// // if (status is StartingSyncStatus) {
77 +// // startReconnectionObserver(syncStore: syncStore, walletStore: walletStore);
78 +// // }
79 +// // });
80 +// }
81 +//
82 +// void startReconnectionObserver({SyncStore syncStore, WalletStore walletStore}) {
83 +// if (_reconnectionTimer != null) {
84 +// _reconnectionTimer.cancel();
85 +// }
86 +//
87 +// _reconnectionTimer = Timer.periodic(Duration(minutes: 1), (_) async {
88 +// try {
89 +// final isConnected = await walletStore.isConnected();
90 +//
91 +// if (!isConnected) {
92 +// await walletStore.reconnect();
93 +// }
94 +// } catch (e) {
95 +// print(e);
96 +// }
97 +// });
98 +// }
lib/src/screens/auth/auth_page.dart
+30 -51
@@ -5,20 +5,18 @@ import 'package:cake_wallet/generated/i18n.dart';
5 import 'package:cake_wallet/view_model/auth_state.dart';
6 import 'package:cake_wallet/view_model/auth_view_model.dart';
7 import 'package:cake_wallet/src/screens/pin_code/pin_code.dart';
8 -import 'package:cake_wallet/src/domain/common/biometric_auth.dart';
8 +import 'package:cake_wallet/src/screens/pin_code/pin_code_widget.dart';
9 +import 'package:cake_wallet/entities/biometric_auth.dart';
10 +import 'package:cake_wallet/core/execution_state.dart';
11
12 typedef OnAuthenticationFinished = void Function(bool, AuthPageState);
13
14 class AuthPage extends StatefulWidget {
13 - AuthPage(
14 - {@required this.allowBiometricalAuthentication,
15 - this.onAuthenticationFinished,
16 - this.authViewModel,
17 - this.closable = true});
15 + AuthPage(this.authViewModel,
16 + {this.onAuthenticationFinished, this.closable = true});
17
18 final AuthViewModel authViewModel;
19 final OnAuthenticationFinished onAuthenticationFinished;
21 - final bool allowBiometricalAuthentication;
20 final bool closable;
21
22 @override
@@ -35,8 +33,8 @@ class AuthPageState extends State<AuthPage> {
33 @override
34 void initState() {
35 _reaction ??=
38 - reaction((_) => widget.authViewModel.state, (AuthState state) {
39 - if (state is AuthenticatedSuccessfully) {
36 + reaction((_) => widget.authViewModel.state, (ExecutionState state) {
37 + if (state is ExecutedSuccessfullyState) {
38 WidgetsBinding.instance.addPostFrameCallback((_) {
39 if (widget.onAuthenticationFinished != null) {
40 widget.onAuthenticationFinished(true, this);
@@ -51,7 +49,7 @@ class AuthPageState extends State<AuthPage> {
49 });
50 }
51
54 - if (state is AuthenticationInProgress) {
52 + if (state is IsExecutingState) {
53 WidgetsBinding.instance.addPostFrameCallback((_) {
54 _key.currentState.showSnackBar(
55 SnackBar(
@@ -62,7 +60,7 @@ class AuthPageState extends State<AuthPage> {
60 });
61 }
62
65 - if (state is AuthenticationFailure) {
63 + if (state is FailureState) {
64 WidgetsBinding.instance.addPostFrameCallback((_) {
65 _pinCodeKey.currentState.clear();
66 _key.currentState.hideCurrentSnackBar();
@@ -97,23 +95,10 @@ class AuthPageState extends State<AuthPage> {
95 }
96 });
97
100 - if (widget.allowBiometricalAuthentication) {
98 + if (widget.authViewModel.isBiometricalAuthenticationAllowed) {
99 WidgetsBinding.instance.addPostFrameCallback((_) async {
102 - print('post');
100 await Future<void>.delayed(Duration(milliseconds: 100));
104 - print('after timeout');
105 - final biometricAuth = BiometricAuth();
106 - final isAuth = await biometricAuth.isAuthenticated();
107 -
108 - if (isAuth) {
109 - widget.authViewModel.biometricAuth();
110 - _key.currentState.showSnackBar(
111 - SnackBar(
112 - content: Text(S.of(context).authenticated),
113 - backgroundColor: Colors.green,
114 - ),
115 - );
116 - }
101 + await widget.authViewModel.biometricAuth();
102 });
103 }
104
@@ -133,34 +118,28 @@ class AuthPageState extends State<AuthPage> {
118
119 @override
120 Widget build(BuildContext context) {
136 - print('start');
137 -
121 return Scaffold(
122 key: _key,
123 appBar: CupertinoNavigationBar(
141 - leading: widget.closable
142 - ? SizedBox(
143 - height: 37,
144 - width: 20,
145 - child: ButtonTheme(
146 - minWidth: double.minPositive,
147 - child: FlatButton(
148 - highlightColor: Colors.transparent,
149 - splashColor: Colors.transparent,
150 - padding: EdgeInsets.all(0),
151 - onPressed: () => Navigator.of(context).pop(),
152 - child: _backArrowImageDarkTheme),
153 - ),
154 - )
155 - : Container(),
156 - backgroundColor: Theme.of(context).backgroundColor,
157 - border: null,
158 - ),
124 + leading: widget.closable
125 + ? SizedBox(
126 + height: 37,
127 + width: 20,
128 + child: ButtonTheme(
129 + minWidth: double.minPositive,
130 + child: FlatButton(
131 + highlightColor: Colors.transparent,
132 + splashColor: Colors.transparent,
133 + padding: EdgeInsets.all(0),
134 + onPressed: () => Navigator.of(context).pop(),
135 + child: _backArrowImageDarkTheme),
136 + ),
137 + )
138 + : Container(),
139 + backgroundColor: Theme.of(context).backgroundColor,
140 + border: null),
141 resizeToAvoidBottomPadding: false,
160 - body: PinCode(
161 - (pin, _) => widget.authViewModel
162 - .auth(password: pin.fold('', (ac, val) => ac + '$val')),
163 - false,
164 - _pinCodeKey));
142 + body: PinCode((pin, _) => widget.authViewModel.auth(password: pin),
143 + (_) => null, widget.authViewModel.pinLength, false, _pinCodeKey));
144 }
145 }
lib/src/screens/auth/create_login_page.dart deleted
-29
@@ -1,29 +0,0 @@
1 -import 'package:flutter/material.dart';
2 -import 'package:provider/provider.dart';
3 -import 'package:shared_preferences/shared_preferences.dart';
4 -import 'package:cake_wallet/src/domain/services/user_service.dart';
5 -import 'package:cake_wallet/src/domain/services/wallet_list_service.dart';
6 -import 'package:cake_wallet/src/domain/services/wallet_service.dart';
7 -import 'package:cake_wallet/src/screens/auth/auth_page.dart';
8 -import 'package:cake_wallet/src/stores/auth/auth_store.dart';
9 -import 'package:cake_wallet/src/stores/authentication/authentication_store.dart';
10 -
11 -Widget createLoginPage(
12 - {@required SharedPreferences sharedPreferences,
13 - @required UserService userService,
14 - @required WalletService walletService,
15 - @required WalletListService walletListService,
16 - @required AuthenticationStore authenticationStore}) =>
17 - null;
18 -// Provider(
19 -// create: (_) => AuthStore(
20 -// sharedPreferences: sharedPreferences,
21 -// userService: userService,
22 -// walletService: walletService),
23 -// child: AuthPage(
24 -// onAuthenticationFinished: (isAuthenticated, state) {
25 -// if (isAuthenticated) {
26 -// authenticationStore.loggedIn();
27 -// }
28 -// },
29 -// closable: false));
lib/src/screens/auth/create_unlock_page.dart deleted
-24
@@ -1,24 +0,0 @@
1 -import 'package:flutter/material.dart';
2 -import 'package:provider/provider.dart';
3 -import 'package:shared_preferences/shared_preferences.dart';
4 -import 'package:cake_wallet/src/domain/services/user_service.dart';
5 -import 'package:cake_wallet/src/domain/services/wallet_service.dart';
6 -import 'package:cake_wallet/src/screens/auth/auth_page.dart';
7 -import 'package:cake_wallet/src/stores/auth/auth_store.dart';
8 -
9 -Widget createUnlockPage(
10 - {@required SharedPreferences sharedPreferences,
11 - @required UserService userService,
12 - @required WalletService walletService,
13 - @required Function(bool, AuthPageState) onAuthenticationFinished}) =>
14 - null;
15 -// WillPopScope(
16 -// onWillPop: () async => false,
17 -// child: Provider(
18 -// create: (_) => AuthStore(
19 -// sharedPreferences: sharedPreferences,
20 -// userService: userService,
21 -// walletService: walletService),
22 -// child: AuthPage(
23 -// onAuthenticationFinished: onAuthenticationFinished,
24 -// closable: false)));
\ No newline at end of file
lib/src/screens/base_page.dart
+3 -3
@@ -94,8 +94,8 @@ abstract class BasePage extends StatelessWidget {
94 leading: leading(context),
95 middle: middle(context),
96 trailing: trailing(context),
97 - backgroundColor:
98 - _isDarkTheme ? backgroundDarkColor : backgroundLightColor);
97 + backgroundColor: Colors.transparent);
98 + // _isDarkTheme ? backgroundDarkColor : backgroundLightColor);
99
100 case AppBarStyle.withShadow:
101 return NavBar.withShadow(
@@ -131,7 +131,7 @@ abstract class BasePage extends StatelessWidget {
131 resizeToAvoidBottomPadding: resizeToAvoidBottomPadding,
132 endDrawer: endDrawer,
133 appBar: appBar(context),
134 - body: body(context), //SafeArea(child: ),
134 + body: body(context),
135 floatingActionButton: floatingActionButton(context));
136
137 return rootWrapper?.call(context, root) ?? root;
lib/src/screens/contact/contact_list_page.dart
+1 -1
@@ -5,7 +5,7 @@ import 'package:flutter_mobx/flutter_mobx.dart';
5 import 'package:flutter_slidable/flutter_slidable.dart';
6 import 'package:cake_wallet/routes.dart';
7 import 'package:cake_wallet/generated/i18n.dart';
8 -import 'package:cake_wallet/src/domain/common/crypto_currency.dart';
8 +import 'package:cake_wallet/entities/crypto_currency.dart';
9 import 'package:cake_wallet/src/screens/base_page.dart';
10 import 'package:cake_wallet/src/widgets/alert_with_two_actions.dart';
11 import 'package:cake_wallet/view_model/contact_list/contact_list_view_model.dart';
lib/src/screens/contact/contact_page.dart
+5 -5
@@ -6,9 +6,9 @@ import 'package:mobx/mobx.dart';
6 import 'package:cake_wallet/generated/i18n.dart';
7 import 'package:cake_wallet/core/address_validator.dart';
8 import 'package:cake_wallet/core/contact_name_validator.dart';
9 +import 'package:cake_wallet/core/execution_state.dart';
10 import 'package:cake_wallet/view_model/contact_list/contact_view_model.dart';
10 -import 'package:cake_wallet/view_model/contact_list/contact_view_model_state.dart';
11 -import 'package:cake_wallet/src/domain/common/crypto_currency.dart';
11 +import 'package:cake_wallet/entities/crypto_currency.dart';
12 import 'package:cake_wallet/src/screens/base_page.dart';
13 import 'package:cake_wallet/src/widgets/alert_with_one_action.dart';
14 import 'package:cake_wallet/src/widgets/primary_button.dart';
@@ -48,12 +48,12 @@ class ContactPage extends BasePage {
48 final downArrow = Image.asset('assets/images/arrow_bottom_purple_icon.png',
49 color: Theme.of(context).primaryTextTheme.overline.color, height: 8);
50
51 - reaction((_) => contactViewModel.state, (ContactViewModelState state) {
52 - if (state is ContactCreationFailure) {
51 + reaction((_) => contactViewModel.state, (ExecutionState state) {
52 + if (state is FailureState) {
53 _onContactSavingFailure(context, state.error);
54 }
55
56 - if (state is ContactSavingSuccessfully) {
56 + if (state is ExecutedSuccessfullyState) {
57 _onContactSavedSuccessfully(context);
58 }
59 });
lib/src/screens/dashboard/create_dashboard_page.dart
+29 -27
@@ -1,31 +1,33 @@
1 import 'package:flutter/material.dart';
2 import 'package:hive/hive.dart';
3 import 'package:provider/provider.dart';
4 -import 'package:cake_wallet/src/domain/exchange/trade.dart';
5 -import 'package:cake_wallet/src/domain/monero/transaction_description.dart';
6 -import 'package:cake_wallet/src/domain/services/wallet_service.dart';
7 -import 'package:cake_wallet/src/screens/dashboard/dashboard_page.dart';
8 -import 'package:cake_wallet/src/stores/action_list/action_list_store.dart';
9 -import 'package:cake_wallet/src/stores/action_list/trade_filter_store.dart';
10 -import 'package:cake_wallet/src/stores/action_list/transaction_filter_store.dart';
11 -import 'package:cake_wallet/src/stores/price/price_store.dart';
12 -import 'package:cake_wallet/src/stores/settings/settings_store.dart';
13 -import 'package:cake_wallet/src/stores/wallet/wallet_store.dart';
4 +import 'package:cake_wallet/exchange/trade.dart';
5 +// import 'package:cake_wallet/monero/transaction_description.dart';
6 +// import 'package:cake_wallet/src/domain/services/wallet_service.dart';
7 +// import 'package:cake_wallet/src/screens/dashboard/dashboard_page.dart';
8 +// import 'package:cake_wallet/src/stores/action_list/action_list_store.dart';
9 +// import 'package:cake_wallet/src/stores/action_list/trade_filter_store.dart';
10 +// import 'package:cake_wallet/src/stores/action_list/transaction_filter_store.dart';
11 +// import 'package:cake_wallet/src/stores/price/price_store.dart';
12 +// import 'package:cake_wallet/src/stores/settings/settings_store.dart';
13 +// import 'package:cake_wallet/src/stores/wallet/wallet_store.dart';
14
15 -Widget createDashboardPage(
16 - {@required WalletService walletService,
17 - @required PriceStore priceStore,
18 - @required Box<TransactionDescription> transactionDescriptions,
19 - @required SettingsStore settingsStore,
20 - @required Box<Trade> trades,
21 - @required WalletStore walletStore}) =>
22 - Provider(
23 - create: (_) => ActionListStore(
24 - walletService: walletService,
25 - settingsStore: settingsStore,
26 - priceStore: priceStore,
27 - tradesSource: trades,
28 - transactionFilterStore: TransactionFilterStore(),
29 - tradeFilterStore: TradeFilterStore(walletStore: walletStore),
30 - transactionDescriptions: transactionDescriptions),
31 - child: DashboardPage());
15 +// FIXME: Remove me.
16 +
17 +// Widget createDashboardPage(
18 +// {@required WalletService walletService,
19 +// @required PriceStore priceStore,
20 +// @required Box<TransactionDescription> transactionDescriptions,
21 +// @required SettingsStore settingsStore,
22 +// @required Box<Trade> trades,
23 +// @required WalletStore walletStore}) =>
24 +// Provider(
25 +// create: (_) => ActionListStore(
26 +// walletService: walletService,
27 +// settingsStore: settingsStore,
28 +// priceStore: priceStore,
29 +// tradesSource: trades,
30 +// transactionFilterStore: TransactionFilterStore(),
31 +// tradeFilterStore: TradeFilterStore(walletStore: walletStore),
32 +// transactionDescriptions: transactionDescriptions),
33 +// child: DashboardPage());
lib/src/screens/dashboard/wallet_menu.dart
-1
@@ -2,7 +2,6 @@ import 'package:flutter/material.dart';
2 import 'package:cake_wallet/routes.dart';
3 import 'package:provider/provider.dart';
4 import 'package:cake_wallet/generated/i18n.dart';
5 -import 'package:cake_wallet/src/stores/wallet/wallet_store.dart';
5 import 'package:cake_wallet/src/screens/auth/auth_page.dart';
6 import 'package:cake_wallet/src/widgets/alert_with_two_actions.dart';
7
lib/src/screens/dashboard/widgets/date_section_raw.dart
+11 -18
@@ -1,26 +1,21 @@
1 import 'package:flutter/material.dart';
2 import 'package:intl/intl.dart';
3 import 'package:cake_wallet/generated/i18n.dart';
4 -import 'package:provider/provider.dart';
5 -import 'package:cake_wallet/src/stores/settings/settings_store.dart';
4 +import 'package:cake_wallet/utils/date_formatter.dart';
5
6 class DateSectionRaw extends StatelessWidget {
7 DateSectionRaw({this.date});
8
10 - static final nowDate = DateTime.now();
9 final DateTime date;
10
11 @override
12 Widget build(BuildContext context) {
13 + final nowDate = DateTime.now();
14 final diffDays = date.difference(nowDate).inDays;
15 final isToday = nowDate.day == date.day &&
16 nowDate.month == date.month &&
17 nowDate.year == date.year;
19 - final settingsStore = Provider.of<SettingsStore>(context);
20 - final currentLanguage = settingsStore.languageCode;
21 - final dateSectionDateFormat = settingsStore.getCurrentDateFormat(
22 - formatUSA: "yyyy MMM d",
23 - formatDefault: "d MMM yyyy");
18 + final dateSectionDateFormat = DateFormatter.withCurrentLocal();
19 var title = "";
20
21 if (isToday) {
@@ -28,21 +23,19 @@ class DateSectionRaw extends StatelessWidget {
23 } else if (diffDays == 0) {
24 title = S.of(context).yesterday;
25 } else if (diffDays > -7 && diffDays < 0) {
31 - final dateFormat = DateFormat.EEEE(currentLanguage);
26 + final dateFormat = DateFormat.EEEE();
27 title = dateFormat.format(date);
28 } else {
29 title = dateSectionDateFormat.format(date);
30 }
31
32 return Container(
38 - height: 35,
39 - alignment: Alignment.center,
40 - color: Colors.transparent,
41 - child: Text(title,
42 - style: TextStyle(
43 - fontSize: 12,
44 - color: Theme.of(context).textTheme.overline.backgroundColor
45 - ))
46 - );
33 + height: 35,
34 + alignment: Alignment.center,
35 + color: Colors.transparent,
36 + child: Text(title,
37 + style: TextStyle(
38 + fontSize: 12,
39 + color: Theme.of(context).textTheme.overline.backgroundColor)));
40 }
41 }
lib/src/screens/dashboard/widgets/menu_widget.dart
+1 -1
@@ -2,7 +2,7 @@ import 'dart:ui';
2 import 'package:flutter/material.dart';
3 import 'package:cake_wallet/palette.dart';
4 import 'package:cake_wallet/view_model/dashboard/dashboard_view_model.dart';
5 -import 'package:cake_wallet/src/domain/common/wallet_type.dart';
5 +import 'package:cake_wallet/entities/wallet_type.dart';
6 import 'package:cake_wallet/src/screens/dashboard/wallet_menu.dart';
7 import 'package:flutter/rendering.dart';
8
lib/src/screens/dashboard/widgets/sync_indicator.dart
+1 -1
@@ -2,7 +2,7 @@ import 'package:flutter/material.dart';
2 import 'package:cake_wallet/view_model/dashboard/dashboard_view_model.dart';
3 import 'package:cake_wallet/palette.dart';
4 import 'package:flutter_mobx/flutter_mobx.dart';
5 -import 'package:cake_wallet/src/domain/common/sync_status.dart';
5 +import 'package:cake_wallet/entities/sync_status.dart';
6
7 class SyncIndicator extends StatelessWidget {
8 SyncIndicator({@required this.dashboardViewModel});
lib/src/screens/dashboard/widgets/trade_row.dart
+2 -2
@@ -1,6 +1,6 @@
1 import 'package:flutter/material.dart';
2 -import 'package:cake_wallet/src/domain/common/crypto_currency.dart';
3 -import 'package:cake_wallet/src/domain/exchange/exchange_provider_description.dart';
2 +import 'package:cake_wallet/entities/crypto_currency.dart';
3 +import 'package:cake_wallet/exchange/exchange_provider_description.dart';
4
5 class TradeRow extends StatelessWidget {
6 TradeRow({
lib/src/screens/dashboard/widgets/transaction_raw.dart
+1 -1
@@ -1,5 +1,5 @@
1 import 'package:flutter/material.dart';
2 -import 'package:cake_wallet/src/domain/common/transaction_direction.dart';
2 +import 'package:cake_wallet/entities/transaction_direction.dart';
3 import 'package:cake_wallet/generated/i18n.dart';
4
5 class TransactionRow extends StatelessWidget {
lib/src/screens/exchange/widgets/base_exchange_widget.dart
+66 -59
@@ -1,5 +1,5 @@
1 import 'dart:ui';
2 -import 'package:cake_wallet/src/domain/exchange/exchange_template.dart';
2 +import 'package:cake_wallet/exchange/exchange_template.dart';
3 import 'package:cake_wallet/src/widgets/alert_with_two_actions.dart';
4 import 'package:cake_wallet/src/widgets/template_tile.dart';
5 import 'package:dotted_border/dotted_border.dart';
@@ -9,10 +9,10 @@ import 'package:flutter_mobx/flutter_mobx.dart';
9 import 'package:mobx/mobx.dart';
10 import 'package:cake_wallet/routes.dart';
11 import 'package:cake_wallet/generated/i18n.dart';
12 -import 'package:cake_wallet/src/domain/common/crypto_currency.dart';
13 -import 'package:cake_wallet/src/domain/exchange/xmrto/xmrto_exchange_provider.dart';
14 -import 'package:cake_wallet/src/stores/exchange/exchange_trade_state.dart';
15 -import 'package:cake_wallet/src/stores/exchange/limits_state.dart';
12 +import 'package:cake_wallet/entities/crypto_currency.dart';
13 +import 'package:cake_wallet/exchange/xmrto/xmrto_exchange_provider.dart';
14 +// import 'package:cake_wallet/exchange/exchange_trade_state.dart';
15 +// import 'package:cake_wallet/exchange/limits_state.dart';
16 import 'package:cake_wallet/src/screens/exchange/widgets/exchange_card.dart';
17 import 'package:cake_wallet/src/widgets/primary_button.dart';
18 import 'package:cake_wallet/src/widgets/scollable_with_bottom_section.dart';
@@ -376,7 +376,7 @@ class BaseExchangeWidgetState extends State<BaseExchangeWidget> {
376 },
377 color: Theme.of(context).accentTextTheme.body2.color,
378 textColor: Colors.white,
379 - isLoading: exchangeViewModel.tradeState is TradeIsCreating,
379 + isLoading: false, // FIXME: FIXME exchangeViewModel.tradeState is TradeIsCreating,
380 )),
381 ]),
382 ));
@@ -419,18 +419,21 @@ class BaseExchangeWidgetState extends State<BaseExchangeWidget> {
419 final depositAmountController = depositKey.currentState.amountController;
420 final receiveAddressController = receiveKey.currentState.addressController;
421 final receiveAmountController = receiveKey.currentState.amountController;
422 - final limitsState = exchangeViewModel.limitsState;
423 -
424 - if (limitsState is LimitsLoadedSuccessfully) {
425 - final min = limitsState.limits.min != null
426 - ? limitsState.limits.min.toString()
427 - : null;
428 - final max = limitsState.limits.max != null
429 - ? limitsState.limits.max.toString()
430 - : null;
431 - final key = depositKey;
432 - key.currentState.changeLimits(min: min, max: max);
433 - }
422 +
423 + // FIXME: FIXME
424 +
425 + // final limitsState = exchangeViewModel.limitsState;
426 + //
427 + // if (limitsState is LimitsLoadedSuccessfully) {
428 + // final min = limitsState.limits.min != null
429 + // ? limitsState.limits.min.toString()
430 + // : null;
431 + // final max = limitsState.limits.max != null
432 + // ? limitsState.limits.max.toString()
433 + // : null;
434 + // final key = depositKey;
435 + // key.currentState.changeLimits(min: min, max: max);
436 + // }
437
438 _onCurrencyChange(
439 exchangeViewModel.receiveCurrency, exchangeViewModel, receiveKey);
@@ -491,47 +494,51 @@ class BaseExchangeWidgetState extends State<BaseExchangeWidget> {
494 receiveKey.currentState.isAddressEditable(isEditable: isEnabled);
495 });
496
494 - reaction((_) => exchangeViewModel.tradeState, (ExchangeTradeState state) {
495 - if (state is TradeIsCreatedFailure) {
496 - WidgetsBinding.instance.addPostFrameCallback((_) {
497 - showDialog<void>(
498 - context: context,
499 - builder: (BuildContext context) {
500 - return AlertWithOneAction(
501 - alertTitle: S.of(context).error,
502 - alertContent: state.error,
503 - buttonText: S.of(context).ok,
504 - buttonAction: () => Navigator.of(context).pop());
505 - });
506 - });
507 - }
508 - if (state is TradeIsCreatedSuccessfully) {
509 - Navigator.of(context).pushNamed(Routes.exchangeConfirm);
510 - }
511 - });
512 -
513 - reaction((_) => exchangeViewModel.limitsState, (LimitsState state) {
514 - String min;
515 - String max;
516 -
517 - if (state is LimitsLoadedSuccessfully) {
518 - min = state.limits.min != null ? state.limits.min.toString() : null;
519 - max = state.limits.max != null ? state.limits.max.toString() : null;
520 - }
521 -
522 - if (state is LimitsLoadedFailure) {
523 - min = '0';
524 - max = '0';
525 - }
526 -
527 - if (state is LimitsIsLoading) {
528 - min = '...';
529 - max = '...';
530 - }
531 -
532 - depositKey.currentState.changeLimits(min: min, max: max);
533 - receiveKey.currentState.changeLimits(min: null, max: null);
534 - });
497 + // FIXME: FIXME
498 +
499 + // reaction((_) => exchangeViewModel.tradeState, (ExchangeTradeState state) {
500 + // if (state is TradeIsCreatedFailure) {
501 + // WidgetsBinding.instance.addPostFrameCallback((_) {
502 + // showDialog<void>(
503 + // context: context,
504 + // builder: (BuildContext context) {
505 + // return AlertWithOneAction(
506 + // alertTitle: S.of(context).error,
507 + // alertContent: state.error,
508 + // buttonText: S.of(context).ok,
509 + // buttonAction: () => Navigator.of(context).pop());
510 + // });
511 + // });
512 + // }
513 + // if (state is TradeIsCreatedSuccessfully) {
514 + // Navigator.of(context).pushNamed(Routes.exchangeConfirm);
515 + // }
516 + // });
517 +
518 + // FIXME: FIXME
519 +
520 + // reaction((_) => exchangeViewModel.limitsState, (LimitsState state) {
521 + // String min;
522 + // String max;
523 + //
524 + // if (state is LimitsLoadedSuccessfully) {
525 + // min = state.limits.min != null ? state.limits.min.toString() : null;
526 + // max = state.limits.max != null ? state.limits.max.toString() : null;
527 + // }
528 + //
529 + // if (state is LimitsLoadedFailure) {
530 + // min = '0';
531 + // max = '0';
532 + // }
533 + //
534 + // if (state is LimitsIsLoading) {
535 + // min = '...';
536 + // max = '...';
537 + // }
538 + //
539 + // depositKey.currentState.changeLimits(min: min, max: max);
540 + // receiveKey.currentState.changeLimits(min: null, max: null);
541 + // });
542
543 depositAddressController.addListener(
544 () => exchangeViewModel.depositAddress = depositAddressController.text);
lib/src/screens/exchange/widgets/currency_picker.dart
+1 -1
@@ -2,7 +2,7 @@ import 'dart:ui';
2 import 'package:cake_wallet/palette.dart';
3 import 'package:flutter/cupertino.dart';
4 import 'package:flutter/material.dart';
5 -import 'package:cake_wallet/src/domain/common/crypto_currency.dart';
5 +import 'package:cake_wallet/entities/crypto_currency.dart';
6 import 'package:cake_wallet/src/widgets/alert_background.dart';
7 import 'package:cake_wallet/src/widgets/alert_close_button.dart';
8
lib/src/screens/exchange/widgets/exchange_card.dart
+1 -1
@@ -1,7 +1,7 @@
1 import 'package:flutter/services.dart';
2 import 'package:flutter/material.dart';
3 import 'package:cake_wallet/generated/i18n.dart';
4 -import 'package:cake_wallet/src/domain/common/crypto_currency.dart';
4 +import 'package:cake_wallet/entities/crypto_currency.dart';
5 import 'package:cake_wallet/src/widgets/address_text_field.dart';
6 import 'package:cake_wallet/src/widgets/base_text_form_field.dart';
7 import 'package:cake_wallet/src/screens/exchange/widgets/currency_picker.dart';
lib/src/screens/exchange/widgets/present_provider_picker.dart
+2 -2
@@ -1,6 +1,6 @@
1 import 'package:flutter/material.dart';
2 -import 'package:cake_wallet/src/domain/exchange/exchange_provider_description.dart';
3 -import 'package:cake_wallet/src/domain/exchange/exchange_provider.dart';
2 +import 'package:cake_wallet/exchange/exchange_provider_description.dart';
3 +import 'package:cake_wallet/exchange/exchange_provider.dart';
4 import 'package:flutter_mobx/flutter_mobx.dart';
5 import 'package:cake_wallet/generated/i18n.dart';
6 import 'package:cake_wallet/src/widgets/picker.dart';
lib/src/screens/exchange_trade/exchange_confirm_page.dart
+1 -1
@@ -6,7 +6,7 @@ import 'package:cake_wallet/routes.dart';
6 import 'package:cake_wallet/generated/i18n.dart';
7 import 'package:cake_wallet/src/widgets/primary_button.dart';
8 import 'package:cake_wallet/src/screens/base_page.dart';
9 -import 'package:cake_wallet/src/domain/exchange/trade.dart';
9 +import 'package:cake_wallet/exchange/trade.dart';
10
11 class ExchangeConfirmPage extends BasePage {
12 ExchangeConfirmPage({@required this.tradesStore}) : trade = tradesStore.trade;
lib/src/screens/exchange_trade/exchange_trade_page.dart
+6 -6
@@ -1,6 +1,6 @@
1 import 'package:cake_wallet/palette.dart';
2 -import 'package:cake_wallet/src/domain/common/crypto_currency.dart';
3 -import 'package:cake_wallet/src/domain/exchange/exchange_provider_description.dart';
2 +import 'package:cake_wallet/entities/crypto_currency.dart';
3 +import 'package:cake_wallet/exchange/exchange_provider_description.dart';
4 import 'package:cake_wallet/src/screens/exchange_trade/exchange_trade_item.dart';
5 import 'package:cake_wallet/src/screens/exchange_trade/information_page.dart';
6 import 'package:cake_wallet/src/widgets/standart_list_row.dart';
@@ -12,10 +12,10 @@ import 'package:flutter/material.dart';
12 import 'package:flutter/cupertino.dart';
13 import 'package:flutter/services.dart';
14 import 'package:cake_wallet/generated/i18n.dart';
15 -import 'package:cake_wallet/src/stores/exchange_trade/exchange_trade_store.dart';
16 -import 'package:cake_wallet/src/stores/send/send_store.dart';
17 -import 'package:cake_wallet/src/stores/send/sending_state.dart';
18 -import 'package:cake_wallet/src/stores/wallet/wallet_store.dart';
15 +// import 'package:cake_wallet/src/stores/exchange_trade/exchange_trade_store.dart';
16 +// import 'package:cake_wallet/src/stores/send/send_store.dart';
17 +// import 'package:cake_wallet/src/stores/send/sending_state.dart';
18 +// import 'package:cake_wallet/src/stores/wallet/wallet_store.dart';
19 import 'package:cake_wallet/src/screens/receive/widgets/qr_image.dart';
20 import 'package:cake_wallet/src/screens/base_page.dart';
21 import 'package:cake_wallet/src/screens/exchange_trade/widgets/timer_widget.dart';
lib/src/screens/faq/faq_page.dart
+33 -31
@@ -5,7 +5,7 @@ import 'package:flutter/material.dart';
5 import 'package:flutter/services.dart';
6 import 'package:provider/provider.dart';
7 import 'package:cake_wallet/generated/i18n.dart';
8 -import 'package:cake_wallet/src/stores/settings/settings_store.dart';
8 +import 'package:cake_wallet/store/settings_store.dart';
9 import 'package:cake_wallet/src/screens/base_page.dart';
10
11 class FaqPage extends BasePage {
@@ -124,35 +124,37 @@ class FaqFormState extends State<FaqForm> {
124 }
125
126 String getFaqPath(BuildContext context) {
127 - final settingsStore = Provider.of<SettingsStore>(context);
128 -
129 - switch (settingsStore.languageCode) {
130 - case 'en':
131 - return 'assets/faq/faq_en.json';
132 - case 'uk':
133 - return 'assets/faq/faq_uk.json';
134 - case 'ru':
135 - return 'assets/faq/faq_ru.json';
136 - case 'es':
137 - return 'assets/faq/faq_es.json';
138 - case 'ja':
139 - return 'assets/faq/faq_ja.json';
140 - case 'ko':
141 - return 'assets/faq/faq_ko.json';
142 - case 'hi':
143 - return 'assets/faq/faq_hi.json';
144 - case 'de':
145 - return 'assets/faq/faq_de.json';
146 - case 'zh':
147 - return 'assets/faq/faq_zh.json';
148 - case 'pt':
149 - return 'assets/faq/faq_pt.json';
150 - case 'pl':
151 - return 'assets/faq/faq_pl.json';
152 - case 'nl':
153 - return 'assets/faq/faq_nl.json';
154 - default:
155 - return 'assets/faq/faq_en.json';
156 - }
127 + // FIXME: FIXME
128 + // final settingsStore = Provider.of<SettingsStore>(context);
129 + //
130 + // switch (settingsStore.languageCode) {
131 + // case 'en':
132 + // return 'assets/faq/faq_en.json';
133 + // case 'uk':
134 + // return 'assets/faq/faq_uk.json';
135 + // case 'ru':
136 + // return 'assets/faq/faq_ru.json';
137 + // case 'es':
138 + // return 'assets/faq/faq_es.json';
139 + // case 'ja':
140 + // return 'assets/faq/faq_ja.json';
141 + // case 'ko':
142 + // return 'assets/faq/faq_ko.json';
143 + // case 'hi':
144 + // return 'assets/faq/faq_hi.json';
145 + // case 'de':
146 + // return 'assets/faq/faq_de.json';
147 + // case 'zh':
148 + // return 'assets/faq/faq_zh.json';
149 + // case 'pt':
150 + // return 'assets/faq/faq_pt.json';
151 + // case 'pl':
152 + // return 'assets/faq/faq_pl.json';
153 + // case 'nl':
154 + // return 'assets/faq/faq_nl.json';
155 + // default:
156 + // return 'assets/faq/faq_en.json';
157 + // }
158 + return '';
159 }
160 }
\ No newline at end of file
lib/src/screens/monero_accounts/monero_account_edit_or_create_page.dart
+2 -2
@@ -1,9 +1,9 @@
1 +import 'package:cake_wallet/core/execution_state.dart';
2 import 'package:flutter/material.dart';
3 import 'package:flutter/cupertino.dart';
4 import 'package:flutter_mobx/flutter_mobx.dart';
5 import 'package:cake_wallet/generated/i18n.dart';
6 import 'package:cake_wallet/core/monero_account_label_validator.dart';
6 -import 'package:cake_wallet/view_model/monero_account_list/monero_account_edit_or_create_state.dart';
7 import 'package:cake_wallet/view_model/monero_account_list/monero_account_edit_or_create_view_model.dart';
8 import 'package:cake_wallet/src/widgets/primary_button.dart';
9 import 'package:cake_wallet/src/screens/base_page.dart';
@@ -59,7 +59,7 @@ class MoneroAccountEditOrCreatePage extends BasePage {
59 color: Colors.green,
60 textColor: Colors.white,
61 isLoading: moneroAccountCreationViewModel.state
62 - is AccountIsCreating,
62 + is IsExecutingState,
63 isDisabled:
64 moneroAccountCreationViewModel.label?.isEmpty ?? true,
65 ))
lib/src/screens/new_wallet/new_wallet_page.dart
+10 -8
@@ -13,7 +13,7 @@ import 'package:cake_wallet/src/widgets/primary_button.dart';
13 import 'package:cake_wallet/src/widgets/scollable_with_bottom_section.dart';
14 import 'package:cake_wallet/src/screens/seed_language/widgets/seed_language_picker.dart';
15 import 'package:cake_wallet/src/widgets/alert_with_one_action.dart';
16 -import 'package:cake_wallet/view_model/wallet_creation_state.dart';
16 +import 'package:cake_wallet/core/execution_state.dart';
17 import 'package:cake_wallet/view_model/wallet_new_vm.dart';
18
19 class NewWalletPage extends BasePage {
@@ -43,7 +43,8 @@ class _WalletNameFormState extends State<WalletNameForm> {
43 static const aspectRatioImage = 1.22;
44
45 final walletNameImage = Image.asset('assets/images/wallet_name.png');
46 - final walletNameLightImage = Image.asset('assets/images/wallet_name_light.png');
46 + final walletNameLightImage =
47 + Image.asset('assets/images/wallet_name_light.png');
48 final _formKey = GlobalKey<FormState>();
49 final _languageSelectorKey = GlobalKey<SeedLanguageSelectorState>();
50 ReactionDisposer _stateReaction;
@@ -52,12 +53,12 @@ class _WalletNameFormState extends State<WalletNameForm> {
53 @override
54 void initState() {
55 _stateReaction ??=
55 - reaction((_) => _walletNewVM.state, (WalletCreationState state) {
56 - if (state is WalletCreatedSuccessfully) {
57 - Navigator.of(context).popAndPushNamed(Routes.seed, arguments: true);
56 + reaction((_) => _walletNewVM.state, (ExecutionState state) {
57 + if (state is ExecutedSuccessfullyState) {
58 + Navigator.of(context).pushNamed(Routes.seed, arguments: true);
59 }
60
60 - if (state is WalletCreationFailure) {
61 + if (state is FailureState) {
62 WidgetsBinding.instance.addPostFrameCallback((_) {
63 showDialog<void>(
64 context: context,
@@ -77,7 +78,8 @@ class _WalletNameFormState extends State<WalletNameForm> {
78 @override
79 Widget build(BuildContext context) {
80 final walletImage = getIt.get<SettingsStore>().isDarkTheme
80 - ? walletNameImage : walletNameLightImage;
81 + ? walletNameImage
82 + : walletNameLightImage;
83
84 return Container(
85 padding: EdgeInsets.only(top: 24),
@@ -158,7 +160,7 @@ class _WalletNameFormState extends State<WalletNameForm> {
160 text: S.of(context).seed_language_next,
161 color: Colors.green,
162 textColor: Colors.white,
161 - isLoading: _walletNewVM.state is WalletCreatedSuccessfully,
163 + isLoading: _walletNewVM.state is IsExecutingState,
164 isDisabled: _walletNewVM.name.isEmpty,
165 );
166 },
lib/src/screens/new_wallet/new_wallet_type_page.dart
+1 -1
@@ -1,5 +1,5 @@
1 import 'package:cake_wallet/di.dart';
2 -import 'package:cake_wallet/src/domain/common/wallet_type.dart';
2 +import 'package:cake_wallet/entities/wallet_type.dart';
3 import 'package:cake_wallet/store/settings_store.dart';
4 import 'package:flutter/material.dart';
5 import 'package:flutter/cupertino.dart';
lib/src/screens/pin_code/pin_code.dart
+12 -293
@@ -1,301 +1,20 @@
1 -import 'package:provider/provider.dart';
2 -import 'package:flutter/material.dart';
3 -import 'package:flutter/cupertino.dart';
4 -import 'package:cake_wallet/src/stores/settings/settings_store.dart';
5 -import 'package:cake_wallet/generated/i18n.dart';
6 -import 'package:cake_wallet/src/domain/common/biometric_auth.dart';
7 -
8 -abstract class PinCodeWidget extends StatefulWidget {
9 - PinCodeWidget({Key key, this.onPinCodeEntered, this.hasLengthSwitcher})
10 - : super(key: key);
11 -
12 - final Function(List<int> pin, PinCodeState state) onPinCodeEntered;
13 - final bool hasLengthSwitcher;
14 -}
1 +import 'package:flutter/foundation.dart';
2 +import 'package:cake_wallet/src/screens/pin_code/pin_code_widget.dart';
3
4 class PinCode extends PinCodeWidget {
17 - PinCode(Function(List<int> pin, PinCodeState state) onPinCodeEntered,
18 - bool hasLengthSwitcher, Key key)
5 + PinCode(
6 + void Function(String pin, PinCodeState state) onFullPin,
7 + void Function(String pin) onChangedPin,
8 + int initialPinLength,
9 + bool hasLengthSwitcher,
10 + Key key)
11 : super(
12 key: key,
21 - onPinCodeEntered: onPinCodeEntered,
22 - hasLengthSwitcher: hasLengthSwitcher);
13 + onFullPin: onFullPin,
14 + onChangedPin: onChangedPin,
15 + hasLengthSwitcher: hasLengthSwitcher,
16 + initialPinLength: initialPinLength);
17
18 @override
19 PinCodeState createState() => PinCodeState();
20 }
27 -
28 -class PinCodeState<T extends PinCodeWidget> extends State<T> {
29 - static const defaultPinLength = 4;
30 - static const sixPinLength = 6;
31 - static const fourPinLength = 4;
32 - final _gridViewKey = GlobalKey();
33 - final _key = GlobalKey<ScaffoldState>();
34 -
35 - int pinLength = defaultPinLength;
36 - List<int> pin = List<int>.filled(defaultPinLength, null);
37 - String title = S.current.enter_your_pin;
38 - double _aspectRatio = 0;
39 -
40 - void setTitle(String title) => setState(() => this.title = title);
41 -
42 - void clear() => setState(() => pin = List<int>.filled(pinLength, null));
43 -
44 - void onPinCodeEntered(PinCodeState state) =>
45 - widget.onPinCodeEntered(state.pin, this);
46 -
47 - void changePinLength(int length) {
48 - final newPin = List<int>.filled(length, null);
49 -
50 - setState(() {
51 - pinLength = length;
52 - pin = newPin;
53 - });
54 - }
55 -
56 - void setDefaultPinLength() {
57 - final settingsStore = Provider.of<SettingsStore>(context);
58 -
59 - pinLength = settingsStore.defaultPinLength;
60 - changePinLength(pinLength);
61 - }
62 -
63 - void calculateAspectRatio() {
64 - final renderBox =
65 - _gridViewKey.currentContext.findRenderObject() as RenderBox;
66 - final cellWidth = renderBox.size.width / 3;
67 - final cellHeight = renderBox.size.height / 4;
68 -
69 - if (cellWidth > 0 && cellHeight > 0) {
70 - _aspectRatio = cellWidth / cellHeight;
71 - }
72 -
73 - setState(() {});
74 - }
75 -
76 - @override
77 - void initState() {
78 - super.initState();
79 - WidgetsBinding.instance.addPostFrameCallback(afterLayout);
80 - }
81 -
82 - void afterLayout(dynamic _) {
83 - setDefaultPinLength();
84 - calculateAspectRatio();
85 - }
86 -
87 - @override
88 - Widget build(BuildContext context) =>
89 - Scaffold(key: _key, body: body(context));
90 -
91 - Widget body(BuildContext context) {
92 - final settingsStore = Provider.of<SettingsStore>(context);
93 -
94 - final deleteIconImage = Image.asset(
95 - 'assets/images/delete_icon.png',
96 - color: Theme.of(context).primaryTextTheme.title.color,
97 - );
98 - final faceImage = Image.asset(
99 - 'assets/images/face.png',
100 - color: Theme.of(context).primaryTextTheme.title.color,
101 - );
102 -
103 - return Container(
104 - color: Theme.of(context).backgroundColor,
105 - padding: EdgeInsets.only(left: 40.0, right: 40.0, bottom: 40.0),
106 - child: Column(children: <Widget>[
107 - Spacer(flex: 2),
108 - Text(title,
109 - style: TextStyle(
110 - fontSize: 20,
111 - fontWeight: FontWeight.w500,
112 - color: Theme.of(context).primaryTextTheme.title.color)),
113 - Spacer(flex: 3),
114 - Container(
115 - width: 180,
116 - child: Row(
117 - mainAxisAlignment: MainAxisAlignment.spaceBetween,
118 - children: List.generate(pinLength, (index) {
119 - const size = 10.0;
120 - final isFilled = pin[index] != null;
121 -
122 - return Container(
123 - width: size,
124 - height: size,
125 - decoration: BoxDecoration(
126 - shape: BoxShape.circle,
127 - color: isFilled
128 - ? Theme.of(context).primaryTextTheme.title.color
129 - : Theme.of(context)
130 - .accentTextTheme
131 - .body1
132 - .color
133 - .withOpacity(0.25),
134 - ));
135 - }),
136 - ),
137 - ),
138 - Spacer(flex: 2),
139 - if (widget.hasLengthSwitcher) ...[
140 - FlatButton(
141 - onPressed: () {
142 - changePinLength(pinLength == PinCodeState.fourPinLength
143 - ? PinCodeState.sixPinLength
144 - : PinCodeState.fourPinLength);
145 - },
146 - child: Text(
147 - _changePinLengthText(),
148 - style: TextStyle(
149 - fontSize: 14.0,
150 - fontWeight: FontWeight.normal,
151 - color: Theme.of(context)
152 - .accentTextTheme
153 - .body1
154 - .decorationColor),
155 - ))
156 - ],
157 - Spacer(flex: 1),
158 - Flexible(
159 - flex: 24,
160 - child: Container(
161 - key: _gridViewKey,
162 - child: _aspectRatio > 0
163 - ? GridView.count(
164 - shrinkWrap: true,
165 - crossAxisCount: 3,
166 - childAspectRatio: _aspectRatio,
167 - physics: const NeverScrollableScrollPhysics(),
168 - children: List.generate(12, (index) {
169 - const double marginRight = 15;
170 - const double marginLeft = 15;
171 -
172 - if (index == 9) {
173 - return Container(
174 - margin: EdgeInsets.only(
175 - left: marginLeft, right: marginRight),
176 - child: FlatButton(
177 - onPressed: (widget.hasLengthSwitcher ||
178 - !settingsStore
179 - .allowBiometricalAuthentication)
180 - ? null
181 - : () {
182 - // FIXME
183 -// if (authStore != null) {
184 -// WidgetsBinding.instance.addPostFrameCallback((_) {
185 -// final biometricAuth = BiometricAuth();
186 -// biometricAuth.isAuthenticated().then(
187 -// (isAuth) {
188 -// if (isAuth) {
189 -// authStore.biometricAuth();
190 -// _key.currentState.showSnackBar(
191 -// SnackBar(
192 -// content: Text(S.of(context).authenticated),
193 -// backgroundColor: Colors.green,
194 -// ),
195 -// );
196 -// }
197 -// }
198 -// );
199 -// });
200 -// }
201 - },
202 - color: Theme.of(context).backgroundColor,
203 - shape: CircleBorder(),
204 - child: (widget.hasLengthSwitcher ||
205 - !settingsStore
206 - .allowBiometricalAuthentication)
207 - ? Offstage()
208 - : faceImage,
209 - ),
210 - );
211 - } else if (index == 10) {
212 - index = 0;
213 - } else if (index == 11) {
214 - return Container(
215 - margin: EdgeInsets.only(
216 - left: marginLeft, right: marginRight),
217 - child: FlatButton(
218 - onPressed: () => _pop(),
219 - color: Theme.of(context).backgroundColor,
220 - shape: CircleBorder(),
221 - child: deleteIconImage,
222 - ),
223 - );
224 - } else {
225 - index++;
226 - }
227 -
228 - return Container(
229 - margin: EdgeInsets.only(
230 - left: marginLeft, right: marginRight),
231 - child: FlatButton(
232 - onPressed: () => _push(index),
233 - color: Theme.of(context).backgroundColor,
234 - shape: CircleBorder(),
235 - child: Text('$index',
236 - style: TextStyle(
237 - fontSize: 30.0,
238 - fontWeight: FontWeight.w600,
239 - color: Theme.of(context)
240 - .primaryTextTheme
241 - .title
242 - .color)),
243 - ),
244 - );
245 - }),
246 - )
247 - : null))
248 - ]),
249 - );
250 - }
251 -
252 - void _push(int num) {
253 - if (currentPinLength() >= pinLength) {
254 - return;
255 - }
256 -
257 - for (var i = 0; i < pin.length; i++) {
258 - if (pin[i] == null) {
259 - setState(() => pin[i] = num);
260 - break;
261 - }
262 - }
263 -
264 - final _currentPinLength = currentPinLength();
265 -
266 - if (_currentPinLength == pinLength) {
267 - onPinCodeEntered(this);
268 - }
269 - }
270 -
271 - void _pop() {
272 - if (currentPinLength() == 0) {
273 - return;
274 - }
275 -
276 - for (var i = pin.length - 1; i >= 0; i--) {
277 - if (pin[i] != null) {
278 - setState(() => pin[i] = null);
279 - break;
280 - }
281 - }
282 - }
283 -
284 - int currentPinLength() {
285 - return pin.fold(0, (v, e) {
286 - if (e != null) {
287 - return v + 1;
288 - }
289 -
290 - return v;
291 - });
292 - }
293 -
294 - String _changePinLengthText() {
295 - return S.current.use +
296 - (pinLength == PinCodeState.fourPinLength
297 - ? '${PinCodeState.sixPinLength}'
298 - : '${PinCodeState.fourPinLength}') +
299 - S.current.digit_pin;
300 - }
301 -}
lib/src/screens/pin_code/pin_code_widget.dart new
+284
@@ -0,0 +1,284 @@
1 +import 'package:flutter/material.dart';
2 +import 'package:flutter/cupertino.dart';
3 +import 'package:cake_wallet/generated/i18n.dart';
4 +
5 +class PinCodeWidget extends StatefulWidget {
6 + PinCodeWidget(
7 + {Key key,
8 + @required this.onFullPin,
9 + @required this.initialPinLength,
10 + this.onChangedPin,
11 + this.onChangedPinLength,
12 + this.hasLengthSwitcher})
13 + : super(key: key);
14 +
15 + final void Function(String pin, PinCodeState state) onFullPin;
16 + final void Function(String pin) onChangedPin;
17 + final void Function(int length) onChangedPinLength;
18 + final bool hasLengthSwitcher;
19 + final int initialPinLength;
20 +
21 + @override
22 + State<StatefulWidget> createState() => PinCodeState();
23 +}
24 +
25 +class PinCodeState<T extends PinCodeWidget> extends State<T> {
26 + static const defaultPinLength = fourPinLength;
27 + static const sixPinLength = 6;
28 + static const fourPinLength = 4;
29 + final _gridViewKey = GlobalKey();
30 + final _key = GlobalKey<ScaffoldState>();
31 +
32 + int pinLength;
33 + String pin;
34 + String title;
35 + double _aspectRatio;
36 +
37 + int currentPinLength() => pin.length;
38 +
39 + @override
40 + void initState() {
41 + super.initState();
42 + pinLength = widget.initialPinLength;
43 + pin = '';
44 + title = S.current.enter_your_pin;
45 + _aspectRatio = 0;
46 + WidgetsBinding.instance.addPostFrameCallback(_afterLayout);
47 + }
48 +
49 + void setTitle(String title) => setState(() => this.title = title);
50 +
51 + void clear() => setState(() => pin = '');
52 +
53 + void reset() => setState(() {
54 + pin = '';
55 + pinLength = widget.initialPinLength;
56 + title = S.current.enter_your_pin;
57 + });
58 +
59 + void changePinLength(int length) {
60 + setState(() {
61 + pinLength = length;
62 + pin = '';
63 + });
64 +
65 + widget.onChangedPinLength?.call(length);
66 + }
67 +
68 + void setDefaultPinLength() => changePinLength(widget.initialPinLength);
69 +
70 + void calculateAspectRatio() {
71 + final renderBox =
72 + _gridViewKey.currentContext.findRenderObject() as RenderBox;
73 + final cellWidth = renderBox.size.width / 3;
74 + final cellHeight = renderBox.size.height / 4;
75 +
76 + if (cellWidth > 0 && cellHeight > 0) {
77 + _aspectRatio = cellWidth / cellHeight;
78 + }
79 +
80 + setState(() {});
81 + }
82 +
83 + @override
84 + Widget build(BuildContext context) =>
85 + Scaffold(key: _key, body: body(context));
86 +
87 + Widget body(BuildContext context) {
88 + final deleteIconImage = Image.asset(
89 + 'assets/images/delete_icon.png',
90 + color: Theme.of(context).primaryTextTheme.title.color,
91 + );
92 + final faceImage = Image.asset(
93 + 'assets/images/face.png',
94 + color: Theme.of(context).primaryTextTheme.title.color,
95 + );
96 +
97 + return Container(
98 + color: Theme.of(context).backgroundColor,
99 + padding: EdgeInsets.only(left: 40.0, right: 40.0, bottom: 40.0),
100 + child: Column(children: <Widget>[
101 + Spacer(flex: 2),
102 + Text(title,
103 + style: TextStyle(
104 + fontSize: 20,
105 + fontWeight: FontWeight.w500,
106 + color: Theme.of(context).primaryTextTheme.title.color)),
107 + Spacer(flex: 3),
108 + Container(
109 + width: 180,
110 + child: Row(
111 + mainAxisAlignment: MainAxisAlignment.spaceBetween,
112 + children: List.generate(pinLength, (index) {
113 + const size = 10.0;
114 + final isFilled = pin.length > index ? pin[index] != null : false;
115 +
116 + return Container(
117 + width: size,
118 + height: size,
119 + decoration: BoxDecoration(
120 + shape: BoxShape.circle,
121 + color: isFilled
122 + ? Theme.of(context).primaryTextTheme.title.color
123 + : Theme.of(context)
124 + .accentTextTheme
125 + .body1
126 + .color
127 + .withOpacity(0.25),
128 + ));
129 + }),
130 + ),
131 + ),
132 + Spacer(flex: 2),
133 + if (widget.hasLengthSwitcher) ...[
134 + FlatButton(
135 + onPressed: () {
136 + changePinLength(pinLength == PinCodeState.fourPinLength
137 + ? PinCodeState.sixPinLength
138 + : PinCodeState.fourPinLength);
139 + },
140 + child: Text(
141 + _changePinLengthText(),
142 + style: TextStyle(
143 + fontSize: 14.0,
144 + fontWeight: FontWeight.normal,
145 + color: Theme.of(context)
146 + .accentTextTheme
147 + .body1
148 + .decorationColor),
149 + ))
150 + ],
151 + Spacer(flex: 1),
152 + Flexible(
153 + flex: 24,
154 + child: Container(
155 + key: _gridViewKey,
156 + child: _aspectRatio > 0
157 + ? GridView.count(
158 + shrinkWrap: true,
159 + crossAxisCount: 3,
160 + childAspectRatio: _aspectRatio,
161 + physics: const NeverScrollableScrollPhysics(),
162 + children: List.generate(12, (index) {
163 + const double marginRight = 15;
164 + const double marginLeft = 15;
165 +
166 + if (index == 9) {
167 + return Container(
168 + margin: EdgeInsets.only(
169 + left: marginLeft, right: marginRight),
170 + child: FlatButton(
171 + onPressed: () => null,
172 + // (widget.hasLengthSwitcher ||
173 + // !settingsStore
174 + // .allowBiometricalAuthentication)
175 + // ? null
176 + // : () {
177 + // FIXME
178 +// if (authStore != null) {
179 +// WidgetsBinding.instance.addPostFrameCallback((_) {
180 +// final biometricAuth = BiometricAuth();
181 +// biometricAuth.isAuthenticated().then(
182 +// (isAuth) {
183 +// if (isAuth) {
184 +// authStore.biometricAuth();
185 +// _key.currentState.showSnackBar(
186 +// SnackBar(
187 +// content: Text(S.of(context).authenticated),
188 +// backgroundColor: Colors.green,
189 +// ),
190 +// );
191 +// }
192 +// }
193 +// );
194 +// });
195 +// }
196 +// },
197 + color: Theme.of(context).backgroundColor,
198 + shape: CircleBorder(),
199 + child: null
200 + // (widget.hasLengthSwitcher ||
201 + // !settingsStore
202 + // .allowBiometricalAuthentication)
203 + // ? Offstage()
204 + // : faceImage,
205 + ),
206 + );
207 + } else if (index == 10) {
208 + index = 0;
209 + } else if (index == 11) {
210 + return Container(
211 + margin: EdgeInsets.only(
212 + left: marginLeft, right: marginRight),
213 + child: FlatButton(
214 + onPressed: () => _pop(),
215 + color: Theme.of(context).backgroundColor,
216 + shape: CircleBorder(),
217 + child: deleteIconImage,
218 + ),
219 + );
220 + } else {
221 + index++;
222 + }
223 +
224 + return Container(
225 + margin: EdgeInsets.only(
226 + left: marginLeft, right: marginRight),
227 + child: FlatButton(
228 + onPressed: () => _push(index),
229 + color: Theme.of(context).backgroundColor,
230 + shape: CircleBorder(),
231 + child: Text('$index',
232 + style: TextStyle(
233 + fontSize: 30.0,
234 + fontWeight: FontWeight.w600,
235 + color: Theme.of(context)
236 + .primaryTextTheme
237 + .title
238 + .color)),
239 + ),
240 + );
241 + }),
242 + )
243 + : null))
244 + ]),
245 + );
246 + }
247 +
248 + void _push(int num) {
249 + setState(() {
250 + if (currentPinLength() >= pinLength) {
251 + return;
252 + }
253 +
254 + pin += num.toString();
255 +
256 + widget.onChangedPin(pin);
257 +
258 + if (pin.length == pinLength) {
259 + widget.onFullPin(pin, this);
260 + }
261 + });
262 + }
263 +
264 + void _pop() {
265 + if (currentPinLength() == 0) {
266 + return;
267 + }
268 +
269 + pin.substring(0, pin.length - 1);
270 + }
271 +
272 + String _changePinLengthText() {
273 + return S.current.use +
274 + (pinLength == PinCodeState.fourPinLength
275 + ? '${PinCodeState.sixPinLength}'
276 + : '${PinCodeState.fourPinLength}') +
277 + S.current.digit_pin;
278 + }
279 +
280 + void _afterLayout(dynamic _) {
281 + setDefaultPinLength();
282 + calculateAspectRatio();
283 + }
284 +}
lib/src/screens/rescan/rescan_page.dart
+19 -16
@@ -1,38 +1,41 @@
1 import 'package:flutter/material.dart';
2 import 'package:flutter_mobx/flutter_mobx.dart';
3 -import 'package:provider/provider.dart';
3 +import 'package:cake_wallet/view_model/rescan_view_model.dart';
4 import 'package:cake_wallet/src/screens/base_page.dart';
5 import 'package:cake_wallet/src/widgets/blockchain_height_widget.dart';
6 import 'package:cake_wallet/src/widgets/primary_button.dart';
7 -import 'package:cake_wallet/src/stores/rescan/rescan_wallet_store.dart';
7 import 'package:cake_wallet/generated/i18n.dart';
8
9 class RescanPage extends BasePage {
11 - final blockchainKey = GlobalKey<BlockchainHeightState>();
10 + RescanPage(this._rescanViewModel)
11 + : _blockchainHeightWidgetKey = GlobalKey<BlockchainHeightState>();
12 +
13 @override
14 String get title => S.current.rescan;
15 + final GlobalKey<BlockchainHeightState> _blockchainHeightWidgetKey;
16 + final RescanViewModel _rescanViewModel;
17
18 @override
19 Widget body(BuildContext context) {
17 - final rescanWalletStore = Provider.of<RescanWalletStore>(context);
18 -
20 return Padding(
21 padding: EdgeInsets.only(left: 24, right: 24, bottom: 24),
22 child:
23 Column(mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [
23 - BlockchainHeightWidget(key: blockchainKey),
24 + BlockchainHeightWidget(key: _blockchainHeightWidgetKey),
25 Observer(
26 builder: (_) => LoadingPrimaryButton(
26 - isLoading:
27 - rescanWalletStore.state == RescanWalletState.rescaning,
28 - text: S.of(context).rescan,
29 - onPressed: () async {
30 - await rescanWalletStore.rescanCurrentWallet(
31 - restoreHeight: blockchainKey.currentState.height);
32 - Navigator.of(context).pop();
33 - },
34 - color: Colors.blue,
35 - textColor: Colors.white,))
27 + isLoading:
28 + _rescanViewModel.state == RescanWalletState.rescaning,
29 + text: S.of(context).rescan,
30 + onPressed: () async {
31 + await _rescanViewModel.rescanCurrentWallet(
32 + restoreHeight:
33 + _blockchainHeightWidgetKey.currentState.height);
34 + Navigator.of(context).pop();
35 + },
36 + color: Colors.blue,
37 + textColor: Colors.white,
38 + ))
39 ]),
40 );
41 }
lib/src/screens/restore/restore_options_page.dart
+1 -1
@@ -1,4 +1,4 @@
1 -import 'package:cake_wallet/src/domain/common/wallet_type.dart';
1 +import 'package:cake_wallet/entities/wallet_type.dart';
2 import 'package:flutter/material.dart';
3 import 'package:cake_wallet/palette.dart';
4 import 'package:cake_wallet/routes.dart';
lib/src/screens/restore/restore_wallet_from_seed_details.dart
+5 -5
@@ -3,7 +3,7 @@ import 'package:flutter/material.dart';
3 import 'package:flutter_mobx/flutter_mobx.dart';
4 import 'package:cake_wallet/generated/i18n.dart';
5 import 'package:cake_wallet/core/validator.dart';
6 -import 'package:cake_wallet/view_model/wallet_creation_state.dart';
6 +import 'package:cake_wallet/core/execution_state.dart';
7 import 'package:cake_wallet/src/screens/base_page.dart';
8 import 'package:cake_wallet/src/widgets/blockchain_height_widget.dart';
9 import 'package:cake_wallet/src/widgets/scollable_with_bottom_section.dart';
@@ -46,12 +46,12 @@ class _RestoreFromSeedDetailsFormState
46 @override
47 void initState() {
48 _stateReaction = reaction((_) => widget.walletRestorationFromSeedVM.state,
49 - (WalletCreationState state) {
50 - if (state is WalletCreatedSuccessfully) {
49 + (ExecutionState state) {
50 + if (state is ExecutedSuccessfullyState) {
51 Navigator.of(context).popUntil((route) => route.isFirst);
52 }
53
54 - if (state is WalletCreationFailure) {
54 + if (state is FailureState) {
55 WidgetsBinding.instance.addPostFrameCallback((_) {
56 showDialog<void>(
57 context: context,
@@ -131,7 +131,7 @@ class _RestoreFromSeedDetailsFormState
131 }
132 },
133 isLoading:
134 - widget.walletRestorationFromSeedVM.state is WalletCreating,
134 + widget.walletRestorationFromSeedVM.state is IsExecutingState,
135 text: S.of(context).restore_recover,
136 color: Theme.of(context).accentTextTheme.body2.color,
137 textColor: Colors.white,
lib/src/screens/restore/restore_wallet_from_seed_page.dart
+1 -1
@@ -4,7 +4,7 @@ import 'package:cake_wallet/routes.dart';
4 import 'package:cake_wallet/generated/i18n.dart';
5 import 'package:cake_wallet/src/screens/base_page.dart';
6 import 'package:cake_wallet/src/widgets/seed_widget.dart';
7 -import 'package:cake_wallet/src/domain/common/wallet_type.dart';
7 +import 'package:cake_wallet/entities/wallet_type.dart';
8 import 'package:cake_wallet/core/seed_validator.dart';
9 import 'package:cake_wallet/core/mnemonic_length.dart';
10
lib/src/screens/restore/restore_wallet_options_page.dart
+1 -1
@@ -1,7 +1,7 @@
1 import 'package:flutter/material.dart';
2 import 'package:cake_wallet/src/screens/restore/widgets/restore_button.dart';
3 import 'package:cake_wallet/src/screens/base_page.dart';
4 -import 'package:cake_wallet/src/domain/common/wallet_type.dart';
4 +import 'package:cake_wallet/entities/wallet_type.dart';
5 import 'package:cake_wallet/generated/i18n.dart';
6
7 class RestoreWalletOptionsPage extends BasePage {
lib/src/screens/root/root.dart
+28 -135
@@ -1,28 +1,9 @@
1 -import 'package:cake_wallet/di.dart';
2 -import 'package:cake_wallet/src/screens/dashboard/dashboard_page.dart';
3 -import 'package:cake_wallet/store/app_store.dart';
1 import 'package:flutter/material.dart';
5 -import 'package:flutter_mobx/flutter_mobx.dart';
6 -import 'package:hive/hive.dart';
7 -import 'package:provider/provider.dart';
8 -import 'package:shared_preferences/shared_preferences.dart';
2 import 'package:cake_wallet/routes.dart';
10 -import 'package:cake_wallet/store/authentication_store.dart';
11 -
12 -//import 'package:cake_wallet/src/stores/authentication/authentication_store.dart';
13 -import 'package:cake_wallet/src/stores/price/price_store.dart';
14 -import 'package:cake_wallet/src/stores/settings/settings_store.dart';
15 -import 'package:cake_wallet/src/stores/wallet/wallet_store.dart';
16 -import 'package:cake_wallet/src/domain/common/qr_scanner.dart';
17 -import 'package:cake_wallet/src/domain/services/user_service.dart';
18 -import 'package:cake_wallet/src/domain/services/wallet_list_service.dart';
19 -import 'package:cake_wallet/src/domain/services/wallet_service.dart';
20 -import 'package:cake_wallet/src/domain/exchange/trade.dart';
21 -import 'package:cake_wallet/src/domain/monero/transaction_description.dart';
22 -import 'package:cake_wallet/src/screens/auth/create_login_page.dart';
23 -import 'package:cake_wallet/src/screens/dashboard/create_dashboard_page.dart';
3 import 'package:cake_wallet/src/screens/auth/auth_page.dart';
25 -import 'package:cake_wallet/src/screens/welcome/create_welcome_page.dart';
4 +import 'package:cake_wallet/store/app_store.dart';
5 +import 'package:cake_wallet/store/authentication_store.dart';
6 +import 'package:cake_wallet/entities/qr_scanner.dart';
7
8 class Root extends StatefulWidget {
9 Root({Key key, this.authenticationStore, this.appStore, this.child})
@@ -39,18 +20,12 @@ class Root extends StatefulWidget {
20 class RootState extends State<Root> with WidgetsBindingObserver {
21 bool _isInactive;
22 bool _postFrameCallback;
42 - // GlobalKey<NavigatorState> _navKey;
23
24 @override
25 void initState() {
26 _isInactive = false;
27 _postFrameCallback = false;
28 WidgetsBinding.instance.addObserver(this);
49 -
50 - // WidgetsBinding.instance.addPostFrameCallback((_) {
51 - // _navKey.currentState.pushNamed(Routes.login);
52 - // });
53 -
29 super.initState();
30 }
31
@@ -62,12 +37,10 @@ class RootState extends State<Root> with WidgetsBindingObserver {
37 return;
38 }
39
65 -// if (!_isInactive &&
66 -// widget.authenticationStore.state ==
67 -// AuthenticationState.authenticated ||
68 -// widget.authenticationStore.state == AuthenticationState.active) {
69 -// setState(() => _isInactive = true);
70 -// }
40 + if (!_isInactive &&
41 + widget.authenticationStore.state == AuthenticationState.allowed) {
42 + setState(() => _isInactive = true);
43 + }
44
45 break;
46 default:
@@ -77,108 +50,28 @@ class RootState extends State<Root> with WidgetsBindingObserver {
50
51 @override
52 Widget build(BuildContext context) {
80 - return widget.child;
81 -
82 -// _authenticationStore = Provider.of<AuthenticationStore>(context);
83 -// final sharedPreferences = Provider.of<SharedPreferences>(context);
84 -// final walletListService = Provider.of<WalletListService>(context);
85 -// final walletService = Provider.of<WalletService>(context);
86 -// final userService = Provider.of<UserService>(context);
87 -// final priceStore = Provider.of<PriceStore>(context);
88 -// final authenticationStore = Provider.of<AuthenticationStore>(context);
89 -// final trades = Provider.of<Box<Trade>>(context);
90 -// final transactionDescriptions =
91 -// Provider.of<Box<TransactionDescription>>(context);
92 -// final walletStore = Provider.of<WalletStore>(context);
93 -// final settingsStore = Provider.of<SettingsStore>(context);
94 -
95 - // if (_isInactive && !_postFrameCallback) {
96 - // _postFrameCallback = true;
97 -
98 - // WidgetsBinding.instance.addPostFrameCallback((_) {
99 - // Navigator.of(context).pushNamed(Routes.unlock,
100 - // arguments: (bool isAuthenticatedSuccessfully, AuthPageState auth) {
101 - // if (!isAuthenticatedSuccessfully) {
102 - // return;
103 - // }
104 -
105 - // setState(() {
106 - // _postFrameCallback = false;
107 - // _isInactive = false;
108 - // });
109 - // auth.close();
110 - // });
111 - // });
112 - // }
113 -
114 - // return Navigator(
115 - // key: _navKey,
116 - // initialRoute: Routes.welcome,
117 - // onGenerateRoute: Router.generateRoute(
118 - // sharedPreferences: sharedPreferences,
119 - // walletListService: walletListService,
120 - // walletService: walletService,
121 - // userService: userService,
122 - // settings: settings,
123 - // priceStore: priceStore,
124 - // walletStore: walletStore,
125 - // syncStore: syncStore,
126 - // balanceStore: balanceStore,
127 - // settingsStore: settingsStore,
128 - // contacts: contacts,
129 - // nodes: nodes,
130 - // trades: trades,
131 - // transactionDescriptions: transactionDescriptions),
132 - // );
133 -
134 - // return Observer(builder: (_) {
135 - // final state = widget.authenticationStore.state;
136 -
137 - // if (state == AuthenticationState.denied) {
138 - // return createWelcomePage();
139 - // }
140 -
141 - // if (state == AuthenticationState.installed) {
142 - // return getIt.get<AuthPage>(instanceName: 'login');
143 - // }
144 -
145 - // if (state == AuthenticationState.allowed) {
146 - // return getIt.get<DashboardPage>();
147 - // }
148 -
149 -// if (state == AuthenticationState.denied) {
150 -// return createWelcomePage();
151 -// }
152 -
153 -// if (state == AuthenticationState.readyToLogin) {
154 -// return createLoginPage(
155 -// sharedPreferences: sharedPreferences,
156 -// userService: userService,
157 -// walletService: walletService,
158 -// walletListService: walletListService,
159 -// authenticationStore: authenticationStore);
160 -// }
161 -
162 -// if (state == AuthenticationState.authenticated ||
163 -// state == AuthenticationState.restored) {
164 -// return createDashboardPage(
165 -// walletService: walletService,
166 -// priceStore: priceStore,
167 -// trades: trades,
168 -// transactionDescriptions: transactionDescriptions,
169 -// walletStore: walletStore,
170 -// settingsStore: settingsStore);
171 -// }
53 + if (_isInactive && !_postFrameCallback) {
54 + _postFrameCallback = true;
55 + WidgetsBinding.instance.addPostFrameCallback((_) {
56 + Navigator.of(context).pushNamed(Routes.unlock,
57 + arguments: (bool isAuthenticatedSuccessfully, AuthPageState auth) {
58 + if (!isAuthenticatedSuccessfully) {
59 + return;
60 + }
61 +
62 + _reset();
63 + auth.close();
64 + });
65 + });
66 + }
67
173 -// if (state == AuthenticationState.created) {
174 -// return createSeedPage(
175 -// settingsStore: settingsStore,
176 -// walletService: walletService,
177 -// callback: () =>
178 -// _authenticationStore.state = AuthenticationState.authenticated);
179 -// }
68 + return widget.child;
69 + }
70
181 - // return Container(color: Colors.white);
182 - // });
71 + void _reset() {
72 + setState(() {
73 + _postFrameCallback = false;
74 + _isInactive = false;
75 + });
76 }
77 }
lib/src/screens/seed/wallet_seed_page.dart
+57 -51
@@ -24,10 +24,9 @@ class WalletSeedPage extends BasePage {
24 final WalletSeedViewModel walletSeedViewModel;
25
26 @override
27 - void onClose(BuildContext context) =>
28 - isNewWalletCreated
29 - ? Navigator.of(context).popUntil((route) => route.isFirst)
30 - : Navigator.of(context).pop();
27 + void onClose(BuildContext context) => isNewWalletCreated
28 + ? Navigator.of(context).popUntil((route) => route.isFirst)
29 + : Navigator.of(context).pop();
30
31 @override
32 Widget leading(BuildContext context) =>
@@ -60,7 +59,8 @@ class WalletSeedPage extends BasePage {
59
60 @override
61 Widget body(BuildContext context) {
63 - final image = getIt.get<SettingsStore>().isDarkTheme ? imageDark : imageLight;
62 + final image =
63 + getIt.get<SettingsStore>().isDarkTheme ? imageDark : imageLight;
64
65 return Container(
66 padding: EdgeInsets.all(24),
@@ -93,7 +93,8 @@ class WalletSeedPage extends BasePage {
93 .color),
94 ),
95 Padding(
96 - padding: EdgeInsets.only(top: 20, left: 16, right: 16),
96 + padding:
97 + EdgeInsets.only(top: 20, left: 16, right: 16),
98 child: Text(
99 walletSeedViewModel.seed,
100 textAlign: TextAlign.center,
@@ -113,58 +114,63 @@ class WalletSeedPage extends BasePage {
114 Column(
115 children: <Widget>[
116 isNewWalletCreated
116 - ? Padding(
117 - padding: EdgeInsets.only(bottom: 52, left: 43, right: 43),
118 - child: Text(
119 - S.of(context).seed_reminder,
120 - textAlign: TextAlign.center,
121 - style: TextStyle(
122 - fontSize: 12,
123 - fontWeight: FontWeight.normal,
124 - color: Theme.of(context)
125 - .primaryTextTheme
126 - .overline
127 - .color
128 - ),
129 - ),
130 - )
131 - : Offstage(),
117 + ? Padding(
118 + padding: EdgeInsets.only(
119 + bottom: 52, left: 43, right: 43),
120 + child: Text(
121 + S.of(context).seed_reminder,
122 + textAlign: TextAlign.center,
123 + style: TextStyle(
124 + fontSize: 12,
125 + fontWeight: FontWeight.normal,
126 + color: Theme.of(context)
127 + .primaryTextTheme
128 + .overline
129 + .color),
130 + ),
131 + )
132 + : Offstage(),
133 Row(
134 mainAxisSize: MainAxisSize.max,
135 children: <Widget>[
136 Flexible(
137 child: Container(
137 - padding: EdgeInsets.only(right: 8.0),
138 - child: PrimaryButton(
139 - onPressed: () => Share.text(
140 - S.of(context).seed_share,
141 - walletSeedViewModel.seed,
142 - 'text/plain'),
143 - text: S.of(context).save,
144 - color: Colors.green,
145 - textColor: Colors.white),
146 - )),
138 + padding: EdgeInsets.only(right: 8.0),
139 + child: PrimaryButton(
140 + onPressed: () => Share.text(
141 + S.of(context).seed_share,
142 + walletSeedViewModel.seed,
143 + 'text/plain'),
144 + text: S.of(context).save,
145 + color: Colors.green,
146 + textColor: Colors.white),
147 + )),
148 Flexible(
149 child: Container(
149 - padding: EdgeInsets.only(left: 8.0),
150 - child: Builder(
151 - builder: (context) => PrimaryButton(
152 - onPressed: () {
153 - Clipboard.setData(ClipboardData(
154 - text: walletSeedViewModel.seed));
155 - Scaffold.of(context).showSnackBar(
156 - SnackBar(
157 - content: Text(
158 - S.of(context).copied_to_clipboard),
159 - backgroundColor: Colors.green,
160 - duration: Duration(milliseconds: 1500),
161 - ),
162 - );
163 - },
164 - text: S.of(context).copy,
165 - color: Theme.of(context).accentTextTheme.body2.color,
166 - textColor: Colors.white)),
167 - ))
150 + padding: EdgeInsets.only(left: 8.0),
151 + child: Builder(
152 + builder: (context) => PrimaryButton(
153 + onPressed: () {
154 + Clipboard.setData(ClipboardData(
155 + text: walletSeedViewModel.seed));
156 + Scaffold.of(context).showSnackBar(
157 + SnackBar(
158 + content: Text(S
159 + .of(context)
160 + .copied_to_clipboard),
161 + backgroundColor: Colors.green,
162 + duration:
163 + Duration(milliseconds: 1500),
164 + ),
165 + );
166 + },
167 + text: S.of(context).copy,
168 + color: Theme.of(context)
169 + .accentTextTheme
170 + .body2
171 + .color,
172 + textColor: Colors.white)),
173 + ))
174 ],
175 )
176 ],
lib/src/screens/send/send_page.dart
-1
@@ -16,7 +16,6 @@ import 'package:cake_wallet/generated/i18n.dart';
16 import 'package:cake_wallet/src/widgets/top_panel.dart';
17 import 'package:cake_wallet/src/widgets/alert_with_one_action.dart';
18 import 'package:cake_wallet/src/widgets/alert_with_two_actions.dart';
19 -import 'package:cake_wallet/src/screens/send/widgets/confirm_sending_alert.dart';
19 import 'package:cake_wallet/view_model/send/send_view_model_state.dart';
20 import 'package:cake_wallet/src/widgets/trail_button.dart';
21
lib/src/screens/send/widgets/base_send_widget.dart
+22 -21
@@ -1,5 +1,6 @@
1 import 'dart:ui';
2 -import 'package:cake_wallet/src/domain/common/transaction_priority.dart';
2 +// import 'package:cake_wallet/src/domain/common/transaction_priority.dart';
3 +import 'package:cake_wallet/core/execution_state.dart';
4 import 'package:cake_wallet/src/widgets/picker.dart';
5 import 'package:cake_wallet/src/widgets/primary_button.dart';
6 import 'package:cake_wallet/src/widgets/scollable_with_bottom_section.dart';
@@ -18,7 +19,7 @@ import 'package:dotted_border/dotted_border.dart';
19 import 'package:cake_wallet/src/widgets/alert_with_one_action.dart';
20 import 'package:cake_wallet/src/widgets/alert_with_two_actions.dart';
21 import 'package:cake_wallet/src/screens/send/widgets/confirm_sending_alert.dart';
21 -import 'package:cake_wallet/src/screens/send/widgets/sending_alert.dart';
22 +// import 'package:cake_wallet/src/screens/send/widgets/sending_alert.dart';
23 import 'package:cake_wallet/src/widgets/template_tile.dart';
24 import 'package:cake_wallet/src/widgets/base_text_form_field.dart';
25 import 'package:cake_wallet/routes.dart';
@@ -473,13 +474,13 @@ class BaseSendWidget extends StatelessWidget {
474 return LoadingPrimaryButton(
475 onPressed: () {
476 if (_formKey.currentState.validate()) {
476 - print('SENT!!!');
477 +
478 }
479 },
480 text: S.of(context).send,
481 color: Theme.of(context).accentTextTheme.body2.color,
482 textColor: Colors.white,
482 - isLoading: sendViewModel.state is TransactionIsCreating ||
483 + isLoading: sendViewModel.state is IsExecutingState ||
484 sendViewModel.state is TransactionCommitting,
485 isDisabled:
486 false // FIXME !(syncStore.status is SyncedSyncStatus),
@@ -530,8 +531,8 @@ class BaseSendWidget extends StatelessWidget {
531 }
532 });
533
533 - reaction((_) => sendViewModel.state, (SendViewModelState state) {
534 - if (state is SendingFailed) {
534 + reaction((_) => sendViewModel.state, (ExecutionState state) {
535 + if (state is FailureState) {
536 WidgetsBinding.instance.addPostFrameCallback((_) {
537 showDialog<void>(
538 context: context,
@@ -545,7 +546,7 @@ class BaseSendWidget extends StatelessWidget {
546 });
547 }
548
548 - if (state is TransactionCreatedSuccessfully) {
549 + if (state is ExecutedSuccessfullyState) {
550 WidgetsBinding.instance.addPostFrameCallback((_) {
551 showDialog<void>(
552 context: context,
@@ -691,19 +692,19 @@ class BaseSendWidget extends StatelessWidget {
692 }
693
694 Future<void> _setTransactionPriority(BuildContext context) async {
694 - final items = TransactionPriority.all;
695 - final selectedItem = items.indexOf(sendViewModel.transactionPriority);
696 -
697 - await showDialog<void>(
698 - builder: (_) => Picker(
699 - items: items,
700 - selectedAtIndex: selectedItem,
701 - title: S.of(context).please_select,
702 - mainAxisAlignment: MainAxisAlignment.center,
703 - onItemSelected: (TransactionPriority priority) => null,
704 - // sendViewModel.setTransactionPriority(priority),
705 - isAlwaysShowScrollThumb: true,
706 - ),
707 - context: context);
695 + // final items = TransactionPriority.all;
696 + // final selectedItem = items.indexOf(sendViewModel.transactionPriority);
697 + //
698 + // await showDialog<void>(
699 + // builder: (_) => Picker(
700 + // items: items,
701 + // selectedAtIndex: selectedItem,
702 + // title: S.of(context).please_select,
703 + // mainAxisAlignment: MainAxisAlignment.center,
704 + // onItemSelected: (TransactionPriority priority) => null,
705 + // // sendViewModel.setTransactionPriority(priority),
706 + // isAlwaysShowScrollThumb: true,
707 + // ),
708 + // context: context);
709 }
710 }
\ No newline at end of file
lib/src/screens/send/widgets/sending_alert.dart deleted
-104
@@ -1,104 +0,0 @@
1 -import 'dart:ui';
2 -import 'package:flutter/material.dart';
3 -import 'package:cake_wallet/src/stores/send/sending_state.dart';
4 -import 'package:cake_wallet/src/widgets/primary_button.dart';
5 -import 'package:cake_wallet/src/stores/send/send_store.dart';
6 -import 'package:cake_wallet/generated/i18n.dart';
7 -import 'package:flutter_mobx/flutter_mobx.dart';
8 -
9 -class SendingAlert extends StatefulWidget {
10 - SendingAlert({@required this.sendStore});
11 -
12 - final SendStore sendStore;
13 -
14 - @override
15 - SendingAlertState createState() => SendingAlertState(sendStore);
16 -}
17 -
18 -class SendingAlertState extends State<SendingAlert> {
19 - SendingAlertState(this.sendStore);
20 -
21 - final SendStore sendStore;
22 -
23 - @override
24 - Widget build(BuildContext context) {
25 - return Observer(
26 - builder: (_) {
27 - final state = sendStore.state;
28 -
29 - if (state is TransactionCommitted) {
30 - return Stack(
31 - children: <Widget>[
32 - Container(
33 - color: Theme.of(context).backgroundColor,
34 - child: Center(
35 - child: Image.asset(
36 - 'assets/images/birthday_cake.png'),
37 - ),
38 - ),
39 - Center(
40 - child: Padding(
41 - padding: EdgeInsets.only(top: 220, left: 24, right: 24),
42 - child: Text(
43 - S.of(context).send_success,
44 - textAlign: TextAlign.center,
45 - style: TextStyle(
46 - fontSize: 22,
47 - fontWeight: FontWeight.bold,
48 - color: Theme.of(context).primaryTextTheme.title.color,
49 - decoration: TextDecoration.none,
50 - ),
51 - ),
52 - ),
53 - ),
54 - Positioned(
55 - left: 24,
56 - right: 24,
57 - bottom: 24,
58 - child: PrimaryButton(
59 - onPressed: () => Navigator.of(context).pop(),
60 - text: S.of(context).send_got_it,
61 - color: Colors.blue,
62 - textColor: Colors.white
63 - )
64 - )
65 - ],
66 - );
67 - }
68 -
69 - return Stack(
70 - children: <Widget>[
71 - Container(
72 - color: Theme.of(context).backgroundColor,
73 - child: Center(
74 - child: Image.asset(
75 - 'assets/images/birthday_cake.png'),
76 - ),
77 - ),
78 - BackdropFilter(
79 - filter: ImageFilter.blur(sigmaX: 3.0, sigmaY: 3.0),
80 - child: Container(
81 - decoration: BoxDecoration(color: Theme.of(context).backgroundColor.withOpacity(0.25)),
82 - child: Center(
83 - child: Padding(
84 - padding: EdgeInsets.only(top: 220),
85 - child: Text(
86 - S.of(context).send_sending,
87 - textAlign: TextAlign.center,
88 - style: TextStyle(
89 - fontSize: 22,
90 - fontWeight: FontWeight.bold,
91 - color: Theme.of(context).primaryTextTheme.title.color,
92 - decoration: TextDecoration.none,
93 - ),
94 - ),
95 - ),
96 - ),
97 - ),
98 - )
99 - ],
100 - );
101 - }
102 - );
103 - }
104 -}
\ No newline at end of file
lib/src/screens/settings/change_language.dart
+50 -46
@@ -4,61 +4,65 @@ import 'package:flutter/material.dart';
4 import 'package:flutter/cupertino.dart';
5 import 'package:provider/provider.dart';
6 import 'package:cake_wallet/generated/i18n.dart';
7 -import 'package:cake_wallet/src/domain/common/language.dart';
8 -import 'package:cake_wallet/src/stores/settings/settings_store.dart';
7 +import 'package:cake_wallet/entities/language.dart';
8 +// import 'package:cake_wallet/src/stores/settings/settings_store.dart';
9 import 'package:cake_wallet/src/screens/base_page.dart';
10 import 'package:cake_wallet/src/widgets/alert_with_two_actions.dart';
11
12 +// FIXME: FIXME
13 +
14 class ChangeLanguage extends BasePage {
15 @override
16 String get title => S.current.settings_change_language;
17
18 @override
19 Widget body(BuildContext context) {
18 - final settingsStore = Provider.of<SettingsStore>(context);
19 - final currentLanguage = Provider.of<Language>(context);
20 -
21 - return Container(
22 - padding: EdgeInsets.only(top: 10.0),
23 - child: SectionStandardList(
24 - sectionCount: 1,
25 - context: context,
26 - itemCounter: (int sectionIndex) => languages.values.length,
27 - itemBuilder: (_, sectionIndex, index) {
28 - final item = languages.values.elementAt(index);
29 - final code = languages.keys.elementAt(index);
30 -
31 - final isCurrent = settingsStore.languageCode == null
32 - ? false
33 - : code == settingsStore.languageCode;
20 + // final settingsStore = Provider.of<SettingsStore>(context);
21 + // final currentLanguage = Provider.of<Language>(context);
22 + //
23 + // return Container(
24 + // padding: EdgeInsets.only(top: 10.0),
25 + // child: SectionStandardList(
26 + // sectionCount: 1,
27 + // context: context,
28 + // itemCounter: (int sectionIndex) => languages.values.length,
29 + // itemBuilder: (_, sectionIndex, index) {
30 + // final item = languages.values.elementAt(index);
31 + // final code = languages.keys.elementAt(index);
32 + //
33 + // final isCurrent = settingsStore.languageCode == null
34 + // ? false
35 + // : code == settingsStore.languageCode;
36 + //
37 + // return LanguageRow(
38 + // title: item,
39 + // isSelected: isCurrent,
40 + // handler: (context) async {
41 + // if (!isCurrent) {
42 + // await showDialog<void>(
43 + // context: context,
44 + // builder: (BuildContext context) {
45 + // return AlertWithTwoActions(
46 + // alertTitle: S.of(context).change_language,
47 + // alertContent: S.of(context).change_language_to(item),
48 + // rightButtonText: S.of(context).change,
49 + // leftButtonText: S.of(context).cancel,
50 + // actionRightButton: () {
51 + // settingsStore.saveLanguageCode(
52 + // languageCode: code);
53 + // currentLanguage.setCurrentLanguage(code);
54 + // Navigator.of(context).pop();
55 + // },
56 + // actionLeftButton: () => Navigator.of(context).pop()
57 + // );
58 + // });
59 + // }
60 + // },
61 + // );
62 + // },
63 + // )
64 + // );
65
35 - return LanguageRow(
36 - title: item,
37 - isSelected: isCurrent,
38 - handler: (context) async {
39 - if (!isCurrent) {
40 - await showDialog<void>(
41 - context: context,
42 - builder: (BuildContext context) {
43 - return AlertWithTwoActions(
44 - alertTitle: S.of(context).change_language,
45 - alertContent: S.of(context).change_language_to(item),
46 - rightButtonText: S.of(context).change,
47 - leftButtonText: S.of(context).cancel,
48 - actionRightButton: () {
49 - settingsStore.saveLanguageCode(
50 - languageCode: code);
51 - currentLanguage.setCurrentLanguage(code);
52 - Navigator.of(context).pop();
53 - },
54 - actionLeftButton: () => Navigator.of(context).pop()
55 - );
56 - });
57 - }
58 - },
59 - );
60 - },
61 - )
62 - );
66 + return null;
67 }
68 }
lib/src/screens/setup_pin_code/setup_pin_code.dart
+56 -80
@@ -1,105 +1,81 @@
1 -import 'package:flutter/foundation.dart';
1 import 'package:flutter/material.dart';
2 import 'package:flutter/cupertino.dart';
4 -import 'package:provider/provider.dart';
5 -import 'package:cake_wallet/src/stores/user/user_store.dart';
6 -import 'package:cake_wallet/src/screens/pin_code/pin_code.dart';
7 -import 'package:cake_wallet/src/screens/base_page.dart';
8 -import 'package:cake_wallet/src/stores/settings/settings_store.dart';
3 import 'package:cake_wallet/generated/i18n.dart';
4 +import 'package:cake_wallet/src/screens/base_page.dart';
5 +import 'package:cake_wallet/src/screens/pin_code/pin_code_widget.dart';
6 +import 'package:cake_wallet/view_model/setup_pin_code_view_model.dart';
7 import 'package:cake_wallet/src/widgets/alert_with_one_action.dart';
8
9 class SetupPinCodePage extends BasePage {
13 - SetupPinCodePage({this.onPinCodeSetup});
10 + SetupPinCodePage(this.pinCodeViewModel, {this.onSuccessfulPinSetup});
11
15 - final Function(BuildContext, String) onPinCodeSetup;
12 + final SetupPinCodeViewModel pinCodeViewModel;
13 + final void Function(BuildContext, String) onSuccessfulPinSetup;
14
15 @override
16 String get title => S.current.setup_pin;
17
18 @override
21 - Widget body(BuildContext context) =>
22 - SetupPinCodeForm(onPinCodeSetup: onPinCodeSetup, hasLengthSwitcher: true);
23 -}
24 -
25 -class SetupPinCodeForm extends PinCodeWidget {
26 - SetupPinCodeForm(
27 - {@required this.onPinCodeSetup, @required bool hasLengthSwitcher})
28 - : super(hasLengthSwitcher: hasLengthSwitcher);
29 -
30 - final Function(BuildContext, String) onPinCodeSetup;
31 -
32 - @override
33 - _SetupPinCodeFormState createState() => _SetupPinCodeFormState();
34 -}
19 + Widget body(BuildContext context) => PinCodeWidget(
20 + hasLengthSwitcher: true,
21 + onFullPin: (String pin, PinCodeState<PinCodeWidget> state) async {
22 + if (pinCodeViewModel.isOriginalPinCodeFull && !pinCodeViewModel.isRepeatedPinCodeFull) {
23 + state.title = S.current.enter_your_pin_again;
24 + state.clear();
25 + return;
26 + }
27
36 -class _SetupPinCodeFormState<WidgetType extends SetupPinCodeForm>
37 - extends PinCodeState<WidgetType> {
38 - _SetupPinCodeFormState() {
39 - title = S.current.enter_your_pin;
40 - }
28 + if (!pinCodeViewModel.isPinCodeCorrect) {
29 + await showDialog<void>(
30 + context: context,
31 + builder: (BuildContext context) {
32 + return AlertWithOneAction(
33 + alertTitle: S.current.setup_pin,
34 + alertContent: S.of(context).pin_is_incorrect,
35 + buttonText: S.of(context).ok,
36 + buttonAction: () => Navigator.of(context).pop());
37 + });
38 + pinCodeViewModel.reset();
39 + state.reset();
40 + return;
41 + }
42
42 - bool isEnteredOriginalPin() => _originalPin.isNotEmpty;
43 - Function(BuildContext) onPinCodeSetup;
44 - List<int> _originalPin = [];
45 - UserStore _userStore;
46 - SettingsStore _settingsStore;
43 + try {
44 + await pinCodeViewModel.setupPinCode();
45
48 - @override
49 - void onPinCodeEntered(PinCodeState state) {
50 - if (!isEnteredOriginalPin()) {
51 - _originalPin = state.pin;
52 - state.title = S.current.enter_your_pin_again;
53 - state.clear();
54 - } else {
55 - if (listEquals<int>(state.pin, _originalPin)) {
56 - final String pin = state.pin.fold('', (ac, val) => ac + '$val');
57 - _userStore.set(password: pin);
58 - _settingsStore.setDefaultPinLength(pinLength: state.pinLength);
59 -
60 - showDialog<void>(
61 - context: context,
62 - builder: (BuildContext context) {
63 - return AlertWithOneAction(
46 + await showDialog<void>(
47 + context: context,
48 + builder: (BuildContext context) {
49 + return AlertWithOneAction(
50 alertTitle: S.current.setup_pin,
51 alertContent: S.of(context).setup_successful,
52 buttonText: S.of(context).ok,
53 buttonAction: () {
54 Navigator.of(context).pop();
69 - widget.onPinCodeSetup(context, pin);
70 - reset();
55 + onSuccessfulPinSetup(context, pin);
56 + state.reset();
57 },
58 alertBarrierDismissible: false,
73 - );
74 - });
75 - } else {
76 - showDialog<void>(
77 - context: context,
78 - builder: (BuildContext context) {
79 - return AlertWithOneAction(
59 + );
60 + });
61 + } catch (e) {
62 + // FIXME: Add translation for alert content text.
63 + await showDialog<void>(
64 + context: context,
65 + builder: (BuildContext context) {
66 + return AlertWithOneAction(
67 alertTitle: S.current.setup_pin,
81 - alertContent: S.of(context).pin_is_incorrect,
68 + alertContent:
69 + 'Setup pin is failed with error: ${e.toString()}',
70 buttonText: S.of(context).ok,
83 - buttonAction: () => Navigator.of(context).pop()
84 - );
85 - });
86 -
87 - reset();
88 - }
89 - }
90 - }
91 -
92 - void reset() {
93 - clear();
94 - setTitle(S.current.enter_your_pin);
95 - _originalPin = [];
96 - }
97 -
98 - @override
99 - Widget build(BuildContext context) {
100 - _userStore = Provider.of<UserStore>(context);
101 - _settingsStore = Provider.of<SettingsStore>(context);
102 -
103 - return body(context);
104 - }
71 + buttonAction: () => Navigator.of(context).pop(),
72 + alertBarrierDismissible: false,
73 + );
74 + });
75 + }
76 + },
77 + onChangedPin: (String pin) => pinCodeViewModel.pinCode = pin,
78 + onChangedPinLength: (int length) =>
79 + pinCodeViewModel.pinCodeLength = length,
80 + initialPinLength: pinCodeViewModel.pinCodeLength);
81 }
lib/src/screens/subaddress/subaddress_list_page.dart deleted
-67
@@ -1,67 +0,0 @@
1 -import 'package:provider/provider.dart';
2 -import 'package:flutter/material.dart';
3 -import 'package:flutter/cupertino.dart';
4 -import 'package:flutter_mobx/flutter_mobx.dart';
5 -import 'package:cake_wallet/generated/i18n.dart';
6 -import 'package:cake_wallet/src/stores/subaddress_list/subaddress_list_store.dart';
7 -import 'package:cake_wallet/src/stores/wallet/wallet_store.dart';
8 -import 'package:cake_wallet/src/screens/base_page.dart';
9 -
10 -class SubaddressListPage extends BasePage {
11 - SubaddressListPage();
12 -
13 - @override
14 - bool get isModalBackButton => true;
15 -
16 - @override
17 - String get title => S.current.subaddress_title;
18 -
19 - @override
20 - AppBarStyle get appBarStyle => AppBarStyle.withShadow;
21 -
22 - @override
23 - Widget body(BuildContext context) {
24 - final walletStore = Provider.of<WalletStore>(context);
25 - final subaddressListStore = Provider.of<SubaddressListStore>(context);
26 -
27 - final currentColor = Theme.of(context).selectedRowColor;
28 - final notCurrentColor = Theme.of(context).backgroundColor;
29 -
30 - return Container(
31 - padding: EdgeInsets.only(top: 20.0, bottom: 20.0),
32 - child: Observer(
33 - builder: (_) => ListView.separated(
34 - separatorBuilder: (_, __) => Divider(
35 - color: Theme.of(context).dividerTheme.color, height: 1.0),
36 - itemCount: subaddressListStore.subaddresses == null
37 - ? 0
38 - : subaddressListStore.subaddresses.length,
39 - itemBuilder: (BuildContext context, int index) {
40 - final subaddress = subaddressListStore.subaddresses[index];
41 - final isCurrent =
42 - walletStore.subaddress.address == subaddress.address;
43 - final label = subaddress.label ?? subaddress.address;
44 -
45 - return InkWell(
46 - onTap: () => Navigator.of(context).pop(subaddress),
47 - child: Container(
48 - color: isCurrent ? currentColor : notCurrentColor,
49 - child: Column(children: <Widget>[
50 - ListTile(
51 - title: Text(
52 - label,
53 - style: TextStyle(
54 - fontSize: 16.0,
55 - color: Theme.of(context)
56 - .primaryTextTheme
57 - .headline
58 - .color),
59 - ),
60 - )
61 - ]),
62 - ),
63 - );
64 - }),
65 - ));
66 - }
67 -}
lib/src/screens/trade_details/trade_details_page.dart
+68 -72
@@ -1,92 +1,88 @@
1 -import 'package:provider/provider.dart';
1 import 'package:flutter/material.dart';
2 import 'package:flutter/cupertino.dart';
3 import 'package:flutter/services.dart';
4 import 'package:flutter_mobx/flutter_mobx.dart';
5 +import 'package:cake_wallet/exchange/trade.dart';
6 import 'package:cake_wallet/generated/i18n.dart';
7 -import 'package:cake_wallet/src/stores/exchange_trade/exchange_trade_store.dart';
8 -import 'package:cake_wallet/src/stores/settings/settings_store.dart';
7 +import 'package:cake_wallet/utils/date_formatter.dart';
8 import 'package:cake_wallet/src/screens/base_page.dart';
9 import 'package:cake_wallet/src/screens/transaction_details/standart_list_item.dart';
10 import 'package:cake_wallet/src/widgets/standart_list_row.dart';
11
12 class TradeDetailsPage extends BasePage {
13 + TradeDetailsPage(this.trade) : _items = [] {
14 + final dateFormat = DateFormatter.withCurrentLocal();
15 + final items = [
16 + StandartListItem(title: S.current.trade_details_id, value: trade.id),
17 + StandartListItem(
18 + title: S.current.trade_details_state,
19 + value: trade.state != null
20 + ? trade.state.toString()
21 + : S.current.trade_details_fetching)
22 + ];
23
15 - @override
16 - String get title => S.current.trade_details_title;
17 -
18 - @override
19 - Widget body(BuildContext context) {
20 - final exchangeStore = Provider.of<ExchangeTradeStore>(context);
21 - final settingsStore = Provider.of<SettingsStore>(context);
22 - final createdAtFormat = settingsStore.getCurrentDateFormat(
23 - formatUSA: "yyyy.MM.dd, HH:mm",
24 - formatDefault: "dd.MM.yyyy, HH:mm");
24 + if (trade.provider != null) {
25 + items.add(StandartListItem(
26 + title: S.current.trade_details_provider,
27 + value: trade.provider.toString()));
28 + }
29
26 - return Container(
27 - child: Observer(builder: (_) {
28 - final trade = exchangeStore.trade;
29 - final items = [
30 - StandartListItem(
31 - title: S.of(context).trade_details_id, value: trade.id),
32 - StandartListItem(
33 - title: S.of(context).trade_details_state,
34 - value: trade.state != null
35 - ? trade.state.toString()
36 - : S.of(context).trade_details_fetching)
37 - ];
30 + if (trade.createdAt != null) {
31 + items.add(StandartListItem(
32 + title: S.current.trade_details_created_at,
33 + value: dateFormat.format(trade.createdAt).toString()));
34 + }
35
39 - if (trade.provider != null) {
40 - items.add(StandartListItem(
41 - title: S.of(context).trade_details_provider,
42 - value: trade.provider.toString()));
43 - }
36 + if (trade.from != null && trade.to != null) {
37 + items.add(StandartListItem(
38 + title: S.current.trade_details_pair,
39 + value: '${trade.from.toString()} → ${trade.to.toString()}'));
40 + }
41 + }
42
45 - if (trade.createdAt != null) {
46 - items.add(StandartListItem(
47 - title: S.of(context).trade_details_created_at,
48 - value: createdAtFormat.format(trade.createdAt).toString()));
49 - }
43 + @override
44 + String get title => S.current.trade_details_title;
45
51 - if (trade.from != null && trade.to != null) {
52 - items.add(StandartListItem(
53 - title: S.of(context).trade_details_pair,
54 - value: '${trade.from.toString()} → ${trade.to.toString()}'));
55 - }
46 + final Trade trade;
47 + final List<StandartListItem> _items;
48
57 - return ListView.separated(
58 - separatorBuilder: (_, __) => Container(
59 - height: 1,
60 - padding: EdgeInsets.only(left: 24),
61 - color: Theme.of(context).backgroundColor,
62 - child: Container(
49 + @override
50 + Widget body(BuildContext context) {
51 + return Container(child: Observer(builder: (_) {
52 + return ListView.separated(
53 + separatorBuilder: (_, __) => Container(
54 + height: 1,
55 + padding: EdgeInsets.only(left: 24),
56 + color: Theme.of(context).backgroundColor,
57 + child: Container(
58 height: 1,
64 - color: Theme.of(context).primaryTextTheme.title.backgroundColor,
65 - ),
66 - ),
67 - itemCount: items.length,
68 - itemBuilder: (BuildContext context, int index) {
69 - final item = items[index];
70 - final isDrawBottom = index == items.length - 1 ? true : false;
59 + color: Theme.of(context)
60 + .primaryTextTheme
61 + .title
62 + .backgroundColor)),
63 + itemCount: _items.length,
64 + itemBuilder: (BuildContext context, int index) {
65 + final item = _items[index];
66 + final isDrawBottom = index == _items.length - 1 ? true : false;
67
72 - return GestureDetector(
73 - onTap: () {
74 - Clipboard.setData(ClipboardData(text: '${item.value}'));
75 - Scaffold.of(context).showSnackBar(
76 - SnackBar(
77 - content: Text(
78 - S.of(context).trade_details_copied(item.title)),
79 - backgroundColor: Colors.green,
80 - duration: Duration(milliseconds: 1500),
81 - ),
82 - );
83 - },
84 - child: StandartListRow(
85 - title: '${item.title}',
86 - value: '${item.value}',
87 - isDrawBottom: isDrawBottom,
88 - ));
89 - });
90 - }));
68 + return GestureDetector(
69 + onTap: () {
70 + Clipboard.setData(ClipboardData(text: '${item.value}'));
71 + Scaffold.of(context).showSnackBar(
72 + SnackBar(
73 + content:
74 + Text(S.of(context).trade_details_copied(item.title)),
75 + backgroundColor: Colors.green,
76 + duration: Duration(milliseconds: 1500),
77 + ),
78 + );
79 + },
80 + child: StandartListRow(
81 + title: '${item.title}',
82 + value: '${item.value}',
83 + isDrawBottom: isDrawBottom,
84 + ));
85 + });
86 + }));
87 }
88 }
lib/src/screens/transaction_details/transaction_details_page.dart
+8 -12
@@ -1,21 +1,17 @@
1 -
2 -import 'package:intl/intl.dart';
1 import 'package:flutter/material.dart';
2 import 'package:flutter/services.dart';
3 import 'package:cake_wallet/generated/i18n.dart';
4 import 'package:cake_wallet/bitcoin/bitcoin_transaction_info.dart';
7 -import 'package:cake_wallet/src/domain/monero/monero_transaction_info.dart';
8 -import 'package:cake_wallet/src/domain/common/transaction_info.dart';
5 +import 'package:cake_wallet/monero/monero_transaction_info.dart';
6 +import 'package:cake_wallet/entities/transaction_info.dart';
7 import 'package:cake_wallet/src/widgets/standart_list_row.dart';
8 import 'package:cake_wallet/src/screens/transaction_details/standart_list_item.dart';
9 import 'package:cake_wallet/src/screens/base_page.dart';
10 +import 'package:cake_wallet/utils/date_formatter.dart';
11
12 class TransactionDetailsPage extends BasePage {
14 - TransactionDetailsPage({this.transactionInfo}) : _items = [] {
15 - // FIXME
16 -// final _dateFormat = widget.settingsStore.getCurrentDateFormat(
17 -// formatUSA: "yyyy.MM.dd, HH:mm", formatDefault: "dd.MM.yyyy, HH:mm");
18 - final dateFormat = DateFormat('dd.MM.yyyy, HH:mm');
13 + TransactionDetailsPage(this.transactionInfo) : _items = [] {
14 + final dateFormat = DateFormatter.withCurrentLocal();
15 final tx = transactionInfo;
16
17 if (tx is MoneroTransactionInfo) {
@@ -50,8 +46,7 @@ class TransactionDetailsPage extends BasePage {
46 title: S.current.transaction_details_date,
47 value: dateFormat.format(tx.date)),
48 StandartListItem(
53 - title: 'Confirmations',
54 - value: tx.confirmations?.toString()),
49 + title: 'Confirmations', value: tx.confirmations?.toString()),
50 StandartListItem(
51 title: S.current.transaction_details_height, value: '${tx.height}'),
52 StandartListItem(
@@ -80,7 +75,8 @@ class TransactionDetailsPage extends BasePage {
75 color: Theme.of(context).backgroundColor,
76 child: Container(
77 height: 1,
83 - color: Theme.of(context).primaryTextTheme.title.backgroundColor,
78 + color:
79 + Theme.of(context).primaryTextTheme.title.backgroundColor,
80 ),
81 ),
82 itemCount: _items.length,
lib/src/screens/wallet_list/wallet_list_page.dart
+1 -1
@@ -4,7 +4,7 @@ import 'package:flutter_mobx/flutter_mobx.dart';
4 import 'package:cake_wallet/routes.dart';
5 import 'package:cake_wallet/palette.dart';
6 import 'package:cake_wallet/generated/i18n.dart';
7 -import 'package:cake_wallet/src/domain/common/wallet_type.dart';
7 +import 'package:cake_wallet/entities/wallet_type.dart';
8 import 'package:cake_wallet/view_model/wallet_list/wallet_list_view_model.dart';
9 import 'package:cake_wallet/src/widgets/primary_button.dart';
10 import 'package:cake_wallet/src/screens/base_page.dart';
lib/src/screens/wallet_list/wallet_menu.dart
+1 -1
@@ -4,7 +4,7 @@ import 'package:flutter/material.dart';
4 import 'package:cake_wallet/routes.dart';
5 import 'package:provider/provider.dart';
6 import 'package:cake_wallet/generated/i18n.dart';
7 -import 'package:cake_wallet/src/stores/wallet_list/wallet_list_store.dart';
7 +// import 'package:cake_wallet/src/stores/wallet_list/wallet_list_store.dart';
8 import 'package:cake_wallet/view_model/wallet_list/wallet_list_item.dart';
9 import 'package:cake_wallet/src/screens/auth/auth_page.dart';
10 import 'package:cake_wallet/palette.dart';
lib/src/start_updating_price.dart deleted
-37
@@ -1,37 +0,0 @@
1 -import 'dart:async';
2 -import 'package:cake_wallet/src/domain/common/fiat_currency.dart';
3 -import 'package:flutter/foundation.dart';
4 -import 'package:cake_wallet/src/domain/common/crypto_currency.dart';
5 -import 'package:cake_wallet/src/domain/common/fetch_price.dart';
6 -import 'package:cake_wallet/src/stores/price/price_store.dart';
7 -import 'package:cake_wallet/src/stores/settings/settings_store.dart';
8 -
9 -bool _startedUpdatingPrice = false;
10 -
11 -Future<double> _updatePrice(Map args) async => await fetchPriceFor(
12 - fiat: args['fiat'] as FiatCurrency,
13 - crypto: args['crypto'] as CryptoCurrency);
14 -
15 -Future<double> updatePrice(Map args) async => compute(_updatePrice, args);
16 -
17 -Future<void> startUpdatingPrice(
18 - {SettingsStore settingsStore, PriceStore priceStore}) async {
19 - if (_startedUpdatingPrice) {
20 - return;
21 - }
22 -
23 - const currentCrypto = CryptoCurrency.xmr;
24 - _startedUpdatingPrice = true;
25 -
26 - final price = await updatePrice(
27 - <String, dynamic>{'fiat': settingsStore.fiatCurrency, 'crypto': currentCrypto});
28 - priceStore.changePriceForPair(
29 - fiat: settingsStore.fiatCurrency, crypto: currentCrypto, price: price);
30 -
31 - Timer.periodic(Duration(seconds: 30), (_) async {
32 - final price = await updatePrice(
33 - <String, dynamic>{'fiat': settingsStore.fiatCurrency, 'crypto': currentCrypto});
34 - priceStore.changePriceForPair(
35 - fiat: settingsStore.fiatCurrency, crypto: currentCrypto, price: price);
36 - });
37 -}
lib/src/stores/account_list/account_list_store.dart deleted
-108
@@ -1,108 +0,0 @@
1 -import 'dart:async';
2 -import 'package:flutter/foundation.dart';
3 -import 'package:mobx/mobx.dart';
4 -import 'package:cake_wallet/src/domain/common/wallet.dart';
5 -import 'package:cake_wallet/src/domain/monero/monero_wallet.dart';
6 -import 'package:cake_wallet/src/domain/monero/account.dart';
7 -import 'package:cake_wallet/src/domain/monero/account_list.dart';
8 -import 'package:cake_wallet/src/domain/services/wallet_service.dart';
9 -import 'package:cake_wallet/generated/i18n.dart';
10 -
11 -part 'account_list_store.g.dart';
12 -
13 -class AccountListStore = AcountListStoreBase with _$AccountListStore;
14 -
15 -abstract class AcountListStoreBase with Store {
16 - AcountListStoreBase({@required WalletService walletService}) {
17 - accounts = [];
18 - isAccountCreating = false;
19 - isDisabledStatus = true;
20 -
21 - if (walletService.currentWallet != null) {
22 - _onWalletChanged(walletService.currentWallet);
23 - }
24 -
25 - _onWalletChangeSubscription =
26 - walletService.onWalletChange.listen(_onWalletChanged);
27 - }
28 -
29 - @observable
30 - List<Account> accounts;
31 -
32 - @observable
33 - bool isValid;
34 -
35 - @observable
36 - String errorMessage;
37 -
38 - @observable
39 - bool isAccountCreating;
40 -
41 - @observable
42 - bool isDisabledStatus;
43 -
44 - AccountList _accountList;
45 - StreamSubscription<Wallet> _onWalletChangeSubscription;
46 - StreamSubscription<List<Account>> _onAccountsChangeSubscription;
47 -
48 - @action
49 - void setDisabledStatus(bool isDisabled) {
50 - isDisabledStatus = isDisabled;
51 - }
52 -
53 - // @override
54 - // void dispose() {
55 - // _onWalletChangeSubscription.cancel();
56 -
57 - // if (_onAccountsChangeSubscription != null) {
58 - // _onAccountsChangeSubscription.cancel();
59 - // }
60 -
61 - // super.dispose();
62 - // }
63 -
64 - void updateAccountList() {
65 - _accountList.refresh();
66 - accounts = _accountList.getAll();
67 - }
68 -
69 - Future addAccount({String label}) async {
70 - try {
71 - isAccountCreating = true;
72 - await _accountList.addAccount(label: label);
73 - updateAccountList();
74 - isAccountCreating = false;
75 - } catch (e) {
76 - isAccountCreating = false;
77 - }
78 - }
79 -
80 - Future renameAccount({int index, String label}) async {
81 - await _accountList.setLabelSubaddress(accountIndex: index, label: label);
82 - updateAccountList();
83 - }
84 -
85 - Future _onWalletChanged(Wallet wallet) async {
86 - if (_onAccountsChangeSubscription != null) {
87 - await _onAccountsChangeSubscription.cancel();
88 - }
89 -
90 - if (wallet is MoneroWallet) {
91 - _accountList = wallet.getAccountList();
92 - _onAccountsChangeSubscription =
93 - _accountList.accounts.listen((accounts) => this.accounts = accounts);
94 - updateAccountList();
95 -
96 - return;
97 - }
98 -
99 - print('Incorrect wallet type for this operation (AccountList)');
100 - }
101 -
102 - void validateAccountName(String value) {
103 - const pattern = '^[a-zA-Z0-9_]{1,15}\$';
104 - final regExp = RegExp(pattern);
105 - isValid = regExp.hasMatch(value);
106 - errorMessage = isValid ? null : S.current.error_text_account_name;
107 - }
108 -}
lib/src/stores/action_list/action_list_item.dart deleted
-3
@@ -1,3 +0,0 @@
1 -abstract class ActionListItem {
2 - DateTime get date;
3 -}
\ No newline at end of file
lib/src/stores/action_list/action_list_store.dart deleted
-239
@@ -1,239 +0,0 @@
1 -import 'dart:async';
2 -import 'package:cake_wallet/src/domain/exchange/trade.dart';
3 -import 'package:cake_wallet/src/domain/monero/monero_transaction_info.dart';
4 -import 'package:hive/hive.dart';
5 -import 'package:mobx/mobx.dart';
6 -import 'package:flutter/foundation.dart';
7 -import 'package:cake_wallet/src/domain/monero/account.dart';
8 -import 'package:cake_wallet/src/domain/common/transaction_history.dart';
9 -import 'package:cake_wallet/src/domain/common/transaction_info.dart';
10 -import 'package:cake_wallet/src/domain/common/wallet.dart';
11 -import 'package:cake_wallet/src/domain/services/wallet_service.dart';
12 -import 'package:cake_wallet/src/domain/monero/monero_wallet.dart';
13 -import 'package:cake_wallet/src/domain/common/calculate_fiat_amount_raw.dart';
14 -import 'package:cake_wallet/src/domain/common/crypto_currency.dart';
15 -import 'package:cake_wallet/src/domain/monero/monero_amount_format.dart';
16 -import 'package:cake_wallet/src/domain/monero/transaction_description.dart';
17 -import 'package:cake_wallet/src/stores/price/price_store.dart';
18 -import 'package:cake_wallet/src/stores/settings/settings_store.dart';
19 -import 'package:cake_wallet/src/stores/action_list/action_list_display_mode.dart';
20 -import 'package:cake_wallet/src/stores/action_list/action_list_item.dart';
21 -import 'package:cake_wallet/src/stores/action_list/date_section_item.dart';
22 -import 'package:cake_wallet/src/stores/action_list/trade_filter_store.dart';
23 -import 'package:cake_wallet/src/stores/action_list/trade_list_item.dart';
24 -import 'package:cake_wallet/src/stores/action_list/transaction_filter_store.dart';
25 -import 'package:cake_wallet/src/stores/action_list/transaction_list_item.dart';
26 -
27 -part 'action_list_store.g.dart';
28 -
29 -class ActionListStore = ActionListBase with _$ActionListStore;
30 -
31 -abstract class ActionListBase with Store {
32 - ActionListBase(
33 - {@required WalletService walletService,
34 - @required SettingsStore settingsStore,
35 - @required PriceStore priceStore,
36 - @required this.transactionFilterStore,
37 - @required this.tradeFilterStore,
38 - @required this.transactionDescriptions,
39 - @required this.tradesSource}) {
40 - trades = List<TradeListItem>();
41 - _transactions = List<TransactionListItem>();
42 - _walletService = walletService;
43 - _settingsStore = settingsStore;
44 - _priceStore = priceStore;
45 -
46 - if (walletService.currentWallet != null) {
47 - _onWalletChanged(walletService.currentWallet);
48 - }
49 -
50 - _onWalletChangeSubscription =
51 - walletService.onWalletChange.listen(_onWalletChanged);
52 -
53 - _onTransactionDescriptions = transactionDescriptions
54 - .watch()
55 - .listen((_) async => await _updateTransactionsList());
56 -
57 - _onTradesChanged =
58 - tradesSource.watch().listen((_) async => await updateTradeList());
59 -
60 - updateTradeList();
61 - }
62 -
63 - static List<ActionListItem> formattedItemsList(List<ActionListItem> items) {
64 - final formattedList = List<ActionListItem>();
65 - DateTime lastDate;
66 - items.sort((a, b) => b.date.compareTo(a.date));
67 -
68 - for (int i = 0; i < items.length; i++) {
69 - final transaction = items[i];
70 -
71 - if (lastDate == null) {
72 - lastDate = transaction.date;
73 - formattedList.add(DateSectionItem(transaction.date));
74 - formattedList.add(transaction);
75 - continue;
76 - }
77 -
78 - final isCurrentDay = lastDate.year == transaction.date.year &&
79 - lastDate.month == transaction.date.month &&
80 - lastDate.day == transaction.date.day;
81 -
82 - if (isCurrentDay) {
83 - formattedList.add(transaction);
84 - continue;
85 - }
86 -
87 - lastDate = transaction.date;
88 - formattedList.add(DateSectionItem(transaction.date));
89 - formattedList.add(transaction);
90 - }
91 -
92 - return formattedList;
93 - }
94 -
95 - @computed
96 - List<TransactionListItem> get transactions {
97 - final symbol = PriceStoreBase.generateSymbolForPair(
98 - fiat: _settingsStore.fiatCurrency, crypto: CryptoCurrency.xmr);
99 - final price = _priceStore.prices[symbol];
100 -
101 - _transactions.forEach((item) {
102 - final tx = item.transaction;
103 -
104 - if (tx is MoneroTransactionInfo) {
105 - final amount = calculateFiatAmountRaw(
106 - cryptoAmount: moneroAmountToDouble(amount: tx.amount),
107 - price: price);
108 - tx.changeFiatAmount(amount);
109 - }
110 - });
111 -
112 - return _transactions;
113 - }
114 -
115 - @observable
116 - List<TransactionListItem> _transactions;
117 -
118 - @observable
119 - List<TradeListItem> trades;
120 -
121 - @computed
122 - List<ActionListItem> get items {
123 - final _items = List<ActionListItem>();
124 -
125 - if (_settingsStore.actionlistDisplayMode
126 - .contains(ActionListDisplayMode.transactions)) {
127 - _items
128 - .addAll(transactionFilterStore.filtered(transactions: transactions));
129 - }
130 -
131 - if (_settingsStore.actionlistDisplayMode
132 - .contains(ActionListDisplayMode.trades)) {
133 - _items.addAll(tradeFilterStore.filtered(trades: trades));
134 - }
135 -
136 - return formattedItemsList(_items);
137 - }
138 -
139 - @computed
140 - int get totalCount => transactions.length + trades.length;
141 -
142 - TransactionFilterStore transactionFilterStore;
143 - TradeFilterStore tradeFilterStore;
144 - Box<TransactionDescription> transactionDescriptions;
145 - Box<Trade> tradesSource;
146 -
147 - WalletService _walletService;
148 - TransactionHistory _history;
149 - SettingsStore _settingsStore;
150 - PriceStore _priceStore;
151 - Account _account;
152 - StreamSubscription<Wallet> _onWalletChangeSubscription;
153 - StreamSubscription<List<TransactionInfo>> _onTransactionsChangeSubscription;
154 - StreamSubscription<Account> _onAccountChangeSubscription;
155 - StreamSubscription<BoxEvent> _onTransactionDescriptions;
156 - StreamSubscription<BoxEvent> _onTradesChanged;
157 -
158 - // @override
159 - // void dispose() {
160 - // if (_onTransactionsChangeSubscription != null) {
161 - // _onTransactionsChangeSubscription.cancel();
162 - // }
163 -
164 - // if (_onAccountChangeSubscription != null) {
165 - // _onAccountChangeSubscription.cancel();
166 - // }
167 -
168 - // _onTransactionDescriptions?.cancel();
169 - // _onWalletChangeSubscription.cancel();
170 - // _onTradesChanged?.cancel();
171 - // super.dispose();
172 - // }
173 -
174 - @action
175 - Future updateTradeList() async => this.trades =
176 - tradesSource.values.map((trade) => TradeListItem(trade: trade)).toList();
177 -
178 - Future _updateTransactionsList() async {
179 - final _transactions = await _history.getAll();
180 - await _setTransactions(_transactions);
181 - }
182 -
183 - Future _onWalletChanged(Wallet wallet) async {
184 - if (_onTransactionsChangeSubscription != null) {
185 - await _onTransactionsChangeSubscription.cancel();
186 - }
187 -
188 - if (_onAccountChangeSubscription != null) {
189 - await _onAccountChangeSubscription.cancel();
190 - }
191 -
192 - _history = wallet.getHistory();
193 - _onTransactionsChangeSubscription = _history.transactions
194 - .listen((transactions) => _setTransactions(transactions));
195 -
196 - if (wallet is MoneroWallet) {
197 - _account = wallet.account;
198 - _onAccountChangeSubscription = wallet.onAccountChange.listen((account) {
199 - _account = account;
200 - _updateTransactionsList();
201 - });
202 - }
203 -
204 - await _updateTransactionsList();
205 - }
206 -
207 - Future _setTransactions(List<TransactionInfo> transactions) async {
208 - final wallet = _walletService.currentWallet;
209 - List<TransactionInfo> sortedTransactions = transactions.map((transaction) {
210 - if (transaction is MoneroTransactionInfo) {
211 - if (transactionDescriptions.values.isNotEmpty) {
212 - final description = transactionDescriptions.values.firstWhere(
213 - (desc) => desc.id == transaction.id,
214 - orElse: () => null);
215 -
216 - if (description != null && description.recipientAddress != null) {
217 - transaction.recipientAddress = description.recipientAddress;
218 - }
219 - }
220 -
221 - return transaction;
222 - }
223 -
224 - return transaction;
225 - }).toList();
226 -
227 - if (wallet is MoneroWallet) {
228 - sortedTransactions = transactions
229 - .where((tx) => tx is MoneroTransactionInfo
230 - ? tx.accountIndex == _account.id
231 - : false)
232 - .toList();
233 - }
234 -
235 - this._transactions = sortedTransactions
236 - .map((transaction) => TransactionListItem(transaction: transaction))
237 - .toList();
238 - }
239 -}
lib/src/stores/action_list/date_section_item.dart deleted
-8
@@ -1,8 +0,0 @@
1 -import 'package:cake_wallet/src/stores/action_list/action_list_item.dart';
2 -
3 -class DateSectionItem extends ActionListItem {
4 - DateSectionItem(this.date);
5 -
6 - @override
7 - final DateTime date;
8 -}
\ No newline at end of file
lib/src/stores/action_list/trade_filter_store.dart deleted
-62
@@ -1,62 +0,0 @@
1 -import 'package:cake_wallet/src/stores/wallet/wallet_store.dart';
2 -import 'package:mobx/mobx.dart';
3 -import 'package:cake_wallet/src/domain/exchange/exchange_provider_description.dart';
4 -import 'package:cake_wallet/src/stores/action_list/trade_list_item.dart';
5 -
6 -part 'trade_filter_store.g.dart';
7 -
8 -class TradeFilterStore = TradeFilterStoreBase with _$TradeFilterStore;
9 -
10 -abstract class TradeFilterStoreBase with Store {
11 - TradeFilterStoreBase(
12 - {this.displayXMRTO = true,
13 - this.displayChangeNow = true,
14 - this.displayMorphToken = true,
15 - this.walletStore});
16 -
17 - @observable
18 - bool displayXMRTO;
19 -
20 - @observable
21 - bool displayChangeNow;
22 -
23 - @observable
24 - bool displayMorphToken;
25 -
26 - WalletStore walletStore;
27 -
28 - @action
29 - void toggleDisplayExchange(ExchangeProviderDescription provider) {
30 - switch (provider) {
31 - case ExchangeProviderDescription.changeNow:
32 - displayChangeNow = !displayChangeNow;
33 - break;
34 - case ExchangeProviderDescription.xmrto:
35 - displayXMRTO = !displayXMRTO;
36 - break;
37 - case ExchangeProviderDescription.morphToken:
38 - displayMorphToken = !displayMorphToken;
39 - break;
40 - }
41 - }
42 -
43 - List<TradeListItem> filtered({List<TradeListItem> trades}) {
44 - final _trades =
45 - trades.where((item) => item.trade.walletId == walletStore.id).toList();
46 - final needToFilter = !displayChangeNow || !displayXMRTO || !displayMorphToken;
47 -
48 - return needToFilter
49 - ? trades
50 - .where((item) =>
51 - (displayXMRTO &&
52 - item.trade.provider == ExchangeProviderDescription.xmrto) ||
53 - (displayChangeNow &&
54 - item.trade.provider ==
55 - ExchangeProviderDescription.changeNow) ||
56 - (displayMorphToken &&
57 - item.trade.provider ==
58 - ExchangeProviderDescription.morphToken))
59 - .toList()
60 - : _trades;
61 - }
62 -}
lib/src/stores/action_list/trade_list_item.dart deleted
-11
@@ -1,11 +0,0 @@
1 -import 'package:cake_wallet/src/domain/exchange/trade.dart';
2 -import 'package:cake_wallet/src/stores/action_list/action_list_item.dart';
3 -
4 -class TradeListItem extends ActionListItem {
5 - TradeListItem({this.trade});
6 -
7 - final Trade trade;
8 -
9 - @override
10 - DateTime get date => trade.createdAt;
11 -}
lib/src/stores/action_list/transaction_filter_store.dart deleted
-69
@@ -1,69 +0,0 @@
1 -import 'package:mobx/mobx.dart';
2 -import 'package:cake_wallet/src/domain/common/transaction_direction.dart';
3 -import 'package:cake_wallet/src/stores/action_list/transaction_list_item.dart';
4 -
5 -part 'transaction_filter_store.g.dart';
6 -
7 -class TransactionFilterStore = TransactionFilterStoreBase
8 - with _$TransactionFilterStore;
9 -
10 -abstract class TransactionFilterStoreBase with Store {
11 - TransactionFilterStoreBase(
12 - {this.displayIncoming = true, this.displayOutgoing = true});
13 -
14 - @observable
15 - bool displayIncoming;
16 -
17 - @observable
18 - bool displayOutgoing;
19 -
20 - @observable
21 - DateTime startDate;
22 -
23 - @observable
24 - DateTime endDate;
25 -
26 - @action
27 - void toggleIncoming() => displayIncoming = !displayIncoming;
28 -
29 - @action
30 - void toggleOutgoing() => displayOutgoing = !displayOutgoing;
31 -
32 - @action
33 - void changeStartDate(DateTime date) => startDate = date;
34 -
35 - @action
36 - void changeEndDate(DateTime date) => endDate = date;
37 -
38 - List<TransactionListItem> filtered({List<TransactionListItem> transactions}) {
39 - List<TransactionListItem> _transactions = [];
40 - final needToFilter = !displayOutgoing ||
41 - !displayIncoming ||
42 - (startDate != null && endDate != null);
43 -
44 - if (needToFilter) {
45 - _transactions = transactions.where((item) {
46 - var allowed = true;
47 -
48 - if (allowed && startDate != null && endDate != null) {
49 - allowed = startDate.isBefore(item.transaction.date) &&
50 - endDate.isAfter(item.transaction.date);
51 - }
52 -
53 - if (allowed && (!displayOutgoing || !displayIncoming)) {
54 - allowed = (displayOutgoing &&
55 - item.transaction.direction ==
56 - TransactionDirection.outgoing) ||
57 - (displayIncoming &&
58 - item.transaction.direction == TransactionDirection.incoming);
59 - }
60 -
61 - return allowed;
62 - }).toList();
63 - } else {
64 - _transactions = transactions;
65 - }
66 -
67 - return _transactions;
68 - }
69 -}
lib/src/stores/action_list/transaction_list_item.dart deleted
-11
@@ -1,11 +0,0 @@
1 -import 'package:cake_wallet/src/domain/common/transaction_info.dart';
2 -import 'package:cake_wallet/src/stores/action_list/action_list_item.dart';
3 -
4 -class TransactionListItem extends ActionListItem {
5 - TransactionListItem({this.transaction});
6 -
7 - final TransactionInfo transaction;
8 -
9 - @override
10 - DateTime get date => transaction.date;
11 -}
\ No newline at end of file
lib/src/stores/address_book/address_book_store.dart deleted
-111
@@ -1,111 +0,0 @@
1 -//import 'package:mobx/mobx.dart';
2 -//import 'package:flutter/foundation.dart';
3 -//import 'package:cake_wallet/generated/i18n.dart';
4 -//import 'package:cake_wallet/src/domain/common/contact.dart';
5 -//import 'package:cake_wallet/src/domain/common/crypto_currency.dart';
6 -//import 'package:hive/hive.dart';
7 -//
8 -//part 'address_book_store.g.dart';
9 -//
10 -//class AddressBookStore = AddressBookStoreBase with _$AddressBookStore;
11 -//
12 -//abstract class AddressBookStoreBase with Store {
13 -// AddressBookStoreBase({@required this.contacts}) {
14 -// updateContactList();
15 -// isDisabledStatus = true;
16 -// }
17 -//
18 -// @observable
19 -// List<Contact> contactList;
20 -//
21 -// @observable
22 -// bool isDisabledStatus;
23 -//
24 -// @observable
25 -// bool isValid;
26 -//
27 -// @observable
28 -// String errorMessage;
29 -//
30 -// Box<Contact> contacts;
31 -//
32 -// @action
33 -// Future add({Contact contact}) async => contacts.add(contact);
34 -//
35 -// @action
36 -// Future updateContactList() async => contactList = contacts.values.toList();
37 -//
38 -// @action
39 -// Future update({Contact contact}) async => contact.save();
40 -//
41 -// @action
42 -// Future delete({Contact contact}) async => await contact.delete();
43 -//
44 -// @action
45 -// void setDisabledStatus(bool isDisabled) {
46 -// isDisabledStatus = isDisabled;
47 -// }
48 -//
49 -// void validateContactName(String value) {
50 -// const pattern = '''^[^`,'"]{1,32}\$''';
51 -// final regExp = RegExp(pattern);
52 -// isValid = regExp.hasMatch(value);
53 -// errorMessage = isValid ? null : S.current.error_text_contact_name;
54 -// }
55 -//
56 -// void validateAddress(String value, {CryptoCurrency cryptoCurrency}) {
57 -// // XMR (95, 106), ADA (59, 92, 105), BCH (42), BNB (42), BTC (34, 42), DASH (34), EOS (42),
58 -// // ETH (42), LTC (34), NANO (64, 65), TRX (34), USDT (42), XLM (56), XRP (34)
59 -// const pattern = '^[0-9a-zA-Z]{95}\$|^[0-9a-zA-Z]{34}\$|^[0-9a-zA-Z]{42}\$|^[0-9a-zA-Z]{56}\$|^[0-9a-zA-Z]{59}\$|^[0-9a-zA-Z_]{64}\$|^[0-9a-zA-Z_]{65}\$|^[0-9a-zA-Z]{92}\$|^[0-9a-zA-Z]{105}\$|^[0-9a-zA-Z]{106}\$';
60 -// final regExp = RegExp(pattern);
61 -// isValid = regExp.hasMatch(value);
62 -// if (isValid && cryptoCurrency != null) {
63 -// switch (cryptoCurrency) {
64 -// case CryptoCurrency.xmr:
65 -// isValid = (value.length == 95)||(value.length == 106);
66 -// break;
67 -// case CryptoCurrency.ada:
68 -// isValid = (value.length == 59)||(value.length == 92)||(value.length == 105);
69 -// break;
70 -// case CryptoCurrency.bch:
71 -// isValid = (value.length == 42);
72 -// break;
73 -// case CryptoCurrency.bnb:
74 -// isValid = (value.length == 42);
75 -// break;
76 -// case CryptoCurrency.btc:
77 -// isValid = (value.length == 34)||(value.length == 42);
78 -// break;
79 -// case CryptoCurrency.dash:
80 -// isValid = (value.length == 34);
81 -// break;
82 -// case CryptoCurrency.eos:
83 -// isValid = (value.length == 42);
84 -// break;
85 -// case CryptoCurrency.eth:
86 -// isValid = (value.length == 42);
87 -// break;
88 -// case CryptoCurrency.ltc:
89 -// isValid = (value.length == 34);
90 -// break;
91 -// case CryptoCurrency.nano:
92 -// isValid = (value.length == 64)||(value.length == 65);
93 -// break;
94 -// case CryptoCurrency.trx:
95 -// isValid = (value.length == 34);
96 -// break;
97 -// case CryptoCurrency.usdt:
98 -// isValid = (value.length == 42);
99 -// break;
100 -// case CryptoCurrency.xlm:
101 -// isValid = (value.length == 56);
102 -// break;
103 -// case CryptoCurrency.xrp:
104 -// isValid = (value.length == 34);
105 -// break;
106 -// }
107 -// }
108 -//
109 -// errorMessage = isValid ? null : S.current.error_text_address;
110 -// }
111 -//}
lib/src/stores/auth/auth_store.dart deleted
-99
@@ -1,99 +0,0 @@
1 -//import 'dart:async';
2 -//import 'package:flutter/foundation.dart';
3 -//import 'package:shared_preferences/shared_preferences.dart';
4 -//import 'package:mobx/mobx.dart';
5 -//import 'package:cake_wallet/src/domain/services/user_service.dart';
6 -//import 'package:cake_wallet/src/domain/services/wallet_service.dart';
7 -//import 'package:cake_wallet/view_model/auth_state.dart';
8 -//import 'package:cake_wallet/generated/i18n.dart';
9 -//
10 -//part 'auth_store.g.dart';
11 -//
12 -//class AuthStore = AuthStoreBase with _$AuthStore;
13 -//
14 -//abstract class AuthStoreBase with Store {
15 -// AuthStoreBase(
16 -// {@required this.userService,
17 -// @required this.walletService,
18 -// @required this.sharedPreferences}) {
19 -// state = AuthenticationStateInitial();
20 -// _failureCounter = 0;
21 -// }
22 -//
23 -// static const maxFailedLogins = 3;
24 -// static const banTimeout = 180; // 3 mins
25 -// final banTimeoutKey = S.current.auth_store_ban_timeout;
26 -//
27 -// final UserService userService;
28 -// final WalletService walletService;
29 -//
30 -// final SharedPreferences sharedPreferences;
31 -//
32 -// @observable
33 -// AuthState state;
34 -//
35 -// @observable
36 -// int _failureCounter;
37 -//
38 -// @action
39 -// Future auth({String password}) async {
40 -// state = AuthenticationStateInitial();
41 -// final _banDuration = banDuration();
42 -//
43 -// if (_banDuration != null) {
44 -// state = AuthenticationBanned(
45 -// error: S.current.auth_store_banned_for + '${_banDuration.inMinutes}' + S.current.auth_store_banned_minutes);
46 -// return;
47 -// }
48 -//
49 -// state = AuthenticationInProgress();
50 -// final isAuth = await userService.authenticate(password);
51 -//
52 -// if (isAuth) {
53 -// state = AuthenticatedSuccessfully();
54 -// _failureCounter = 0;
55 -// } else {
56 -// _failureCounter += 1;
57 -//
58 -// if (_failureCounter >= maxFailedLogins) {
59 -// final banDuration = await ban();
60 -// state = AuthenticationBanned(
61 -// error: S.current.auth_store_banned_for + '${banDuration.inMinutes}' + S.current.auth_store_banned_minutes);
62 -// return;
63 -// }
64 -//
65 -// state = AuthenticationFailure(error: S.current.auth_store_incorrect_password);
66 -// }
67 -// }
68 -//
69 -// Duration banDuration() {
70 -// final unbanTimestamp = sharedPreferences.getInt(banTimeoutKey);
71 -//
72 -// if (unbanTimestamp == null) {
73 -// return null;
74 -// }
75 -//
76 -// final unbanTime = DateTime.fromMillisecondsSinceEpoch(unbanTimestamp);
77 -// final now = DateTime.now();
78 -//
79 -// if (now.isAfter(unbanTime)) {
80 -// return null;
81 -// }
82 -//
83 -// return Duration(milliseconds: unbanTimestamp - now.millisecondsSinceEpoch);
84 -// }
85 -//
86 -// Future<Duration> ban() async {
87 -// final multiplier = _failureCounter - maxFailedLogins + 1;
88 -// final timeout = (multiplier * banTimeout) * 1000;
89 -// final unbanTimestamp = DateTime.now().millisecondsSinceEpoch + timeout;
90 -// await sharedPreferences.setInt(banTimeoutKey, unbanTimestamp);
91 -//
92 -// return Duration(milliseconds: timeout);
93 -// }
94 -//
95 -// @action
96 -// void biometricAuth() {
97 -// state = AuthenticatedSuccessfully();
98 -// }
99 -//}
lib/src/stores/authentication/authentication_store.dart deleted
-70
@@ -1,70 +0,0 @@
1 -import 'dart:async';
2 -import 'package:flutter/foundation.dart';
3 -import 'package:mobx/mobx.dart';
4 -import 'package:cake_wallet/src/domain/services/user_service.dart';
5 -
6 -part 'authentication_store.g.dart';
7 -
8 -class AuthenticationStore = AuthenticationStoreBase with _$AuthenticationStore;
9 -
10 -enum AuthenticationState {
11 - uninitialized,
12 - allowed,
13 - denied,
14 - authenticated,
15 - unauthenticated,
16 - active,
17 - loading,
18 - created,
19 - restored,
20 - readyToLogin
21 -}
22 -
23 -abstract class AuthenticationStoreBase with Store {
24 - AuthenticationStoreBase({@required this.userService}) {
25 - state = AuthenticationState.uninitialized;
26 - }
27 -
28 - final UserService userService;
29 -
30 - @observable
31 - AuthenticationState state;
32 -
33 -// @observable
34 -// String errorMessage;
35 -
36 - Future started() async {
37 - final canAuth = await userService.canAuthenticate();
38 - state = canAuth ? AuthenticationState.allowed : AuthenticationState.denied;
39 - }
40 -
41 - @action
42 - void created() {
43 - state = AuthenticationState.created;
44 - }
45 -
46 - @action
47 - void restored() {
48 - state = AuthenticationState.restored;
49 - }
50 -
51 - @action
52 - void loggedIn() {
53 - state = AuthenticationState.authenticated;
54 - }
55 -
56 - @action
57 - void inactive() {
58 - state = AuthenticationState.unauthenticated;
59 - }
60 -
61 - @action
62 - void active() {
63 - state = AuthenticationState.active;
64 - }
65 -
66 - @action
67 - void loggedOut() {
68 - state = AuthenticationState.uninitialized;
69 - }
70 -}
lib/src/stores/balance/balance_store.dart deleted
-134
@@ -1,134 +0,0 @@
1 -import 'dart:async';
2 -import 'package:cake_wallet/bitcoin/bitcoin_balance.dart';
3 -import 'package:mobx/mobx.dart';
4 -import 'package:flutter/foundation.dart';
5 -import 'package:cake_wallet/src/domain/common/wallet.dart';
6 -import 'package:cake_wallet/src/domain/common/balance.dart';
7 -import 'package:cake_wallet/src/domain/services/wallet_service.dart';
8 -import 'package:cake_wallet/src/domain/monero/monero_balance.dart';
9 -import 'package:cake_wallet/src/domain/common/crypto_currency.dart';
10 -import 'package:cake_wallet/src/domain/common/calculate_fiat_amount.dart';
11 -import 'package:cake_wallet/src/stores/price/price_store.dart';
12 -import 'package:cake_wallet/src/stores/settings/settings_store.dart';
13 -
14 -part 'balance_store.g.dart';
15 -
16 -class BalanceStore = BalanceStoreBase with _$BalanceStore;
17 -
18 -abstract class BalanceStoreBase with Store {
19 - BalanceStoreBase(
20 - {String fullBalance = '0.0',
21 - String unlockedBalance = '0.0',
22 - @required WalletService walletService,
23 - @required SettingsStore settingsStore,
24 - @required PriceStore priceStore}) {
25 - fullBalance = fullBalance;
26 - unlockedBalance = unlockedBalance;
27 - isReversing = false;
28 - _walletService = walletService;
29 - _settingsStore = settingsStore;
30 - _priceStore = priceStore;
31 -
32 - if (_walletService.currentWallet != null) {
33 - _onWalletChanged(_walletService.currentWallet);
34 - }
35 -
36 - _onWalletChangeSubscription = _walletService.onWalletChange
37 - .listen((wallet) => _onWalletChanged(wallet));
38 - }
39 -
40 - @observable
41 - String fullBalance;
42 -
43 - @observable
44 - String unlockedBalance;
45 -
46 - @computed
47 - String get fiatFullBalance {
48 - if (fullBalance == null) {
49 - return '0.00';
50 - }
51 -
52 - final symbol = PriceStoreBase.generateSymbolForPair(
53 - fiat: _settingsStore.fiatCurrency, crypto: CryptoCurrency.xmr);
54 - final price = _priceStore.prices[symbol];
55 - return calculateFiatAmount(price: price, cryptoAmount: fullBalance);
56 - }
57 -
58 - @computed
59 - String get fiatUnlockedBalance {
60 - if (unlockedBalance == null) {
61 - return '0.00';
62 - }
63 -
64 - final symbol = PriceStoreBase.generateSymbolForPair(
65 - fiat: _settingsStore.fiatCurrency, crypto: CryptoCurrency.xmr);
66 - final price = _priceStore.prices[symbol];
67 - return calculateFiatAmount(price: price, cryptoAmount: unlockedBalance);
68 - }
69 -
70 - @observable
71 - bool isReversing;
72 -
73 - WalletService _walletService;
74 - StreamSubscription<Wallet> _onWalletChangeSubscription;
75 - StreamSubscription<Balance> _onBalanceChangeSubscription;
76 - SettingsStore _settingsStore;
77 - PriceStore _priceStore;
78 -
79 - // @override
80 - // void dispose() {
81 - // _onWalletChangeSubscription.cancel();
82 -
83 - // if (_onBalanceChangeSubscription != null) {
84 - // _onBalanceChangeSubscription.cancel();
85 - // }
86 -
87 - // super.dispose();
88 - // }
89 -
90 - Future _onBalanceChange(Balance balance) async {
91 - if (balance is MoneroBalance) {
92 - await _onMoneroBalanceChange(balance);
93 - }
94 -
95 - if (balance is BitcoinBalance) {
96 - await _onBitcoinBalanceChange(balance);
97 - }
98 - }
99 -
100 - Future _onMoneroBalanceChange(MoneroBalance balance) async {
101 - if (this.fullBalance != balance.fullBalance) {
102 - this.fullBalance = balance.fullBalance;
103 - }
104 -
105 - if (this.unlockedBalance != balance.unlockedBalance) {
106 - this.unlockedBalance = balance.unlockedBalance;
107 - }
108 - }
109 -
110 - Future _onBitcoinBalanceChange(BitcoinBalance balance) async {
111 - fullBalance = balance.totalFormatted;
112 - unlockedBalance = balance.totalFormatted;
113 - }
114 -
115 - Future _onWalletChanged(Wallet wallet) async {
116 - if (_onBalanceChangeSubscription != null) {
117 - await _onBalanceChangeSubscription.cancel();
118 - }
119 -
120 - _onBalanceChangeSubscription = _walletService.onBalanceChange
121 - .listen((balance) async => await _onBalanceChange(balance));
122 -
123 - await _updateBalances(wallet);
124 - }
125 -
126 - Future _updateBalances(Wallet wallet) async {
127 - if (wallet == null) {
128 - return;
129 - }
130 -
131 - fullBalance = await _walletService.getFullBalance();
132 - unlockedBalance = await _walletService.getUnlockedBalance();
133 - }
134 -}
lib/src/stores/exchange/exchange_store.dart deleted
-352
@@ -1,352 +0,0 @@
1 -import 'package:flutter/foundation.dart';
2 -import 'package:hive/hive.dart';
3 -import 'package:mobx/mobx.dart';
4 -import 'package:cake_wallet/src/domain/common/crypto_currency.dart';
5 -import 'package:cake_wallet/src/domain/exchange/changenow/changenow_exchange_provider.dart';
6 -import 'package:cake_wallet/src/domain/exchange/changenow/changenow_request.dart';
7 -import 'package:cake_wallet/src/domain/exchange/exchange_provider.dart';
8 -import 'package:cake_wallet/src/domain/exchange/trade_request.dart';
9 -import 'package:cake_wallet/src/domain/exchange/xmrto/xmrto_exchange_provider.dart';
10 -import 'package:cake_wallet/src/domain/exchange/xmrto/xmrto_trade_request.dart';
11 -import 'package:cake_wallet/src/domain/exchange/morphtoken/morphtoken_exchange_provider.dart';
12 -import 'package:cake_wallet/src/domain/exchange/morphtoken/morphtoken_request.dart';
13 -import 'package:cake_wallet/src/domain/exchange/trade.dart';
14 -import 'package:cake_wallet/src/stores/wallet/wallet_store.dart';
15 -import 'package:cake_wallet/src/stores/exchange/exchange_trade_state.dart';
16 -import 'package:cake_wallet/src/stores/exchange/limits_state.dart';
17 -import 'package:cake_wallet/generated/i18n.dart';
18 -import 'package:cake_wallet/src/domain/exchange/limits.dart';
19 -import 'package:intl/intl.dart';
20 -
21 -part 'exchange_store.g.dart';
22 -
23 -class ExchangeStore = ExchangeStoreBase with _$ExchangeStore;
24 -
25 -abstract class ExchangeStoreBase with Store {
26 - ExchangeStoreBase(
27 - {@required ExchangeProvider initialProvider,
28 - @required CryptoCurrency initialDepositCurrency,
29 - @required CryptoCurrency initialReceiveCurrency,
30 - @required this.providerList,
31 - @required this.trades,
32 - @required this.walletStore}) {
33 - provider = initialProvider;
34 - depositCurrency = initialDepositCurrency;
35 - receiveCurrency = initialReceiveCurrency;
36 - isDepositAddressEnabled = !(depositCurrency == walletStore.type);
37 - isReceiveAddressEnabled = !(receiveCurrency == walletStore.type);
38 - depositAmount = '';
39 - receiveAmount = '';
40 - depositAddress = '';
41 - receiveAddress = '';
42 - limitsState = LimitsInitialState();
43 - tradeState = ExchangeTradeStateInitial();
44 - _cryptoNumberFormat = NumberFormat()..maximumFractionDigits = 12;
45 - loadLimits();
46 - }
47 -
48 - @observable
49 - ExchangeProvider provider;
50 -
51 - @observable
52 - List<ExchangeProvider> providerList;
53 -
54 - @observable
55 - CryptoCurrency depositCurrency;
56 -
57 - @observable
58 - CryptoCurrency receiveCurrency;
59 -
60 - @observable
61 - LimitsState limitsState;
62 -
63 - @observable
64 - ExchangeTradeState tradeState;
65 -
66 - @observable
67 - String depositAmount;
68 -
69 - @observable
70 - String receiveAmount;
71 -
72 - @observable
73 - String depositAddress;
74 -
75 - @observable
76 - String receiveAddress;
77 -
78 - @observable
79 - bool isDepositAddressEnabled;
80 -
81 - @observable
82 - bool isReceiveAddressEnabled;
83 -
84 - @observable
85 - bool isValid;
86 -
87 - @observable
88 - String errorMessage;
89 -
90 - Box<Trade> trades;
91 -
92 - WalletStore walletStore;
93 -
94 - Limits limits;
95 -
96 - NumberFormat _cryptoNumberFormat;
97 -
98 - @action
99 - void changeProvider({ExchangeProvider provider}) {
100 - this.provider = provider;
101 - depositAmount = '';
102 - receiveAmount = '';
103 - loadLimits();
104 - }
105 -
106 - @action
107 - void changeDepositCurrency({CryptoCurrency currency}) {
108 - depositCurrency = currency;
109 - _onPairChange();
110 - isDepositAddressEnabled = !(depositCurrency == walletStore.type);
111 - isReceiveAddressEnabled = !(receiveCurrency == walletStore.type);
112 - }
113 -
114 - @action
115 - void changeReceiveCurrency({CryptoCurrency currency}) {
116 - receiveCurrency = currency;
117 - _onPairChange();
118 - isDepositAddressEnabled = !(depositCurrency == walletStore.type);
119 - isReceiveAddressEnabled = !(receiveCurrency == walletStore.type);
120 - }
121 -
122 - @action
123 - void changeReceiveAmount({String amount}) {
124 - receiveAmount = amount;
125 -
126 - if (amount == null || amount.isEmpty) {
127 - depositAmount = '';
128 - receiveAmount = '';
129 - return;
130 - }
131 -
132 - final _amount = double.parse(amount) ?? 0;
133 -
134 - provider
135 - .calculateAmount(
136 - from: depositCurrency, to: receiveCurrency, amount: _amount)
137 - .then((amount) => _cryptoNumberFormat.format(amount).toString().replaceAll(RegExp("\\,"), ""))
138 - .then((amount) => depositAmount = amount);
139 - }
140 -
141 - @action
142 - void changeDepositAmount({String amount}) {
143 - depositAmount = amount;
144 -
145 - if (amount == null || amount.isEmpty) {
146 - depositAmount = '';
147 - receiveAmount = '';
148 - return;
149 - }
150 -
151 - final _amount = double.parse(amount);
152 - provider
153 - .calculateAmount(
154 - from: depositCurrency, to: receiveCurrency, amount: _amount)
155 - .then((amount) => _cryptoNumberFormat.format(amount).toString().replaceAll(RegExp("\\,"), ""))
156 - .then((amount) => receiveAmount = amount);
157 - }
158 -
159 - @action
160 - Future loadLimits() async {
161 - limitsState = LimitsIsLoading();
162 -
163 - try {
164 - limits = await provider.fetchLimits(
165 - from: depositCurrency, to: receiveCurrency);
166 - limitsState = LimitsLoadedSuccessfully(limits: limits);
167 - } catch (e) {
168 - limitsState = LimitsLoadedFailure(error: e.toString());
169 - }
170 - }
171 -
172 - @action
173 - Future createTrade() async {
174 - TradeRequest request;
175 - String amount;
176 - CryptoCurrency currency;
177 -
178 - if (provider is XMRTOExchangeProvider) {
179 - request = XMRTOTradeRequest(
180 - from: depositCurrency,
181 - to: receiveCurrency,
182 - amount: depositAmount,
183 - address: receiveAddress,
184 - refundAddress: depositAddress);
185 - amount = depositAmount;
186 - currency = depositCurrency;
187 - }
188 -
189 - if (provider is ChangeNowExchangeProvider) {
190 - request = ChangeNowRequest(
191 - from: depositCurrency,
192 - to: receiveCurrency,
193 - amount: depositAmount,
194 - refundAddress: depositAddress,
195 - address: receiveAddress);
196 - amount = depositAmount;
197 - currency = depositCurrency;
198 - }
199 -
200 - if (provider is MorphTokenExchangeProvider) {
201 - request = MorphTokenRequest(
202 - from: depositCurrency,
203 - to: receiveCurrency,
204 - amount: depositAmount,
205 - refundAddress: depositAddress,
206 - address: receiveAddress);
207 - amount = depositAmount;
208 - currency = depositCurrency;
209 - }
210 -
211 - if (limitsState is LimitsLoadedSuccessfully && amount != null) {
212 - if (double.parse(amount) < limits.min) {
213 - tradeState = TradeIsCreatedFailure(error: S.current.error_text_minimal_limit("${provider.description}",
214 - "${limits.min}", currency.toString()));
215 - } else if (limits.max != null && double.parse(amount) > limits.max) {
216 - tradeState = TradeIsCreatedFailure(error: S.current.error_text_maximum_limit("${provider.description}",
217 - "${limits.max}", currency.toString()));
218 - } else {
219 - try {
220 - tradeState = TradeIsCreating();
221 - final trade = await provider.createTrade(request: request);
222 - trade.walletId = walletStore.id;
223 - await trades.add(trade);
224 - tradeState = TradeIsCreatedSuccessfully(trade: trade);
225 - } catch (e) {
226 - tradeState = TradeIsCreatedFailure(error: e.toString());
227 - }
228 - }
229 - } else {
230 - tradeState = TradeIsCreatedFailure(error: S.current.error_text_limits_loading_failed("${provider.description}"));
231 - }
232 -
233 - }
234 -
235 - @action
236 - void reset() {
237 - depositAmount = '';
238 - receiveAmount = '';
239 - depositCurrency = CryptoCurrency.xmr;
240 - receiveCurrency = CryptoCurrency.btc;
241 - depositAddress = depositCurrency == walletStore.type ? walletStore.address : '';
242 - receiveAddress = receiveCurrency == walletStore.type ? walletStore.address : '';
243 - isDepositAddressEnabled = !(depositCurrency == walletStore.type);
244 - isReceiveAddressEnabled = !(receiveCurrency == walletStore.type);
245 - _onPairChange();
246 - }
247 -
248 - List<ExchangeProvider> providersForCurrentPair() {
249 - return _providersForPair(from: depositCurrency, to: receiveCurrency);
250 - }
251 -
252 - List<ExchangeProvider> _providersForPair(
253 - {CryptoCurrency from, CryptoCurrency to}) {
254 - final providers = providerList
255 - .where((provider) => provider.pairList
256 - .where((pair) =>
257 - pair.from == depositCurrency && pair.to == receiveCurrency)
258 - .isNotEmpty)
259 - .toList();
260 -
261 - return providers;
262 - }
263 -
264 - void _onPairChange() {
265 - final isPairExist = provider.pairList
266 - .where((pair) =>
267 - pair.from == depositCurrency && pair.to == receiveCurrency)
268 - .isNotEmpty;
269 -
270 - if (!isPairExist) {
271 - final provider =
272 - _providerForPair(from: depositCurrency, to: receiveCurrency);
273 -
274 - if (provider != null) {
275 - changeProvider(provider: provider);
276 - }
277 - }
278 -
279 - depositAmount = '';
280 - receiveAmount = '';
281 -
282 - loadLimits();
283 - }
284 -
285 - ExchangeProvider _providerForPair({CryptoCurrency from, CryptoCurrency to}) {
286 - final providers = _providersForPair(from: from, to: to);
287 - return providers.isNotEmpty ? providers[0] : null;
288 - }
289 -
290 - void validateAddress(String value, {CryptoCurrency cryptoCurrency}) {
291 - // XMR (95, 106), ADA (59, 92, 105), BCH (42), BNB (42), BTC (34, 42), DASH (34), EOS (42),
292 - // ETH (42), LTC (34), NANO (64, 65), TRX (34), USDT (42), XLM (56), XRP (34)
293 - const pattern = '^[0-9a-zA-Z]{95}\$|^[0-9a-zA-Z]{34}\$|^[0-9a-zA-Z]{42}\$|^[0-9a-zA-Z]{56}\$|^[0-9a-zA-Z]{59}\$|^[0-9a-zA-Z_]{64}\$|^[0-9a-zA-Z_]{65}\$|^[0-9a-zA-Z]{92}\$|^[0-9a-zA-Z]{105}\$|^[0-9a-zA-Z]{106}\$';
294 - final regExp = RegExp(pattern);
295 - isValid = regExp.hasMatch(value);
296 - if (isValid && cryptoCurrency != null) {
297 - switch (cryptoCurrency) {
298 - case CryptoCurrency.xmr:
299 - isValid = (value.length == 95)||(value.length == 106);
300 - break;
301 - case CryptoCurrency.ada:
302 - isValid = (value.length == 59)||(value.length == 92)||(value.length == 105);
303 - break;
304 - case CryptoCurrency.bch:
305 - isValid = (value.length == 42);
306 - break;
307 - case CryptoCurrency.bnb:
308 - isValid = (value.length == 42);
309 - break;
310 - case CryptoCurrency.btc:
311 - isValid = (value.length == 34)||(value.length == 42);
312 - break;
313 - case CryptoCurrency.dash:
314 - isValid = (value.length == 34);
315 - break;
316 - case CryptoCurrency.eos:
317 - isValid = (value.length == 42);
318 - break;
319 - case CryptoCurrency.eth:
320 - isValid = (value.length == 42);
321 - break;
322 - case CryptoCurrency.ltc:
323 - isValid = (value.length == 34);
324 - break;
325 - case CryptoCurrency.nano:
326 - isValid = (value.length == 64)||(value.length == 65);
327 - break;
328 - case CryptoCurrency.trx:
329 - isValid = (value.length == 34);
330 - break;
331 - case CryptoCurrency.usdt:
332 - isValid = (value.length == 42);
333 - break;
334 - case CryptoCurrency.xlm:
335 - isValid = (value.length == 56);
336 - break;
337 - case CryptoCurrency.xrp:
338 - isValid = (value.length == 34);
339 - break;
340 - }
341 - }
342 -
343 - errorMessage = isValid ? null : S.current.error_text_address;
344 - }
345 -
346 - void validateCryptoCurrency(String value) {
347 - const pattern = '^([0-9]+([.][0-9]{0,12})?|[.][0-9]{1,12})\$';
348 - final regExp = RegExp(pattern);
349 - isValid = regExp.hasMatch(value);
350 - errorMessage = isValid ? null : S.current.error_text_crypto_currency;
351 - }
352 -}
lib/src/stores/exchange_template/exchange_template_store.dart deleted
-40
@@ -1,40 +0,0 @@
1 -import 'dart:async';
2 -import 'package:mobx/mobx.dart';
3 -import 'package:hive/hive.dart';
4 -import 'package:cake_wallet/src/domain/exchange/exchange_template.dart';
5 -
6 -part 'exchange_template_store.g.dart';
7 -
8 -class ExchangeTemplateStore = ExchangeTemplateBase with _$ExchangeTemplateStore;
9 -
10 -abstract class ExchangeTemplateBase with Store {
11 - ExchangeTemplateBase({this.templateSource}) {
12 - templates = ObservableList<ExchangeTemplate>();
13 - update();
14 - }
15 -
16 - @observable
17 - ObservableList<ExchangeTemplate> templates;
18 -
19 - Box<ExchangeTemplate> templateSource;
20 -
21 - @action
22 - void update() =>
23 - templates.replaceRange(0, templates.length, templateSource.values.toList());
24 -
25 - @action
26 - Future addTemplate({String amount, String depositCurrency, String receiveCurrency,
27 - String provider, String depositAddress, String receiveAddress}) async {
28 - final template = ExchangeTemplate(
29 - amount: amount,
30 - depositCurrency: depositCurrency,
31 - receiveCurrency: receiveCurrency,
32 - provider: provider,
33 - depositAddress: depositAddress,
34 - receiveAddress: receiveAddress);
35 - await templateSource.add(template);
36 - }
37 -
38 - @action
39 - Future remove({ExchangeTemplate template}) async => await template.delete();
40 -}
\ No newline at end of file
lib/src/stores/exchange_trade/exchange_trade_store.dart deleted
-74
@@ -1,74 +0,0 @@
1 -import 'dart:async';
2 -import 'package:mobx/mobx.dart';
3 -import 'package:flutter/foundation.dart';
4 -import 'package:cake_wallet/src/domain/exchange/trade.dart';
5 -import 'package:cake_wallet/src/domain/exchange/exchange_provider.dart';
6 -import 'package:cake_wallet/src/domain/exchange/changenow/changenow_exchange_provider.dart';
7 -import 'package:cake_wallet/src/domain/exchange/exchange_provider_description.dart';
8 -import 'package:cake_wallet/src/domain/exchange/xmrto/xmrto_exchange_provider.dart';
9 -import 'package:cake_wallet/src/domain/exchange/morphtoken/morphtoken_exchange_provider.dart';
10 -import 'package:cake_wallet/src/stores/wallet/wallet_store.dart';
11 -import 'package:hive/hive.dart';
12 -
13 -part 'exchange_trade_store.g.dart';
14 -
15 -class ExchangeTradeStore = ExchangeTradeStoreBase with _$ExchangeTradeStore;
16 -
17 -abstract class ExchangeTradeStoreBase with Store {
18 - ExchangeTradeStoreBase(
19 - {@required this.trade, @required WalletStore walletStore, @required this.trades}) {
20 - isSendable = trade.from == walletStore.type ||
21 - trade.provider == ExchangeProviderDescription.xmrto;
22 -
23 - switch (trade.provider) {
24 - case ExchangeProviderDescription.xmrto:
25 - _provider = XMRTOExchangeProvider();
26 - break;
27 - case ExchangeProviderDescription.changeNow:
28 - _provider = ChangeNowExchangeProvider();
29 - break;
30 - case ExchangeProviderDescription.morphToken:
31 - _provider = MorphTokenExchangeProvider(trades: trades);
32 - break;
33 - }
34 -
35 - _updateTrade();
36 - _timer = Timer.periodic(Duration(seconds: 20), (_) async => _updateTrade());
37 - }
38 -
39 - @observable
40 - Trade trade;
41 -
42 - @observable
43 - bool isSendable;
44 -
45 - Box<Trade> trades;
46 -
47 - ExchangeProvider _provider;
48 -
49 - Timer _timer;
50 -
51 - // @override
52 - // void dispose() {
53 - // super.dispose();
54 -
55 - // if (_timer != null) {
56 - // _timer.cancel();
57 - // }
58 - // }
59 -
60 - @action
61 - Future<void> _updateTrade() async {
62 - try {
63 - final updatedTrade = await _provider.findTradeById(id: trade.id);
64 -
65 - if (updatedTrade.createdAt == null && trade.createdAt != null) {
66 - updatedTrade.createdAt = trade.createdAt;
67 - }
68 -
69 - trade = updatedTrade;
70 - } catch (e) {
71 - print(e.toString());
72 - }
73 - }
74 -}
lib/src/stores/login/login_store.dart deleted
-49
@@ -1,49 +0,0 @@
1 -import 'package:flutter/foundation.dart';
2 -import 'package:mobx/mobx.dart';
3 -import 'package:shared_preferences/shared_preferences.dart';
4 -import 'package:cake_wallet/src/domain/services/wallet_list_service.dart';
5 -
6 -part 'login_store.g.dart';
7 -
8 -abstract class LoginState {}
9 -
10 -class InitialLoginState extends LoginState {}
11 -
12 -class LoadingCurrentWallet extends LoginState {}
13 -
14 -class LoadedCurrentWalletSuccessfully extends LoginState {}
15 -
16 -class LoadedCurrentWalletFailure extends LoginState {
17 - LoadedCurrentWalletFailure({this.errorMessage});
18 -
19 - final String errorMessage;
20 -}
21 -
22 -class LoginStore = LoginStoreBase with _$LoginStore;
23 -
24 -abstract class LoginStoreBase with Store {
25 - LoginStoreBase(
26 - {@required this.sharedPreferences, @required this.walletsService}) {
27 - state = InitialLoginState();
28 - }
29 -
30 - final SharedPreferences sharedPreferences;
31 - final WalletListService walletsService;
32 -
33 - @observable
34 - LoginState state;
35 -
36 - @action
37 - Future loadCurrentWallet() async {
38 - state = InitialLoginState();
39 -
40 - try {
41 - state = LoadingCurrentWallet();
42 - final walletName = sharedPreferences.getString('current_wallet_name');
43 - await walletsService.openWallet(walletName);
44 - state = LoadedCurrentWalletSuccessfully();
45 - } catch (e) {
46 - state = LoadedCurrentWalletFailure(errorMessage: e.toString());
47 - }
48 - }
49 -}
lib/src/stores/node_list/node_list_store.dart deleted
-106
@@ -1,106 +0,0 @@
1 -import 'dart:async';
2 -import 'package:mobx/mobx.dart';
3 -import 'package:hive/hive.dart';
4 -import 'package:cake_wallet/src/domain/common/node.dart';
5 -import 'package:cake_wallet/src/domain/common/node_list.dart';
6 -import 'package:cake_wallet/generated/i18n.dart';
7 -
8 -part 'node_list_store.g.dart';
9 -
10 -class NodeListStore = NodeListBase with _$NodeListStore;
11 -
12 -abstract class NodeListBase with Store {
13 - NodeListBase({this.nodesSource}) {
14 - nodes = ObservableList<Node>();
15 - disabledState = true;
16 - _onNodesChangeSubscription = nodesSource.watch().listen((e) => update());
17 - update();
18 - }
19 -
20 - @observable
21 - ObservableList<Node> nodes;
22 -
23 - @observable
24 - bool isValid;
25 -
26 - @observable
27 - String errorMessage;
28 -
29 - @observable
30 - bool disabledState;
31 -
32 - Box<Node> nodesSource;
33 -
34 - StreamSubscription<BoxEvent> _onNodesChangeSubscription;
35 -
36 - // @override
37 - // void dispose() {
38 - // super.dispose();
39 -
40 - // if (_onNodesChangeSubscription != null) {
41 - // _onNodesChangeSubscription.cancel();
42 - // }
43 - // }
44 -
45 - @action
46 - void update() =>
47 - nodes.replaceRange(0, nodes.length, nodesSource.values.toList());
48 -
49 - @action
50 - Future addNode(
51 - {String address, String port, String login, String password}) async {
52 - var uri = address;
53 -
54 - if (port != null && port.isNotEmpty) {
55 - uri += ':' + port;
56 - }
57 -
58 - final node = Node(uri: uri, login: login, password: password);
59 - await nodesSource.add(node);
60 - }
61 -
62 - @action
63 - Future remove({Node node}) async => await node.delete();
64 -
65 - @action
66 - Future reset() async => await resetToDefault(nodesSource);
67 -
68 - @action
69 - void setDisabledState(bool isDisable) {
70 - disabledState = isDisable;
71 - }
72 -
73 - Future<bool> isNodeOnline(Node node) async {
74 - try {
75 - return await node.requestNode();
76 - } catch (e) {
77 - return false;
78 - }
79 - }
80 -
81 - void validateNodeAddress(String value) {
82 - const pattern =
83 - '^((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\$|^[0-9a-zA-Z.]+\$';
84 - final regExp = RegExp(pattern);
85 - isValid = regExp.hasMatch(value);
86 - errorMessage = isValid ? null : S.current.error_text_node_address;
87 - }
88 -
89 - void validateNodePort(String value) {
90 - const pattern = '^[0-9]{1,5}';
91 - final regExp = RegExp(pattern);
92 -
93 - if (regExp.hasMatch(value)) {
94 - try {
95 - final intValue = int.parse(value);
96 - isValid = (intValue >= 0 && intValue <= 65535);
97 - } catch (e) {
98 - isValid = false;
99 - }
100 - } else {
101 - isValid = false;
102 - }
103 -
104 - errorMessage = isValid ? null : S.current.error_text_node_port;
105 - }
106 -}
lib/src/stores/price/price_store.dart deleted
-33
@@ -1,33 +0,0 @@
1 -import 'package:mobx/mobx.dart';
2 -import 'package:cake_wallet/src/domain/common/crypto_currency.dart';
3 -import 'package:cake_wallet/src/domain/common/fetch_price.dart';
4 -import 'package:cake_wallet/src/domain/common/fiat_currency.dart';
5 -
6 -part 'price_store.g.dart';
7 -
8 -class PriceStore = PriceStoreBase with _$PriceStore;
9 -
10 -abstract class PriceStoreBase with Store {
11 - PriceStoreBase() : prices = ObservableMap();
12 -
13 - static String generateSymbolForPair(
14 - {FiatCurrency fiat, CryptoCurrency crypto}) =>
15 - crypto.toString().toUpperCase() + fiat.toString().toUpperCase();
16 -
17 - @observable
18 - ObservableMap<String, double> prices;
19 -
20 - @action
21 - Future updatePrice({FiatCurrency fiat, CryptoCurrency crypto}) async {
22 - final symbol = generateSymbolForPair(fiat: fiat, crypto: crypto);
23 - final price = await fetchPriceFor(fiat: fiat, crypto: crypto);
24 - prices[symbol] = price;
25 - }
26 -
27 - @action
28 - void changePriceForPair(
29 - {FiatCurrency fiat, CryptoCurrency crypto, double price}) {
30 - final symbol = generateSymbolForPair(fiat: fiat, crypto: crypto);
31 - prices[symbol] = price;
32 - }
33 -}
lib/src/stores/rescan/rescan_wallet_store.dart deleted
-28
@@ -1,28 +0,0 @@
1 -import 'package:flutter/foundation.dart';
2 -import 'package:mobx/mobx.dart';
3 -import 'package:cake_wallet/src/domain/services/wallet_service.dart';
4 -
5 -part 'rescan_wallet_store.g.dart';
6 -
7 -class RescanWalletStore = RescanWalletStoreBase with _$RescanWalletStore;
8 -
9 -enum RescanWalletState { rescaning, none }
10 -
11 -abstract class RescanWalletStoreBase with Store {
12 - RescanWalletStoreBase({@required WalletService walletService}) {
13 - _walletService = walletService;
14 - state = RescanWalletState.none;
15 - }
16 -
17 - @observable
18 - RescanWalletState state;
19 -
20 - WalletService _walletService;
21 -
22 - @action
23 - Future rescanCurrentWallet({int restoreHeight}) async {
24 - state = RescanWalletState.rescaning;
25 - await _walletService.rescan(restoreHeight: restoreHeight);
26 - state = RescanWalletState.none;
27 - }
28 -}
lib/src/stores/seed_language/seed_language_store.dart deleted
-37
@@ -1,37 +0,0 @@
1 -import 'package:mobx/mobx.dart';
2 -
3 -part 'seed_language_store.g.dart';
4 -
5 -const List<String> seedLanguages = [
6 - 'English',
7 - 'Chinese (simplified)',
8 - 'Dutch',
9 - 'German',
10 - 'Japanese',
11 - 'Portuguese',
12 - 'Russian',
13 - 'Spanish'
14 -];
15 -
16 -class SeedLanguageStore = SeedLanguageStoreBase with _$SeedLanguageStore;
17 -
18 -abstract class SeedLanguageStoreBase with Store {
19 - SeedLanguageStoreBase() {
20 - selectedSeedLanguage = seedLanguages[0];
21 - currentRoute = '';
22 - }
23 -
24 - @observable
25 - String selectedSeedLanguage;
26 -
27 - String currentRoute;
28 -
29 - @action
30 - void setSelectedSeedLanguage(String seedLanguage) {
31 - selectedSeedLanguage = seedLanguage;
32 - }
33 -
34 - void setCurrentRoute(String route) {
35 - currentRoute = route;
36 - }
37 -}
\ No newline at end of file
lib/src/stores/send/send_store.dart deleted
-304
@@ -1,304 +0,0 @@
1 -import 'package:hive/hive.dart';
2 -import 'package:intl/intl.dart';
3 -import 'package:mobx/mobx.dart';
4 -import 'package:flutter/foundation.dart';
5 -import 'package:cake_wallet/src/domain/services/wallet_service.dart';
6 -import 'package:cake_wallet/src/domain/common/pending_transaction.dart';
7 -import 'package:cake_wallet/src/domain/common/crypto_currency.dart';
8 -import 'package:cake_wallet/src/domain/monero/monero_transaction_creation_credentials.dart';
9 -import 'package:cake_wallet/src/domain/monero/transaction_description.dart';
10 -import 'package:cake_wallet/src/stores/price/price_store.dart';
11 -import 'package:cake_wallet/src/stores/send/sending_state.dart';
12 -import 'package:cake_wallet/src/stores/settings/settings_store.dart';
13 -import 'package:cake_wallet/generated/i18n.dart';
14 -import 'package:cake_wallet/src/domain/common/openalias_record.dart';
15 -
16 -part 'send_store.g.dart';
17 -
18 -class SendStore = SendStoreBase with _$SendStore;
19 -
20 -abstract class SendStoreBase with Store {
21 - SendStoreBase(
22 - {@required this.walletService,
23 - this.settingsStore,
24 - this.transactionDescriptions,
25 - this.priceStore}) {
26 - state = SendingStateInitial();
27 - _pendingTransaction = null;
28 - _cryptoNumberFormat = NumberFormat()..maximumFractionDigits = 12;
29 - _fiatNumberFormat = NumberFormat()..maximumFractionDigits = 2;
30 - }
31 -
32 - WalletService walletService;
33 - SettingsStore settingsStore;
34 - PriceStore priceStore;
35 - Box<TransactionDescription> transactionDescriptions;
36 - String recordName;
37 - String recordAddress;
38 -
39 - @observable
40 - SendingState state;
41 -
42 - @observable
43 - String fiatAmount;
44 -
45 - @observable
46 - String cryptoAmount;
47 -
48 - @observable
49 - String address;
50 -
51 - @observable
52 - bool isValid;
53 -
54 - @observable
55 - String errorMessage;
56 -
57 - PendingTransaction get pendingTransaction => _pendingTransaction;
58 - PendingTransaction _pendingTransaction;
59 - NumberFormat _cryptoNumberFormat;
60 - NumberFormat _fiatNumberFormat;
61 - String _lastRecipientAddress;
62 -
63 - @action
64 - Future createTransaction(
65 - {String address, String paymentId, String amount}) async {
66 - state = CreatingTransaction();
67 -
68 - try {
69 - final _amount = amount != null
70 - ? amount
71 - : cryptoAmount == S.current.all
72 - ? null
73 - : cryptoAmount.replaceAll(',', '.');
74 - final credentials = MoneroTransactionCreationCredentials(
75 - address: address,
76 - paymentId: paymentId ?? '',
77 - amount: _amount,
78 - priority: settingsStore.transactionPriority);
79 -
80 - _pendingTransaction = await walletService.createTransaction(credentials);
81 - state = TransactionCreatedSuccessfully();
82 - _lastRecipientAddress = address;
83 - } catch (e) {
84 - state = SendingFailed(error: e.toString());
85 - }
86 - }
87 -
88 - @action
89 - Future commitTransaction() async {
90 - try {
91 - final transactionId = _pendingTransaction.hash;
92 - state = TransactionCommiting();
93 - await _pendingTransaction.commit();
94 - state = TransactionCommitted();
95 -
96 - if (settingsStore.shouldSaveRecipientAddress) {
97 - await transactionDescriptions.add(TransactionDescription(
98 - id: transactionId, recipientAddress: _lastRecipientAddress));
99 - }
100 - } catch (e) {
101 - state = SendingFailed(error: e.toString());
102 - }
103 -
104 - _pendingTransaction = null;
105 - }
106 -
107 - @action
108 - void setSendAll() {
109 - cryptoAmount = 'ALL';
110 - fiatAmount = '';
111 - }
112 -
113 - @action
114 - void changeCryptoAmount(String amount) {
115 - cryptoAmount = amount;
116 -
117 - if (cryptoAmount != null && cryptoAmount.isNotEmpty) {
118 - _calculateFiatAmount();
119 - } else {
120 - fiatAmount = '';
121 - }
122 - }
123 -
124 - @action
125 - void changeFiatAmount(String amount) {
126 - fiatAmount = amount;
127 -
128 - if (fiatAmount != null && fiatAmount.isNotEmpty) {
129 - _calculateCryptoAmount();
130 - } else {
131 - cryptoAmount = '';
132 - }
133 - }
134 -
135 - @action
136 - Future _calculateFiatAmount() async {
137 - final symbol = PriceStoreBase.generateSymbolForPair(
138 - fiat: settingsStore.fiatCurrency, crypto: CryptoCurrency.xmr);
139 - final price = priceStore.prices[symbol] ?? 0;
140 -
141 - try {
142 - final amount = double.parse(cryptoAmount) * price;
143 - fiatAmount = _fiatNumberFormat.format(amount);
144 - } catch (e) {
145 - fiatAmount = '0.00';
146 - }
147 - }
148 -
149 - @action
150 - Future _calculateCryptoAmount() async {
151 - final symbol = PriceStoreBase.generateSymbolForPair(
152 - fiat: settingsStore.fiatCurrency, crypto: CryptoCurrency.xmr);
153 - final price = priceStore.prices[symbol] ?? 0;
154 -
155 - try {
156 - final amount = double.parse(fiatAmount) / price;
157 - cryptoAmount = _cryptoNumberFormat.format(amount);
158 - } catch (e) {
159 - cryptoAmount = '0.00';
160 - }
161 - }
162 -
163 - @action
164 - void changeAddress(String address) {
165 - this.address = address;
166 - }
167 -
168 - @action
169 - void clear() {
170 - address = '';
171 - cryptoAmount = '';
172 - fiatAmount = '';
173 - }
174 -
175 - Future<bool> isOpenaliasRecord(String name) async {
176 - final _openaliasRecord = await OpenaliasRecord
177 - .fetchAddressAndName(OpenaliasRecord.formatDomainName(name));
178 -
179 - recordAddress = _openaliasRecord.address;
180 - recordName = _openaliasRecord.name;
181 -
182 - return recordAddress != name;
183 - }
184 -
185 - void validateAddress(String value, {CryptoCurrency cryptoCurrency}) {
186 - // XMR (95, 106), ADA (59, 92, 105), BCH (42), BNB (42), BTC (34, 42), DASH (34), EOS (42),
187 - // ETH (42), LTC (34), NANO (64, 65), TRX (34), USDT (42), XLM (56), XRP (34)
188 - const pattern = '^[0-9a-zA-Z]{95}\$|^[0-9a-zA-Z]{34}\$|^[0-9a-zA-Z]{42}\$|^[0-9a-zA-Z]{56}\$|^[0-9a-zA-Z]{59}\$|^[0-9a-zA-Z_]{64}\$|^[0-9a-zA-Z_]{65}\$|^[0-9a-zA-Z]{92}\$|^[0-9a-zA-Z]{105}\$|^[0-9a-zA-Z]{106}\$';
189 - final regExp = RegExp(pattern);
190 - isValid = regExp.hasMatch(value);
191 - if (isValid && cryptoCurrency != null) {
192 - switch (cryptoCurrency) {
193 - case CryptoCurrency.xmr:
194 - isValid = (value.length == 95)||(value.length == 106);
195 - break;
196 - case CryptoCurrency.ada:
197 - isValid = (value.length == 59)||(value.length == 92)||(value.length == 105);
198 - break;
199 - case CryptoCurrency.bch:
200 - isValid = (value.length == 42);
201 - break;
202 - case CryptoCurrency.bnb:
203 - isValid = (value.length == 42);
204 - break;
205 - case CryptoCurrency.btc:
206 - isValid = (value.length == 34)||(value.length == 42);
207 - break;
208 - case CryptoCurrency.dash:
209 - isValid = (value.length == 34);
210 - break;
211 - case CryptoCurrency.eos:
212 - isValid = (value.length == 42);
213 - break;
214 - case CryptoCurrency.eth:
215 - isValid = (value.length == 42);
216 - break;
217 - case CryptoCurrency.ltc:
218 - isValid = (value.length == 34);
219 - break;
220 - case CryptoCurrency.nano:
221 - isValid = (value.length == 64)||(value.length == 65);
222 - break;
223 - case CryptoCurrency.trx:
224 - isValid = (value.length == 34);
225 - break;
226 - case CryptoCurrency.usdt:
227 - isValid = (value.length == 42);
228 - break;
229 - case CryptoCurrency.xlm:
230 - isValid = (value.length == 56);
231 - break;
232 - case CryptoCurrency.xrp:
233 - isValid = (value.length == 34);
234 - break;
235 - }
236 - }
237 -
238 - errorMessage = isValid ? null : S.current.error_text_address;
239 - }
240 -
241 - void validatePaymentID(String value) {
242 - if (value.isEmpty) {
243 - isValid = true;
244 - } else {
245 - const pattern = '^[A-Fa-f0-9]{16,64}\$';
246 - final regExp = RegExp(pattern);
247 - isValid = regExp.hasMatch(value);
248 - }
249 -
250 - errorMessage = isValid ? null : S.current.error_text_payment_id;
251 - }
252 -
253 - void validateXMR(String value, String availableBalance) {
254 - const double maxValue = 18446744.073709551616;
255 - const pattern = '^([0-9]+([.][0-9]{0,12})?|[.][0-9]{1,12})\$|ALL';
256 - final regExp = RegExp(pattern);
257 -
258 - if (regExp.hasMatch(value)) {
259 - if (value == 'ALL') {
260 - isValid = true;
261 - } else {
262 - try {
263 - final dValue = double.parse(value);
264 - final maxAvailable = double.parse(availableBalance);
265 - isValid =
266 - (dValue <= maxAvailable && dValue <= maxValue && dValue > 0);
267 - } catch (e) {
268 - isValid = false;
269 - }
270 - }
271 - } else {
272 - isValid = false;
273 - }
274 -
275 - errorMessage = isValid ? null : S.current.error_text_xmr;
276 - }
277 -
278 - void validateFiat(String value, {double maxValue}) {
279 - const double minValue = 0.01;
280 -
281 - if (value.isEmpty && cryptoAmount == 'ALL') {
282 - isValid = true;
283 - } else {
284 - const pattern = '^([0-9]+([.][0-9]{0,2})?|[.][0-9]{1,2})\$';
285 - final regExp = RegExp(pattern);
286 -
287 - if (regExp.hasMatch(value)) {
288 - try {
289 - final dValue = double.parse(value);
290 - isValid = (dValue >= minValue && dValue <= maxValue);
291 - } catch (e) {
292 - isValid = false;
293 - }
294 - } else {
295 - isValid = false;
296 - }
297 - }
298 -
299 - errorMessage = isValid
300 - ? null
301 - : "Value of amount can't exceed available balance.\n"
302 - "The number of fraction digits must be less or equal to 2";
303 - }
304 -}
lib/src/stores/send/sending_state.dart deleted
-19
@@ -1,19 +0,0 @@
1 -import 'package:flutter/foundation.dart';
2 -
3 -abstract class SendingState {}
4 -
5 -class SendingStateInitial extends SendingState {}
6 -
7 -class CreatingTransaction extends SendingState {}
8 -
9 -class TransactionCreatedSuccessfully extends SendingState {}
10 -
11 -class TransactionCommiting extends SendingState {}
12 -
13 -class TransactionCommitted extends SendingState {}
14 -
15 -class SendingFailed extends SendingState {
16 - SendingFailed({@required this.error});
17 -
18 - String error;
19 -}
lib/src/stores/send_template/send_template_store.dart deleted
-48
@@ -1,48 +0,0 @@
1 -import 'dart:async';
2 -import 'package:mobx/mobx.dart';
3 -import 'package:hive/hive.dart';
4 -import 'package:cake_wallet/src/domain/common/template.dart';
5 -import 'package:cake_wallet/generated/i18n.dart';
6 -
7 -part 'send_template_store.g.dart';
8 -
9 -class SendTemplateStore = SendTemplateBase with _$SendTemplateStore;
10 -
11 -abstract class SendTemplateBase with Store {
12 - SendTemplateBase({this.templateSource}) {
13 - templates = ObservableList<Template>();
14 - update();
15 - }
16 -
17 - @observable
18 - ObservableList<Template> templates;
19 -
20 - @observable
21 - bool isValid;
22 -
23 - @observable
24 - String errorMessage;
25 -
26 - Box<Template> templateSource;
27 -
28 - @action
29 - void update() =>
30 - templates.replaceRange(0, templates.length, templateSource.values.toList());
31 -
32 - @action
33 - Future addTemplate({String name, String address, String cryptoCurrency, String amount}) async {
34 - final template = Template(name: name, address: address,
35 - cryptoCurrency: cryptoCurrency, amount: amount);
36 - await templateSource.add(template);
37 - }
38 -
39 - @action
40 - Future remove({Template template}) async => await template.delete();
41 -
42 - void validateTemplate(String value) {
43 - const pattern = '''^[^`,'"]{1,106}\$''';
44 - final regExp = RegExp(pattern);
45 - isValid = regExp.hasMatch(value);
46 - errorMessage = isValid ? null : S.current.error_text_template;
47 - }
48 -}
\ No newline at end of file
lib/src/stores/settings/settings_store.dart deleted
-297
@@ -1,297 +0,0 @@
1 -import 'package:flutter/material.dart';
2 -import 'package:flutter/services.dart';
3 -import 'package:mobx/mobx.dart';
4 -import 'package:flutter/foundation.dart';
5 -import 'package:shared_preferences/shared_preferences.dart';
6 -import 'package:hive/hive.dart';
7 -import 'package:cake_wallet/src/domain/common/node.dart';
8 -import 'package:cake_wallet/src/domain/common/balance_display_mode.dart';
9 -import 'package:cake_wallet/src/domain/common/fiat_currency.dart';
10 -import 'package:cake_wallet/src/domain/common/transaction_priority.dart';
11 -import 'package:cake_wallet/src/stores/action_list/action_list_display_mode.dart';
12 -import 'package:cake_wallet/src/screens/settings/items/item_headers.dart';
13 -import 'package:cake_wallet/generated/i18n.dart';
14 -import 'package:cake_wallet/src/domain/common/default_settings_migration.dart';
15 -import 'package:package_info/package_info.dart';
16 -import 'package:cake_wallet/src/domain/common/language.dart';
17 -import 'package:devicelocale/devicelocale.dart';
18 -import 'package:intl/intl.dart';
19 -
20 -part 'settings_store.g.dart';
21 -
22 -class SettingsStore = SettingsStoreBase with _$SettingsStore;
23 -
24 -abstract class SettingsStoreBase with Store {
25 - SettingsStoreBase(
26 - {@required SharedPreferences sharedPreferences,
27 - @required Box<Node> nodes,
28 - @required FiatCurrency initialFiatCurrency,
29 - @required TransactionPriority initialTransactionPriority,
30 - @required BalanceDisplayMode initialBalanceDisplayMode,
31 - @required bool initialSaveRecipientAddress,
32 - @required bool initialAllowBiometricalAuthentication,
33 - @required bool initialDarkTheme,
34 - this.actionlistDisplayMode,
35 - @required int initialPinLength,
36 - @required String initialLanguageCode,
37 - @required String initialCurrentLocale}) {
38 - fiatCurrency = initialFiatCurrency;
39 - transactionPriority = initialTransactionPriority;
40 - balanceDisplayMode = initialBalanceDisplayMode;
41 - shouldSaveRecipientAddress = initialSaveRecipientAddress;
42 - _sharedPreferences = sharedPreferences;
43 - _nodes = nodes;
44 - allowBiometricalAuthentication = initialAllowBiometricalAuthentication;
45 - isDarkTheme = true;
46 - defaultPinLength = initialPinLength;
47 - languageCode = initialLanguageCode;
48 - currentLocale = initialCurrentLocale;
49 - itemHeaders = Map();
50 -
51 - actionlistDisplayMode.observe(
52 - (dynamic _) => _sharedPreferences.setInt(displayActionListModeKey,
53 - serializeActionlistDisplayModes(actionlistDisplayMode)),
54 - fireImmediately: false);
55 -
56 - PackageInfo.fromPlatform().then((PackageInfo packageInfo) => currentVersion = packageInfo.version);
57 -
58 - }
59 -
60 - static const currentNodeIdKey = 'current_node_id';
61 - static const currentFiatCurrencyKey = 'current_fiat_currency';
62 - static const currentTransactionPriorityKey = 'current_fee_priority';
63 - static const currentBalanceDisplayModeKey = 'current_balance_display_mode';
64 - static const shouldSaveRecipientAddressKey = 'save_recipient_address';
65 - static const allowBiometricalAuthenticationKey =
66 - 'allow_biometrical_authentication';
67 - static const currentDarkTheme = 'dark_theme';
68 - static const displayActionListModeKey = 'display_list_mode';
69 - static const currentPinLength = 'current_pin_length';
70 - static const currentLanguageCode = 'language_code';
71 -
72 - static Future<SettingsStore> load(
73 - {@required SharedPreferences sharedPreferences,
74 - @required Box<Node> nodes,
75 - @required FiatCurrency initialFiatCurrency,
76 - @required TransactionPriority initialTransactionPriority,
77 - @required BalanceDisplayMode initialBalanceDisplayMode}) async {
78 - final currentFiatCurrency = FiatCurrency(
79 - symbol: sharedPreferences.getString(currentFiatCurrencyKey));
80 - final currentTransactionPriority = TransactionPriority.deserialize(
81 - raw: sharedPreferences.getInt(currentTransactionPriorityKey));
82 - final currentBalanceDisplayMode = BalanceDisplayMode.deserialize(
83 - raw: sharedPreferences.getInt(currentBalanceDisplayModeKey));
84 - final shouldSaveRecipientAddress =
85 - sharedPreferences.getBool(shouldSaveRecipientAddressKey);
86 - final allowBiometricalAuthentication =
87 - sharedPreferences.getBool(allowBiometricalAuthenticationKey) == null
88 - ? false
89 - : sharedPreferences.getBool(allowBiometricalAuthenticationKey);
90 - final savedDarkTheme = sharedPreferences.getBool(currentDarkTheme) == null
91 - ? false
92 - : sharedPreferences.getBool(currentDarkTheme);
93 - final actionlistDisplayMode = ObservableList<ActionListDisplayMode>();
94 - actionlistDisplayMode.addAll(deserializeActionlistDisplayModes(
95 - sharedPreferences.getInt(displayActionListModeKey) ?? 11));
96 - final defaultPinLength = sharedPreferences.getInt(currentPinLength) == null
97 - ? 4
98 - : sharedPreferences.getInt(currentPinLength);
99 - final savedLanguageCode =
100 - sharedPreferences.getString(currentLanguageCode) == null
101 - ? await Language.localeDetection()
102 - : sharedPreferences.getString(currentLanguageCode);
103 - final initialCurrentLocale = await Devicelocale.currentLocale;
104 -
105 - final store = SettingsStore(
106 - sharedPreferences: sharedPreferences,
107 - nodes: nodes,
108 - initialFiatCurrency: currentFiatCurrency,
109 - initialTransactionPriority: currentTransactionPriority,
110 - initialBalanceDisplayMode: currentBalanceDisplayMode,
111 - initialSaveRecipientAddress: shouldSaveRecipientAddress,
112 - initialAllowBiometricalAuthentication: allowBiometricalAuthentication,
113 - initialDarkTheme: savedDarkTheme,
114 - actionlistDisplayMode: actionlistDisplayMode,
115 - initialPinLength: defaultPinLength,
116 - initialLanguageCode: savedLanguageCode,
117 - initialCurrentLocale: initialCurrentLocale);
118 -
119 - await store.loadSettings();
120 -
121 - return store;
122 - }
123 -
124 - @observable
125 - Node node;
126 -
127 - @observable
128 - FiatCurrency fiatCurrency;
129 -
130 - @observable
131 - ObservableList<ActionListDisplayMode> actionlistDisplayMode;
132 -
133 - @observable
134 - TransactionPriority transactionPriority;
135 -
136 - @observable
137 - BalanceDisplayMode balanceDisplayMode;
138 -
139 - @observable
140 - bool shouldSaveRecipientAddress;
141 -
142 - @observable
143 - bool allowBiometricalAuthentication;
144 -
145 - @observable
146 - bool isDarkTheme = true;
147 -
148 - @observable
149 - int defaultPinLength;
150 -
151 - String languageCode;
152 -
153 - String currentLocale;
154 -
155 - @observable
156 - Map<String, String> itemHeaders;
157 -
158 - SharedPreferences _sharedPreferences;
159 - Box<Node> _nodes;
160 - String currentVersion;
161 -
162 - @action
163 - Future setAllowBiometricalAuthentication(
164 - {@required bool allowBiometricalAuthentication}) async {
165 - this.allowBiometricalAuthentication = allowBiometricalAuthentication;
166 - await _sharedPreferences.setBool(
167 - allowBiometricalAuthenticationKey, allowBiometricalAuthentication);
168 - }
169 -
170 - @action
171 - Future saveDarkTheme({@required bool isDarkTheme}) async {
172 - this.isDarkTheme = isDarkTheme;
173 - SystemChrome.setSystemUIOverlayStyle(SystemUiOverlayStyle(
174 - statusBarColor: isDarkTheme ? Colors.black : Colors.white));
175 - await _sharedPreferences.setBool(currentDarkTheme, isDarkTheme);
176 - }
177 -
178 - @action
179 - Future saveLanguageCode({@required String languageCode}) async {
180 - this.languageCode = languageCode;
181 - await _sharedPreferences.setString(currentLanguageCode, languageCode);
182 - }
183 -
184 - @action
185 - Future setCurrentNode({@required Node node}) async {
186 - this.node = node;
187 - await _sharedPreferences.setInt(currentNodeIdKey, node.key as int);
188 - }
189 -
190 - @action
191 - Future setCurrentFiatCurrency({@required FiatCurrency currency}) async {
192 - this.fiatCurrency = currency;
193 - await _sharedPreferences.setString(
194 - currentFiatCurrencyKey, fiatCurrency.serialize());
195 - }
196 -
197 - @action
198 - Future setCurrentTransactionPriority(
199 - {@required TransactionPriority priority}) async {
200 - this.transactionPriority = priority;
201 - await _sharedPreferences.setInt(
202 - currentTransactionPriorityKey, priority.serialize());
203 - }
204 -
205 - @action
206 - Future setCurrentBalanceDisplayMode(
207 - {@required BalanceDisplayMode balanceDisplayMode}) async {
208 - this.balanceDisplayMode = balanceDisplayMode;
209 - await _sharedPreferences.setInt(
210 - currentBalanceDisplayModeKey, balanceDisplayMode.serialize());
211 - }
212 -
213 - @action
214 - Future setSaveRecipientAddress(
215 - {@required bool shouldSaveRecipientAddress}) async {
216 - this.shouldSaveRecipientAddress = shouldSaveRecipientAddress;
217 - await _sharedPreferences.setBool(
218 - shouldSaveRecipientAddressKey, shouldSaveRecipientAddress);
219 - }
220 -
221 - Future loadSettings() async => node = await _fetchCurrentNode();
222 -
223 - @action
224 - void toggleTransactionsDisplay() =>
225 - actionlistDisplayMode.contains(ActionListDisplayMode.transactions)
226 - ? _hideTransaction()
227 - : _showTransaction();
228 -
229 - @action
230 - void toggleTradesDisplay() =>
231 - actionlistDisplayMode.contains(ActionListDisplayMode.trades)
232 - ? _hideTrades()
233 - : _showTrades();
234 -
235 - @action
236 - void _hideTransaction() =>
237 - actionlistDisplayMode.remove(ActionListDisplayMode.transactions);
238 -
239 - @action
240 - void _hideTrades() =>
241 - actionlistDisplayMode.remove(ActionListDisplayMode.trades);
242 -
243 - @action
244 - void _showTransaction() =>
245 - actionlistDisplayMode.add(ActionListDisplayMode.transactions);
246 -
247 - @action
248 - void _showTrades() => actionlistDisplayMode.add(ActionListDisplayMode.trades);
249 -
250 - @action
251 - Future setDefaultPinLength({@required int pinLength}) async {
252 - this.defaultPinLength = pinLength;
253 - await _sharedPreferences.setInt(currentPinLength, pinLength);
254 - }
255 -
256 - Future<Node> _fetchCurrentNode() async {
257 - final id = _sharedPreferences.getInt(currentNodeIdKey);
258 -
259 - return _nodes.get(id);
260 - }
261 -
262 - @action
263 - void setItemHeaders() {
264 - itemHeaders.clear();
265 - itemHeaders.addAll({
266 - ItemHeaders.nodes: S.current.settings_nodes,
267 - ItemHeaders.currentNode: S.current.settings_current_node,
268 - ItemHeaders.wallets: S.current.settings_wallets,
269 - ItemHeaders.displayBalanceAs: S.current.settings_display_balance_as,
270 - ItemHeaders.currency: S.current.settings_currency,
271 - ItemHeaders.feePriority: S.current.settings_fee_priority,
272 - ItemHeaders.saveRecipientAddress:
273 - S.current.settings_save_recipient_address,
274 - ItemHeaders.personal: S.current.settings_personal,
275 - ItemHeaders.changePIN: S.current.settings_change_pin,
276 - ItemHeaders.changeLanguage: S.current.settings_change_language,
277 - ItemHeaders.allowBiometricalAuthentication:
278 - S.current.settings_allow_biometrical_authentication,
279 - ItemHeaders.darkMode: S.current.settings_dark_mode,
280 - ItemHeaders.support: S.current.settings_support,
281 - ItemHeaders.termsAndConditions: S.current.settings_terms_and_conditions,
282 - ItemHeaders.faq: S.current.faq,
283 - ItemHeaders.version: S.current.version(currentVersion)
284 - });
285 - }
286 -
287 - Future setCurrentNodeToDefault() async {
288 -// await changeCurrentNodeToDefault(sharedPreferences: _sharedPreferences, nodes: _nodes);
289 - await loadSettings();
290 - }
291 -
292 - DateFormat getCurrentDateFormat({
293 - @required String formatUSA,
294 - @required String formatDefault}) => currentLocale == 'en_US'
295 - ? DateFormat(formatUSA, languageCode)
296 - : DateFormat(formatDefault, languageCode);
297 -}
lib/src/stores/subaddress_creation/subaddress_creation_state.dart deleted
-13
@@ -1,13 +0,0 @@
1 -abstract class SubaddressCreationState {}
2 -
3 -class SubaddressCreationStateInitial extends SubaddressCreationState {}
4 -
5 -class SubaddressIsCreating extends SubaddressCreationState {}
6 -
7 -class SubaddressCreatedSuccessfully extends SubaddressCreationState {}
8 -
9 -class SubaddressCreationFailure extends SubaddressCreationState {
10 - SubaddressCreationFailure({this.error});
11 -
12 - String error;
13 -}
\ No newline at end of file
lib/src/stores/subaddress_creation/subaddress_creation_store.dart deleted
-110
@@ -1,110 +0,0 @@
1 -import 'dart:async';
2 -import 'package:flutter/foundation.dart';
3 -import 'package:mobx/mobx.dart';
4 -import 'package:cake_wallet/src/domain/common/wallet.dart';
5 -import 'package:cake_wallet/src/domain/monero/monero_wallet.dart';
6 -import 'package:cake_wallet/src/domain/monero/subaddress_list.dart';
7 -import 'package:cake_wallet/src/domain/services/wallet_service.dart';
8 -import 'package:cake_wallet/src/stores/subaddress_creation/subaddress_creation_state.dart';
9 -import 'package:cake_wallet/src/domain/monero/account.dart';
10 -import 'package:cake_wallet/generated/i18n.dart';
11 -
12 -part 'subaddress_creation_store.g.dart';
13 -
14 -class SubadrressCreationStore = SubadrressCreationStoreBase
15 - with _$SubadrressCreationStore;
16 -
17 -abstract class SubadrressCreationStoreBase with Store {
18 - SubadrressCreationStoreBase({@required WalletService walletService}) {
19 - state = SubaddressCreationStateInitial();
20 - isDisabledStatus = true;
21 -
22 - if (walletService.currentWallet != null) {
23 - _onWalletChanged(walletService.currentWallet);
24 - }
25 -
26 - _onWalletChangeSubscription =
27 - walletService.onWalletChange.listen(_onWalletChanged);
28 - }
29 -
30 - @observable
31 - SubaddressCreationState state;
32 -
33 - @observable
34 - bool isValid;
35 -
36 - @observable
37 - String errorMessage;
38 -
39 - @observable
40 - bool isDisabledStatus;
41 -
42 - SubaddressList _subaddressList;
43 - StreamSubscription<Wallet> _onWalletChangeSubscription;
44 - StreamSubscription<Account> _onAccountChangeSubscription;
45 - Account _account;
46 -
47 - @action
48 - void setDisabledStatus(bool isDisabled) {
49 - isDisabledStatus = isDisabled;
50 - }
51 -
52 - // @override
53 - // void dispose() {
54 - // _onWalletChangeSubscription.cancel();
55 -
56 - // if (_onAccountChangeSubscription != null) {
57 - // _onAccountChangeSubscription.cancel();
58 - // }
59 -
60 - // super.dispose();
61 - // }
62 -
63 - Future<void> add({String label}) async {
64 - try {
65 - state = SubaddressIsCreating();
66 - await _subaddressList.addSubaddress(
67 - accountIndex: _account.id, label: label);
68 - state = SubaddressCreatedSuccessfully();
69 - } catch (e) {
70 - state = SubaddressCreationFailure(error: e.toString());
71 - }
72 - }
73 -
74 - Future<void> setLabel({int addressIndex, String label}) async {
75 - try {
76 - state = SubaddressIsCreating();
77 - await _subaddressList.setLabelSubaddress(
78 - accountIndex: _account.id,
79 - addressIndex: addressIndex,
80 - label: label
81 - );
82 - state = SubaddressCreatedSuccessfully();
83 - } catch (e) {
84 - state = SubaddressCreationFailure(error: e.toString());
85 - }
86 - }
87 -
88 - Future<void> _onWalletChanged(Wallet wallet) async {
89 - if (wallet is MoneroWallet) {
90 - _account = wallet.account;
91 - _subaddressList = wallet.getSubaddress();
92 -
93 - _onAccountChangeSubscription =
94 - wallet.onAccountChange.listen((account) async {
95 - _account = account;
96 - await _subaddressList.update(accountIndex: account.id);
97 - });
98 - return;
99 - }
100 -
101 - print('Incorrect wallet type for this operation (SubaddressList)');
102 - }
103 -
104 - void validateSubaddressName(String value) {
105 - const pattern = '''^[^`,'"]{1,20}\$''';
106 - final regExp = RegExp(pattern);
107 - isValid = regExp.hasMatch(value);
108 - errorMessage = isValid ? null : S.current.error_text_subaddress_name;
109 - }
110 -}
lib/src/stores/subaddress_list/subaddress_list_store.dart deleted
-78
@@ -1,78 +0,0 @@
1 -import 'dart:async';
2 -import 'package:flutter/foundation.dart';
3 -import 'package:mobx/mobx.dart';
4 -import 'package:cake_wallet/src/domain/common/wallet.dart';
5 -import 'package:cake_wallet/src/domain/monero/monero_wallet.dart';
6 -import 'package:cake_wallet/src/domain/monero/subaddress.dart';
7 -import 'package:cake_wallet/src/domain/monero/subaddress_list.dart';
8 -import 'package:cake_wallet/src/domain/services/wallet_service.dart';
9 -import 'package:cake_wallet/src/domain/monero/account.dart';
10 -
11 -part 'subaddress_list_store.g.dart';
12 -
13 -class SubaddressListStore = SubaddressListStoreBase with _$SubaddressListStore;
14 -
15 -abstract class SubaddressListStoreBase with Store {
16 - SubaddressListStoreBase({@required WalletService walletService}) {
17 - subaddresses = ObservableList<Subaddress>();
18 -
19 - if (walletService.currentWallet != null) {
20 - _onWalletChanged(walletService.currentWallet);
21 - }
22 -
23 - _onWalletChangeSubscription =
24 - walletService.onWalletChange.listen(_onWalletChanged);
25 - }
26 -
27 - @observable
28 - ObservableList<Subaddress> subaddresses;
29 -
30 - SubaddressList _subaddressList;
31 - StreamSubscription<Wallet> _onWalletChangeSubscription;
32 - StreamSubscription<List<Subaddress>> _onSubaddressesChangeSubscription;
33 - StreamSubscription<Account> _onAccountChangeSubscription;
34 - Account _account;
35 -
36 - // @override
37 - // void dispose() {
38 - // if (_onSubaddressesChangeSubscription != null) {
39 - // _onSubaddressesChangeSubscription.cancel();
40 - // }
41 -
42 - // if (_onAccountChangeSubscription != null) {
43 - // _onAccountChangeSubscription.cancel();
44 - // }
45 -
46 - // _onWalletChangeSubscription.cancel();
47 - // super.dispose();
48 - // }
49 -
50 - Future<void> _updateSubaddressList({int accountIndex}) async {
51 - await _subaddressList.refresh(accountIndex: accountIndex);
52 - subaddresses = ObservableList.of(_subaddressList.getAll());
53 - }
54 -
55 - Future<void> _onWalletChanged(Wallet wallet) async {
56 - if (_onSubaddressesChangeSubscription != null) {
57 - await _onSubaddressesChangeSubscription.cancel();
58 - }
59 -
60 - if (wallet is MoneroWallet) {
61 - _account = wallet.account;
62 - _subaddressList = wallet.getSubaddress();
63 - _onSubaddressesChangeSubscription = _subaddressList.subaddresses
64 - .listen((subaddress) => subaddresses = ObservableList.of(subaddress));
65 - await _updateSubaddressList(accountIndex: _account.id);
66 -
67 - _onAccountChangeSubscription =
68 - wallet.onAccountChange.listen((account) async {
69 - _account = account;
70 - await _updateSubaddressList(accountIndex: account.id);
71 - });
72 -
73 - return;
74 - }
75 -
76 - print('Incorrect wallet type for this operation (SubaddressList)');
77 - }
78 -}
lib/src/stores/sync/sync_store.dart deleted
-50
@@ -1,50 +0,0 @@
1 -import 'dart:async';
2 -import 'package:flutter/foundation.dart';
3 -import 'package:mobx/mobx.dart';
4 -import 'package:cake_wallet/src/domain/common/sync_status.dart';
5 -import 'package:cake_wallet/src/domain/common/wallet.dart';
6 -import 'package:cake_wallet/src/domain/services/wallet_service.dart';
7 -
8 -part 'sync_store.g.dart';
9 -
10 -class SyncStore = SyncStoreBase with _$SyncStore;
11 -
12 -abstract class SyncStoreBase with Store {
13 - SyncStoreBase(
14 - {SyncStatus syncStatus = const NotConnectedSyncStatus(),
15 - @required WalletService walletService}) {
16 - status = syncStatus;
17 -
18 - if (walletService.currentWallet != null) {
19 - _onWalletChanged(walletService.currentWallet);
20 - }
21 -
22 - _onWalletChangeSubscription =
23 - walletService.onWalletChange.listen(_onWalletChanged);
24 - }
25 -
26 - @observable
27 - SyncStatus status;
28 -
29 - StreamSubscription<Wallet> _onWalletChangeSubscription;
30 - StreamSubscription<SyncStatus> _onSyncStatusChangeSubscription;
31 -
32 - // @override
33 - // void dispose() {
34 - // if (_onSyncStatusChangeSubscription != null) {
35 - // _onSyncStatusChangeSubscription.cancel();
36 - // }
37 -
38 - // _onWalletChangeSubscription.cancel();
39 - // super.dispose();
40 - // }
41 -
42 - void _onWalletChanged(Wallet wallet) {
43 - if (_onSyncStatusChangeSubscription != null) {
44 - _onSyncStatusChangeSubscription.cancel();
45 - }
46 -
47 - _onSyncStatusChangeSubscription =
48 - wallet.syncStatus.listen((status) => this.status = status);
49 - }
50 -}
lib/src/stores/user/user_store.dart deleted
-32
@@ -1,32 +0,0 @@
1 -import 'package:mobx/mobx.dart';
2 -import 'package:flutter/foundation.dart';
3 -import 'package:cake_wallet/src/domain/services/user_service.dart';
4 -import 'package:cake_wallet/src/stores/user/user_store_state.dart';
5 -
6 -part 'user_store.g.dart';
7 -
8 -class UserStore = UserStoreBase with _$UserStore;
9 -
10 -abstract class UserStoreBase with Store {
11 - UserStoreBase({@required this.accountService});
12 -
13 - UserService accountService;
14 -
15 - @observable
16 - UserStoreState state;
17 -
18 - @observable
19 - String errorMessage;
20 -
21 - @action
22 - Future set({String password}) async {
23 - state = UserStoreStateInitial();
24 -
25 - try {
26 - await accountService.setPassword(password);
27 - state = PinCodeSetSuccesfully();
28 - } catch (e) {
29 - state = PinCodeSetFailed(error: e.toString());
30 - }
31 - }
32 -}
lib/src/stores/user/user_store_state.dart deleted
-13
@@ -1,13 +0,0 @@
1 -import 'package:flutter/foundation.dart';
2 -
3 -abstract class UserStoreState {}
4 -
5 -class UserStoreStateInitial extends UserStoreState {}
6 -
7 -class PinCodeSetSuccesfully extends UserStoreState {}
8 -
9 -class PinCodeSetFailed extends UserStoreState {
10 - PinCodeSetFailed({@required this.error});
11 -
12 - String error;
13 -}
lib/src/stores/wallet/wallet_keys_store.dart deleted
-45
@@ -1,45 +0,0 @@
1 -import 'package:cake_wallet/src/domain/common/wallet_type.dart';
2 -import 'package:flutter/foundation.dart';
3 -import 'package:mobx/mobx.dart';
4 -import 'package:cake_wallet/src/domain/services/wallet_service.dart';
5 -
6 -part 'wallet_keys_store.g.dart';
7 -
8 -class WalletKeysStore = WalletKeysStoreBase with _$WalletKeysStore;
9 -
10 -abstract class WalletKeysStoreBase with Store {
11 - WalletKeysStoreBase({@required WalletService walletService}) {
12 - publicViewKey = '';
13 - privateViewKey = '';
14 - publicSpendKey = '';
15 - privateSpendKey = '';
16 -
17 - if (walletService.currentWallet != null) {
18 - walletService.getKeys().then((keys) {
19 - if (walletService.getType() == WalletType.monero) {
20 - publicViewKey = keys['publicViewKey'];
21 - privateViewKey = keys['privateViewKey'];
22 - publicSpendKey = keys['publicSpendKey'];
23 - privateSpendKey = keys['privateSpendKey'];
24 - }
25 -
26 - if (walletService.getType() == WalletType.bitcoin) {
27 - publicViewKey = keys['publicKey'];
28 - privateSpendKey = keys['privateKey'];
29 - }
30 - });
31 - }
32 - }
33 -
34 - @observable
35 - String publicViewKey;
36 -
37 - @observable
38 - String privateViewKey;
39 -
40 - @observable
41 - String publicSpendKey;
42 -
43 - @observable
44 - String privateSpendKey;
45 -}
lib/src/stores/wallet/wallet_store.dart deleted
-170
@@ -1,170 +0,0 @@
1 -import 'dart:async';
2 -import 'package:cake_wallet/src/domain/common/node.dart';
3 -import 'package:cake_wallet/src/domain/common/wallet_type.dart';
4 -import 'package:mobx/mobx.dart';
5 -import 'package:cake_wallet/src/domain/common/wallet.dart';
6 -import 'package:cake_wallet/src/domain/monero/account.dart';
7 -import 'package:cake_wallet/src/domain/monero/monero_wallet.dart';
8 -import 'package:cake_wallet/src/domain/monero/subaddress.dart';
9 -import 'package:cake_wallet/src/domain/services/wallet_service.dart';
10 -import 'package:cake_wallet/src/domain/common/crypto_currency.dart';
11 -import 'package:cake_wallet/src/stores/settings/settings_store.dart';
12 -import 'package:cake_wallet/generated/i18n.dart';
13 -
14 -part 'wallet_store.g.dart';
15 -
16 -class WalletStore = WalletStoreBase with _$WalletStore;
17 -
18 -abstract class WalletStoreBase with Store {
19 - WalletStoreBase({WalletService walletService, SettingsStore settingsStore}) {
20 - _walletService = walletService;
21 - _settingsStore = settingsStore;
22 - name = '';
23 - type = CryptoCurrency.xmr;
24 - amountValue = '';
25 -
26 - if (_walletService.currentWallet != null) {
27 - _onWalletChanged(_walletService.currentWallet);
28 - }
29 -
30 - _onWalletChangeSubscription = _walletService.onWalletChange
31 - .listen((wallet) async => await _onWalletChanged(wallet));
32 - }
33 -
34 - @observable
35 - String address;
36 -
37 - @observable
38 - String name;
39 -
40 - @observable
41 - Subaddress subaddress;
42 -
43 - @observable
44 - Account account;
45 -
46 - @observable
47 - CryptoCurrency type;
48 -
49 - @observable
50 - String amountValue;
51 -
52 - @observable
53 - bool isValid;
54 -
55 - @observable
56 - String errorMessage;
57 -
58 - String get id => name + type.toString().toLowerCase();
59 -
60 - WalletService _walletService;
61 - SettingsStore _settingsStore;
62 - StreamSubscription<Wallet> _onWalletChangeSubscription;
63 - StreamSubscription<Account> _onAccountChangeSubscription;
64 - StreamSubscription<Subaddress> _onSubaddressChangeSubscription;
65 -
66 - // @override
67 - // void dispose() {
68 - // if (_onWalletChangeSubscription != null) {
69 - // _onWalletChangeSubscription.cancel();
70 - // }
71 -
72 - // if (_onAccountChangeSubscription != null) {
73 - // _onAccountChangeSubscription.cancel();
74 - // }
75 -
76 - // if (_onSubaddressChangeSubscription != null) {
77 - // _onSubaddressChangeSubscription.cancel();
78 - // }
79 -
80 - // super.dispose();
81 - // }
82 -
83 - @action
84 - void setAccount(Account account) {
85 - final wallet = _walletService.currentWallet;
86 -
87 - if (wallet is MoneroWallet) {
88 - this.account = account;
89 - wallet.changeAccount(account);
90 - }
91 - }
92 -
93 - @action
94 - void setSubaddress(Subaddress subaddress) {
95 - final wallet = _walletService.currentWallet;
96 -
97 - if (wallet is MoneroWallet) {
98 - this.subaddress = subaddress;
99 - wallet.changeCurrentSubaddress(subaddress);
100 - }
101 - }
102 -
103 - @action
104 - Future reconnect() async =>
105 - await _walletService.connectToNode(node: _settingsStore.node);
106 -
107 - @action
108 - Future rescan({int restoreHeight}) async =>
109 - await _walletService.rescan(restoreHeight: restoreHeight);
110 -
111 - @action
112 - Future startSync() async => await _walletService.startSync();
113 -
114 - @action
115 - Future connectToNode({Node node}) async =>
116 - await _walletService.connectToNode(node: node);
117 -
118 - Future _onWalletChanged(Wallet wallet) async {
119 - if (this == null) {
120 - return;
121 - }
122 -
123 - address = await wallet.getAddress();
124 - wallet.onNameChange.listen((name) => this.name = name);
125 - wallet.onAddressChange.listen((address) => this.address = address);
126 -
127 - if (wallet is MoneroWallet) {
128 - _onAccountChangeSubscription =
129 - wallet.onAccountChange.listen((account) => this.account = account);
130 - _onSubaddressChangeSubscription = wallet.subaddress
131 - .listen((subaddress) => this.subaddress = subaddress);
132 - }
133 - }
134 -
135 - @action
136 - void onChangedAmountValue(String value) =>
137 - amountValue = value.isNotEmpty ? '?tx_amount=' + value : '';
138 -
139 - @action
140 - void validateAmount(String value) {
141 - const double maxValue = 18446744.073709551616;
142 -
143 - if (value.isEmpty) {
144 - isValid = true;
145 - } else {
146 - const pattern = '^([0-9]+([.][0-9]{0,12})?|[.][0-9]{1,12})\$';
147 - final regExp = RegExp(pattern);
148 -
149 - if (regExp.hasMatch(value)) {
150 - try {
151 - final dValue = double.parse(value);
152 - isValid = dValue <= maxValue;
153 - } catch (e) {
154 - isValid = false;
155 - }
156 - } else {
157 - isValid = false;
158 - }
159 - }
160 -
161 - errorMessage = isValid ? null : S.current.error_text_amount;
162 - }
163 -
164 - Future<bool> isConnected() async => await _walletService.isConnected();
165 -
166 - WalletType getType() => _walletService.getType();
167 -
168 - String get getAddress =>
169 - getType() == WalletType.monero ? subaddress.address : address;
170 -}
lib/src/stores/wallet_creation/wallet_creation_state.dart deleted
-15
@@ -1,15 +0,0 @@
1 -import 'package:flutter/foundation.dart';
2 -
3 -abstract class WalletCreationState {}
4 -
5 -class WalletCreationStateInitial extends WalletCreationState {}
6 -
7 -class WalletIsCreating extends WalletCreationState {}
8 -
9 -class WalletCreatedSuccessfully extends WalletCreationState {}
10 -
11 -class WalletCreationFailure extends WalletCreationState {
12 - WalletCreationFailure({@required this.error});
13 -
14 - String error;
15 -}
\ No newline at end of file
lib/src/stores/wallet_creation/wallet_creation_store.dart deleted
-63
@@ -1,63 +0,0 @@
1 -import 'package:mobx/mobx.dart';
2 -import 'package:flutter/foundation.dart';
3 -import 'package:shared_preferences/shared_preferences.dart';
4 -import 'package:cake_wallet/src/domain/services/wallet_list_service.dart';
5 -import 'package:cake_wallet/src/stores/wallet_creation/wallet_creation_state.dart';
6 -import 'package:cake_wallet/src/stores/authentication/authentication_store.dart';
7 -import 'package:cake_wallet/generated/i18n.dart';
8 -
9 -part 'wallet_creation_store.g.dart';
10 -
11 -class WalletCreationStore = WalletCreationStoreBase with _$WalletCreationStore;
12 -
13 -abstract class WalletCreationStoreBase with Store {
14 - WalletCreationStoreBase(
15 - {@required this.authStore,
16 - @required this.walletListService,
17 - @required this.sharedPreferences}) {
18 - state = WalletCreationStateInitial();
19 - isDisabledStatus = true;
20 - }
21 -
22 - final AuthenticationStore authStore;
23 - final WalletListService walletListService;
24 - final SharedPreferences sharedPreferences;
25 -
26 - @observable
27 - WalletCreationState state;
28 -
29 - @observable
30 - String errorMessage;
31 -
32 - @observable
33 - bool isValid;
34 -
35 - @observable
36 - bool isDisabledStatus;
37 -
38 - @action
39 - Future create({String name, String language}) async {
40 - state = WalletCreationStateInitial();
41 -
42 - try {
43 - state = WalletIsCreating();
44 - await walletListService.create(name, language);
45 - authStore.created();
46 - state = WalletCreatedSuccessfully();
47 - } catch (e) {
48 - state = WalletCreationFailure(error: e.toString());
49 - }
50 - }
51 -
52 - @action
53 - void setDisabledStatus(bool isDisabled) {
54 - isDisabledStatus = isDisabled;
55 - }
56 -
57 - void validateWalletName(String value) {
58 - const pattern = '^[a-zA-Z0-9_]{1,15}\$';
59 - final regExp = RegExp(pattern);
60 - isValid = regExp.hasMatch(value);
61 - errorMessage = isValid ? null : S.current.error_text_wallet_name;
62 - }
63 -}
lib/src/stores/wallet_list/wallet_list_store.dart deleted
-45
@@ -1,45 +0,0 @@
1 -import 'package:flutter/foundation.dart';
2 -import 'package:mobx/mobx.dart';
3 -import 'package:cake_wallet/src/domain/common/wallet_description.dart';
4 -import 'package:cake_wallet/src/domain/services/wallet_list_service.dart';
5 -import 'package:cake_wallet/src/domain/services/wallet_service.dart';
6 -
7 -part 'wallet_list_store.g.dart';
8 -
9 -class WalletListStore = WalletListStoreBase with _$WalletListStore;
10 -
11 -abstract class WalletListStoreBase with Store {
12 - WalletListStoreBase(
13 - {@required WalletListService walletListService,
14 - @required WalletService walletService}) {
15 - _walletListService = walletListService;
16 - _walletService = walletService;
17 - wallets = [];
18 - walletListService.getAll().then((walletList) => wallets = walletList);
19 - }
20 -
21 - @observable
22 - List<WalletDescription> wallets;
23 -
24 - WalletListService _walletListService;
25 - WalletService _walletService;
26 -
27 - bool isCurrentWallet(WalletDescription wallet) =>
28 - _walletService.description?.name == wallet.name;
29 -
30 - @action
31 - Future<void> updateWalletList() async {
32 - wallets = await _walletListService.getAll();
33 - }
34 -
35 - @action
36 - Future<void> loadWallet(WalletDescription wallet) async {
37 - await _walletListService.openWallet(wallet.name);
38 - }
39 -
40 - @action
41 - Future<void> remove(WalletDescription wallet) async {
42 - await _walletListService.remove(wallet);
43 - await updateWalletList();
44 - }
45 -}
lib/src/stores/wallet_restoration/wallet_restoration_state.dart deleted
-15
@@ -1,15 +0,0 @@
1 -import 'package:flutter/foundation.dart';
2 -
3 -abstract class WalletRestorationState {}
4 -
5 -class WalletRestorationStateInitial extends WalletRestorationState {}
6 -
7 -class WalletIsRestoring extends WalletRestorationState {}
8 -
9 -class WalletRestoredSuccessfully extends WalletRestorationState {}
10 -
11 -class WalletRestorationFailure extends WalletRestorationState {
12 - WalletRestorationFailure({@required this.error});
13 -
14 - String error;
15 -}
lib/src/stores/wallet_restoration/wallet_restoration_store.dart deleted
-190
@@ -1,190 +0,0 @@
1 -import 'package:mobx/mobx.dart';
2 -import 'package:flutter/foundation.dart';
3 -import 'package:shared_preferences/shared_preferences.dart';
4 -import 'package:cake_wallet/src/domain/services/wallet_list_service.dart';
5 -import 'package:cake_wallet/src/domain/common/mnemonic_item.dart';
6 -import 'package:cake_wallet/src/stores/wallet_restoration/wallet_restoration_state.dart';
7 -import 'package:cake_wallet/src/stores/authentication/authentication_store.dart';
8 -import 'package:cake_wallet/src/domain/common/crypto_currency.dart';
9 -import 'package:cake_wallet/generated/i18n.dart';
10 -
11 -part 'wallet_restoration_store.g.dart';
12 -
13 -class WalletRestorationStore = WalleRestorationStoreBase
14 - with _$WalletRestorationStore;
15 -
16 -abstract class WalleRestorationStoreBase with Store {
17 - WalleRestorationStoreBase(
18 - {this.seed,
19 - @required this.authStore,
20 - @required this.walletListService,
21 - @required this.sharedPreferences}) {
22 - state = WalletRestorationStateInitial();
23 - disabledState = true;
24 - }
25 -
26 - final AuthenticationStore authStore;
27 - final WalletListService walletListService;
28 - final SharedPreferences sharedPreferences;
29 -
30 - @observable
31 - WalletRestorationState state;
32 -
33 - @observable
34 - String errorMessage;
35 -
36 - @observable
37 - bool isValid;
38 -
39 - @observable
40 - List<MnemonicItem> seed;
41 -
42 - @observable
43 - bool disabledState;
44 -
45 - @action
46 - Future restoreFromSeed({String name, String seed, int restoreHeight}) async {
47 - state = WalletRestorationStateInitial();
48 - final _seed = seed ?? _seedText();
49 -
50 - try {
51 - state = WalletIsRestoring();
52 - await walletListService.restoreFromSeed(name, _seed, restoreHeight);
53 - authStore.restored();
54 - state = WalletRestoredSuccessfully();
55 - } catch (e) {
56 - state = WalletRestorationFailure(error: e.toString());
57 - }
58 - }
59 -
60 - @action
61 - Future restoreFromKeys(
62 - {String name,
63 - String language,
64 - String address,
65 - String viewKey,
66 - String spendKey,
67 - int restoreHeight}) async {
68 - state = WalletRestorationStateInitial();
69 -
70 - try {
71 - state = WalletIsRestoring();
72 - await walletListService.restoreFromKeys(
73 - name, language, restoreHeight, address, viewKey, spendKey);
74 - authStore.restored();
75 - state = WalletRestoredSuccessfully();
76 - } catch (e) {
77 - state = WalletRestorationFailure(error: e.toString());
78 - }
79 - }
80 -
81 - @action
82 - void setSeed(List<MnemonicItem> seed) {
83 - this.seed = seed;
84 - }
85 -
86 -// @action
87 -// void validateSeed(List<MnemonicItem> seed) {
88 -// final _seed = seed != null ? seed : this.seed;
89 -// bool isValid = _seed != null ? _seed.length == 25 : false;
90 -//
91 -// if (!isValid) {
92 -// errorMessage = S.current.wallet_restoration_store_incorrect_seed_length;
93 -// this.isValid = isValid;
94 -// return;
95 -// }
96 -//
97 -// for (final item in _seed) {
98 -// if (!item.isCorrect()) {
99 -// isValid = false;
100 -// break;
101 -// }
102 -// }
103 -//
104 -// if (isValid) {
105 -// errorMessage = null;
106 -// }
107 -//
108 -// this.isValid = isValid;
109 -// return;
110 -// }
111 -
112 - String _seedText() {
113 - return seed.fold('', (acc, item) => acc + ' ' + item.toString());
114 - }
115 -
116 - @action
117 - void setDisabledState(bool isDisable) {
118 - disabledState = isDisable;
119 - }
120 -
121 - void validateWalletName(String value) {
122 - const pattern = '^[a-zA-Z0-9_]{1,15}\$';
123 - final regExp = RegExp(pattern);
124 - isValid = regExp.hasMatch(value);
125 - errorMessage = isValid ? null : S.current.error_text_wallet_name;
126 - }
127 -
128 - void validateAddress(String value, {CryptoCurrency cryptoCurrency}) {
129 - // XMR (95, 106), ADA (59, 92, 105), BCH (42), BNB (42), BTC (34, 42), DASH (34), EOS (42),
130 - // ETH (42), LTC (34), NANO (64, 65), TRX (34), USDT (42), XLM (56), XRP (34)
131 - const pattern = '^[0-9a-zA-Z]{95}\$|^[0-9a-zA-Z]{34}\$|^[0-9a-zA-Z]{42}\$|^[0-9a-zA-Z]{56}\$|^[0-9a-zA-Z]{59}\$|^[0-9a-zA-Z_]{64}\$|^[0-9a-zA-Z_]{65}\$|^[0-9a-zA-Z]{92}\$|^[0-9a-zA-Z]{105}\$|^[0-9a-zA-Z]{106}\$';
132 - final regExp = RegExp(pattern);
133 - isValid = regExp.hasMatch(value);
134 - if (isValid && cryptoCurrency != null) {
135 - switch (cryptoCurrency) {
136 - case CryptoCurrency.xmr:
137 - isValid = (value.length == 95)||(value.length == 106);
138 - break;
139 - case CryptoCurrency.ada:
140 - isValid = (value.length == 59)||(value.length == 92)||(value.length == 105);
141 - break;
142 - case CryptoCurrency.bch:
143 - isValid = (value.length == 42);
144 - break;
145 - case CryptoCurrency.bnb:
146 - isValid = (value.length == 42);
147 - break;
148 - case CryptoCurrency.btc:
149 - isValid = (value.length == 34)||(value.length == 42);
150 - break;
151 - case CryptoCurrency.dash:
152 - isValid = (value.length == 34);
153 - break;
154 - case CryptoCurrency.eos:
155 - isValid = (value.length == 42);
156 - break;
157 - case CryptoCurrency.eth:
158 - isValid = (value.length == 42);
159 - break;
160 - case CryptoCurrency.ltc:
161 - isValid = (value.length == 34);
162 - break;
163 - case CryptoCurrency.nano:
164 - isValid = (value.length == 64)||(value.length == 65);
165 - break;
166 - case CryptoCurrency.trx:
167 - isValid = (value.length == 34);
168 - break;
169 - case CryptoCurrency.usdt:
170 - isValid = (value.length == 42);
171 - break;
172 - case CryptoCurrency.xlm:
173 - isValid = (value.length == 56);
174 - break;
175 - case CryptoCurrency.xrp:
176 - isValid = (value.length == 34);
177 - break;
178 - }
179 - }
180 -
181 - errorMessage = isValid ? null : S.current.error_text_address;
182 - }
183 -
184 - void validateKeys(String value) {
185 - const pattern = '^[A-Fa-f0-9]{64}\$';
186 - final regExp = RegExp(pattern);
187 - isValid = regExp.hasMatch(value);
188 - errorMessage = isValid ? null : S.current.error_text_keys;
189 - }
190 -}
lib/src/stores/wallet_seed/wallet_seed_store.dart deleted
-24
@@ -1,24 +0,0 @@
1 -import 'package:flutter/foundation.dart';
2 -import 'package:mobx/mobx.dart';
3 -import 'package:cake_wallet/src/domain/services/wallet_service.dart';
4 -
5 -part 'wallet_seed_store.g.dart';
6 -
7 -class WalletSeedStore = WalletSeedStoreBase with _$WalletSeedStore;
8 -
9 -abstract class WalletSeedStoreBase with Store {
10 - WalletSeedStoreBase({@required WalletService walletService}) {
11 - seed = '';
12 -
13 - if (walletService.currentWallet != null) {
14 - walletService.getSeed().then((seed) => this.seed = seed);
15 - walletService.getName().then((name) => this.name = name);
16 - }
17 - }
18 -
19 - @observable
20 - String name;
21 -
22 - @observable
23 - String seed;
24 -}
lib/src/util/index.dart
lib/src/widgets/address_text_field.dart
+76 -85
@@ -1,31 +1,30 @@
1 -import 'package:cake_wallet/routes.dart';
1 +import 'package:flutter/services.dart';
2 import 'package:flutter/material.dart';
3 +import 'package:cake_wallet/routes.dart';
4 import 'package:cake_wallet/generated/i18n.dart';
4 -import 'package:cake_wallet/src/domain/common/contact.dart';
5 -import 'package:cake_wallet/src/domain/monero/subaddress.dart';
6 -import 'package:cake_wallet/src/domain/common/qr_scanner.dart';
7 -import 'package:flutter/services.dart';
5 +import 'package:cake_wallet/entities/contact.dart';
6 +import 'package:cake_wallet/entities/qr_scanner.dart';
7
9 -enum AddressTextFieldOption { paste, qrCode, addressBook, subaddressList }
8 +enum AddressTextFieldOption { paste, qrCode, addressBook }
9
10 class AddressTextField extends StatelessWidget {
11 AddressTextField(
12 {@required this.controller,
14 - this.isActive = true,
15 - this.placeholder,
16 - this.options = const [
17 - AddressTextFieldOption.qrCode,
18 - AddressTextFieldOption.addressBook
19 - ],
20 - this.onURIScanned,
21 - this.focusNode,
22 - this.isBorderExist = true,
23 - this.buttonColor,
24 - this.borderColor,
25 - this.iconColor,
26 - this.textStyle,
27 - this.hintStyle,
28 - this.validator});
13 + this.isActive = true,
14 + this.placeholder,
15 + this.options = const [
16 + AddressTextFieldOption.qrCode,
17 + AddressTextFieldOption.addressBook
18 + ],
19 + this.onURIScanned,
20 + this.focusNode,
21 + this.isBorderExist = true,
22 + this.buttonColor,
23 + this.borderColor,
24 + this.iconColor,
25 + this.textStyle,
26 + this.hintStyle,
27 + this.validator});
28
29 static const prefixIconWidth = 34.0;
30 static const prefixIconHeight = 34.0;
@@ -54,35 +53,35 @@ class AddressTextField extends StatelessWidget {
53 enabled: isActive,
54 controller: controller,
55 focusNode: focusNode,
57 - style: textStyle ?? TextStyle(
58 - fontSize: 16,
59 - color: Theme.of(context).primaryTextTheme.title.color
60 - ),
56 + style: textStyle ??
57 + TextStyle(
58 + fontSize: 16,
59 + color: Theme.of(context).primaryTextTheme.title.color),
60 decoration: InputDecoration(
61 suffixIcon: SizedBox(
62 width: prefixIconWidth * options.length +
63 (spaceBetweenPrefixIcons * options.length),
64 ),
66 - hintStyle: hintStyle ?? TextStyle(
67 - fontSize: 16,
68 - color: Theme.of(context).hintColor
69 - ),
65 + hintStyle: hintStyle ??
66 + TextStyle(fontSize: 16, color: Theme.of(context).hintColor),
67 hintText: placeholder ?? S.current.widgets_address,
68 focusedBorder: isBorderExist
69 ? UnderlineInputBorder(
73 - borderSide: BorderSide(
74 - color: borderColor ?? Theme.of(context).dividerColor,
75 - width: 1.0))
70 + borderSide: BorderSide(
71 + color: borderColor ?? Theme.of(context).dividerColor,
72 + width: 1.0))
73 : InputBorder.none,
74 disabledBorder: isBorderExist
75 ? UnderlineInputBorder(
79 - borderSide:
80 - BorderSide(color: borderColor ?? Theme.of(context).dividerColor, width: 1.0))
76 + borderSide: BorderSide(
77 + color: borderColor ?? Theme.of(context).dividerColor,
78 + width: 1.0))
79 : InputBorder.none,
80 enabledBorder: isBorderExist
81 ? UnderlineInputBorder(
84 - borderSide:
85 - BorderSide(color: borderColor ?? Theme.of(context).dividerColor, width: 1.0))
82 + borderSide: BorderSide(
83 + color: borderColor ?? Theme.of(context).dividerColor,
84 + width: 1.0))
85 : InputBorder.none,
86 ),
87 validator: validator,
@@ -97,9 +96,7 @@ class AddressTextField extends StatelessWidget {
96 mainAxisAlignment: MainAxisAlignment.spaceBetween,
97 children: [
98 SizedBox(width: 5),
100 - if (this
101 - .options
102 - .contains(AddressTextFieldOption.paste)) ...[
99 + if (this.options.contains(AddressTextFieldOption.paste)) ...[
100 Container(
101 width: prefixIconWidth,
102 height: prefixIconHeight,
@@ -109,12 +106,20 @@ class AddressTextField extends StatelessWidget {
106 child: Container(
107 padding: EdgeInsets.all(8),
108 decoration: BoxDecoration(
112 - color: buttonColor ?? Theme.of(context).accentTextTheme.title.color,
109 + color: buttonColor ??
110 + Theme.of(context)
111 + .accentTextTheme
112 + .title
113 + .color,
114 borderRadius:
114 - BorderRadius.all(Radius.circular(6))),
115 + BorderRadius.all(Radius.circular(6))),
116 child: Image.asset(
116 - 'assets/images/duplicate.png',
117 - color: iconColor ?? Theme.of(context).primaryTextTheme.display1.decorationColor,
117 + 'assets/images/duplicate.png',
118 + color: iconColor ??
119 + Theme.of(context)
120 + .primaryTextTheme
121 + .display1
122 + .decorationColor,
123 )),
124 )),
125 ],
@@ -128,11 +133,20 @@ class AddressTextField extends StatelessWidget {
133 child: Container(
134 padding: EdgeInsets.all(8),
135 decoration: BoxDecoration(
131 - color: buttonColor ?? Theme.of(context).accentTextTheme.title.color,
136 + color: buttonColor ??
137 + Theme.of(context)
138 + .accentTextTheme
139 + .title
140 + .color,
141 borderRadius:
133 - BorderRadius.all(Radius.circular(6))),
134 - child: Image.asset('assets/images/qr_code_icon.png',
135 - color: iconColor ?? Theme.of(context).primaryTextTheme.display1.decorationColor,
142 + BorderRadius.all(Radius.circular(6))),
143 + child: Image.asset(
144 + 'assets/images/qr_code_icon.png',
145 + color: iconColor ??
146 + Theme.of(context)
147 + .primaryTextTheme
148 + .display1
149 + .decorationColor,
150 )),
151 ))
152 ],
@@ -148,40 +162,26 @@ class AddressTextField extends StatelessWidget {
162 child: Container(
163 padding: EdgeInsets.all(8),
164 decoration: BoxDecoration(
151 - color: buttonColor ?? Theme.of(context).accentTextTheme.title.color,
165 + color: buttonColor ??
166 + Theme.of(context)
167 + .accentTextTheme
168 + .title
169 + .color,
170 borderRadius:
153 - BorderRadius.all(Radius.circular(6))),
171 + BorderRadius.all(Radius.circular(6))),
172 child: Image.asset(
155 - 'assets/images/open_book.png',
156 - color: iconColor ?? Theme.of(context).primaryTextTheme.display1.decorationColor,
173 + 'assets/images/open_book.png',
174 + color: iconColor ??
175 + Theme.of(context)
176 + .primaryTextTheme
177 + .display1
178 + .decorationColor,
179 )),
180 ))
159 - ],
160 - if (this
161 - .options
162 - .contains(AddressTextFieldOption.subaddressList)) ...[
163 - Container(
164 - width: prefixIconWidth,
165 - height: prefixIconHeight,
166 - padding: EdgeInsets.only(top: 0),
167 - child: InkWell(
168 - onTap: () async => _presetSubaddressListPicker(context),
169 - child: Container(
170 - padding: EdgeInsets.all(8),
171 - decoration: BoxDecoration(
172 - color: buttonColor ?? Theme.of(context).accentTextTheme.title.color,
173 - borderRadius:
174 - BorderRadius.all(Radius.circular(6))),
175 - child: Image.asset(
176 - 'assets/images/receive_icon_raw.png',
177 - color: iconColor ?? Theme.of(context).primaryTextTheme.display1.decorationColor,
178 - )),
179 - )),
180 - ],
181 + ]
182 ],
183 ),
183 - )
184 - )
184 + ))
185 ],
186 );
187 }
@@ -217,15 +217,6 @@ class AddressTextField extends StatelessWidget {
217 }
218 }
219
220 - Future<void> _presetSubaddressListPicker(BuildContext context) async {
221 - final subaddress = await Navigator.of(context, rootNavigator: true)
222 - .pushNamed(Routes.subaddressList);
223 -
224 - if (subaddress is Subaddress && subaddress.address != null) {
225 - controller.text = subaddress.address;
226 - }
227 - }
228 -
220 Future<void> _pasteAddress(BuildContext context) async {
221 String address;
222
@@ -235,4 +226,4 @@ class AddressTextField extends StatelessWidget {
226 controller.text = address;
227 }
228 }
238 -}
\ No newline at end of file
229 +}
lib/src/widgets/blockchain_height_widget.dart
+1 -1
@@ -1,7 +1,7 @@
1 import 'package:flutter/material.dart';
2 import 'package:intl/intl.dart';
3 import 'package:cake_wallet/generated/i18n.dart';
4 -import 'package:cake_wallet/src/domain/monero/get_height_by_date.dart';
4 +import 'package:cake_wallet/monero/get_height_by_date.dart';
5 import 'package:cake_wallet/src/widgets/base_text_form_field.dart';
6
7 class BlockchainHeightWidget extends StatefulWidget {
lib/src/widgets/seed_widget.dart
+1 -1
@@ -4,7 +4,7 @@ import 'package:flutter/services.dart';
4 import 'package:cake_wallet/palette.dart';
5 import 'package:cake_wallet/core/seed_validator.dart';
6 import 'package:cake_wallet/src/widgets/primary_button.dart';
7 -import 'package:cake_wallet/src/domain/common/mnemonic_item.dart';
7 +import 'package:cake_wallet/entities/mnemonic_item.dart';
8 import 'package:cake_wallet/generated/i18n.dart';
9 import 'package:flutter/widgets.dart';
10
lib/store/contact_list_store.dart
+1 -1
@@ -1,5 +1,5 @@
1 import 'package:mobx/mobx.dart';
2 -import 'package:cake_wallet/src/domain/common/contact.dart';
2 +import 'package:cake_wallet/entities/contact.dart';
3
4 part 'contact_list_store.g.dart';
5
lib/store/dashboard/fiat_conversion_store.dart new
+13
@@ -0,0 +1,13 @@
1 +import 'package:mobx/mobx.dart';
2 +
3 +part 'fiat_conversion_store.g.dart';
4 +
5 +class FiatConversionStore = FiatConversionStoreBase
6 + with _$FiatConversionStore;
7 +
8 +abstract class FiatConversionStoreBase with Store {
9 + FiatConversionStoreBase() : price = 0.0;
10 +
11 + @observable
12 + double price;
13 +}
lib/store/dashboard/fiat_convertation_store.dart deleted
-19
@@ -1,19 +0,0 @@
1 -import 'package:mobx/mobx.dart';
2 -
3 -part 'fiat_convertation_store.g.dart';
4 -
5 -class FiatConvertationStore = FiatConvertationStoreBase with _$FiatConvertationStore;
6 -
7 -abstract class FiatConvertationStoreBase with Store {
8 - FiatConvertationStoreBase() {
9 - setPrice(0.0);
10 - }
11 -
12 - @observable
13 - double price;
14 -
15 - @action
16 - void setPrice(double price) {
17 - this.price = price;
18 - }
19 -}
\ No newline at end of file
lib/store/dashboard/trade_filter_store.dart
+1 -1
@@ -1,6 +1,6 @@
1 import 'package:cake_wallet/core/wallet_base.dart';
2 import 'package:mobx/mobx.dart';
3 -import 'package:cake_wallet/src/domain/exchange/exchange_provider_description.dart';
3 +import 'package:cake_wallet/exchange/exchange_provider_description.dart';
4 import 'package:cake_wallet/view_model/dashboard/trade_list_item.dart';
5
6 part 'trade_filter_store.g.dart';
lib/store/dashboard/trades_store.dart
+1 -1
@@ -1,5 +1,5 @@
1 import 'dart:async';
2 -import 'package:cake_wallet/src/domain/exchange/trade.dart';
2 +import 'package:cake_wallet/exchange/trade.dart';
3 import 'package:cake_wallet/view_model/dashboard/trade_list_item.dart';
4 import 'package:flutter/cupertino.dart';
5 import 'package:hive/hive.dart';
lib/store/dashboard/transaction_filter_store.dart
+1 -1
@@ -1,5 +1,5 @@
1 import 'package:mobx/mobx.dart';
2 -import 'package:cake_wallet/src/domain/common/transaction_direction.dart';
2 +import 'package:cake_wallet/entities/transaction_direction.dart';
3 import 'package:cake_wallet/view_model/dashboard/transaction_list_item.dart';
4
5 part 'transaction_filter_store.g.dart';
lib/store/node_list_store.dart
+22 -1
@@ -1,5 +1,9 @@
1 +import 'dart:async';
2 +import 'package:hive/hive.dart';
3 import 'package:mobx/mobx.dart';
2 -import 'package:cake_wallet/src/domain/common/node.dart';
4 +import 'package:cake_wallet/di.dart';
5 +import 'package:cake_wallet/entities/node.dart';
6 +import 'package:cake_wallet/utils/mobx.dart';
7
8 part 'node_list_store.g.dart';
9
@@ -8,6 +12,23 @@ class NodeListStore = NodeListStoreBase with _$NodeListStore;
12 abstract class NodeListStoreBase with Store {
13 NodeListStoreBase() : nodes = ObservableList<Node>();
14
15 + static StreamSubscription<BoxEvent> _onNodesSourceChange;
16 + static NodeListStore _instance;
17 +
18 + static NodeListStore get instance {
19 + if (_instance != null) {
20 + return _instance;
21 + }
22 +
23 + final nodeSource = getIt.get<Box<Node>>();
24 + _instance = NodeListStore();
25 + _instance.replaceValues(nodeSource.values);
26 + _onNodesSourceChange?.cancel();
27 + _onNodesSourceChange = bindBox(nodeSource, _instance.nodes);
28 +
29 + return _instance;
30 + }
31 +
32 final ObservableList<Node> nodes;
33
34 void replaceValues(Iterable<Node> newNodes) {
lib/store/settings_store.dart
+60 -57
@@ -1,17 +1,18 @@
1 -import 'package:cake_wallet/di.dart';
2 -import 'package:cake_wallet/src/domain/common/wallet_type.dart';
1 +import 'package:cake_wallet/entities/preferences_key.dart';
2 import 'package:flutter/foundation.dart';
3 import 'package:hive/hive.dart';
4 import 'package:mobx/mobx.dart';
6 -import 'package:devicelocale/devicelocale.dart';
5 import 'package:package_info/package_info.dart';
6 +import 'package:devicelocale/devicelocale.dart';
7 +import 'package:cake_wallet/di.dart';
8 +import 'package:cake_wallet/entities/wallet_type.dart';
9 import 'package:shared_preferences/shared_preferences.dart';
9 -import 'package:cake_wallet/src/domain/common/language.dart';
10 -import 'package:cake_wallet/src/domain/common/balance_display_mode.dart';
11 -import 'package:cake_wallet/src/domain/common/fiat_currency.dart';
12 -import 'package:cake_wallet/src/domain/common/node.dart';
13 -import 'package:cake_wallet/src/domain/common/transaction_priority.dart';
14 -import 'package:cake_wallet/src/stores/action_list/action_list_display_mode.dart';
10 +import 'package:cake_wallet/entities/language.dart';
11 +import 'package:cake_wallet/entities/balance_display_mode.dart';
12 +import 'package:cake_wallet/entities/fiat_currency.dart';
13 +import 'package:cake_wallet/entities/node.dart';
14 +import 'package:cake_wallet/entities/transaction_priority.dart';
15 +import 'package:cake_wallet/entities/action_list_display_mode.dart';
16
17 part 'settings_store.g.dart';
18
@@ -30,7 +31,6 @@ abstract class SettingsStoreBase with Store {
31 @required int initialPinLength,
32 @required String initialLanguageCode,
33 @required String initialCurrentLocale,
33 -// @required this.node,
34 @required this.appVersion,
35 @required Map<WalletType, Node> nodes,
36 this.actionlistDisplayMode}) {
@@ -40,7 +40,7 @@ abstract class SettingsStoreBase with Store {
40 shouldSaveRecipientAddress = initialSaveRecipientAddress;
41 allowBiometricalAuthentication = initialAllowBiometricalAuthentication;
42 isDarkTheme = initialDarkTheme;
43 - defaultPinLength = initialPinLength;
43 + pinCodeLength = initialPinLength;
44 languageCode = initialLanguageCode;
45 currentLocale = initialCurrentLocale;
46 itemHeaders = {};
@@ -51,21 +51,17 @@ abstract class SettingsStoreBase with Store {
51 reaction(
52 (_) => allowBiometricalAuthentication,
53 (bool biometricalAuthentication) => sharedPreferences.setBool(
54 - allowBiometricalAuthenticationKey, biometricalAuthentication));
54 + PreferencesKey.allowBiometricalAuthenticationKey,
55 + biometricalAuthentication));
56 +
57 + reaction(
58 + (_) => pinCodeLength,
59 + (int pinLength) => sharedPreferences.setInt(
60 + PreferencesKey.currentPinLength, pinLength));
61 }
62
57 - static const currentNodeIdKey = 'current_node_id';
58 - static const currentBitcoinElectrumSererIdKey = 'current_node_id_btc';
59 - static const currentFiatCurrencyKey = 'current_fiat_currency';
60 - static const currentTransactionPriorityKey = 'current_fee_priority';
61 - static const currentBalanceDisplayModeKey = 'current_balance_display_mode';
62 - static const shouldSaveRecipientAddressKey = 'save_recipient_address';
63 - static const allowBiometricalAuthenticationKey =
64 - 'allow_biometrical_authentication';
65 - static const currentDarkTheme = 'dark_theme';
66 - static const displayActionListModeKey = 'display_list_mode';
67 - static const currentPinLength = 'current_pin_length';
68 - static const currentLanguageCode = 'language_code';
63 + static const defaultPinLength = 4;
64 + static const defaultActionsMode = 11;
65
66 @observable
67 FiatCurrency fiatCurrency;
@@ -89,7 +85,7 @@ abstract class SettingsStoreBase with Store {
85 bool isDarkTheme;
86
87 @observable
92 - int defaultPinLength;
88 + int pinCodeLength;
89
90 @observable
91 Map<String, String> itemHeaders;
@@ -107,22 +103,6 @@ abstract class SettingsStoreBase with Store {
103
104 Node getCurrentNode(WalletType walletType) => nodes[walletType];
105
110 - Future<void> setCurrentNode(Node node, WalletType walletType) async {
111 - switch (walletType) {
112 - case WalletType.bitcoin:
113 - await _sharedPreferences.setInt(
114 - currentBitcoinElectrumSererIdKey, node.key as int);
115 - break;
116 - case WalletType.monero:
117 - await _sharedPreferences.setInt(currentNodeIdKey, node.key as int);
118 - break;
119 - default:
120 - break;
121 - }
122 -
123 - nodes[walletType] = node;
124 - }
125 -
106 static Future<SettingsStore> load(
107 {@required Box<Node> nodeSource,
108 FiatCurrency initialFiatCurrency = FiatCurrency.usd,
@@ -131,29 +111,35 @@ abstract class SettingsStoreBase with Store {
111 BalanceDisplayMode.availableBalance}) async {
112 final sharedPreferences = await getIt.getAsync<SharedPreferences>();
113 final currentFiatCurrency = FiatCurrency(
134 - symbol: sharedPreferences.getString(currentFiatCurrencyKey));
114 + symbol:
115 + sharedPreferences.getString(PreferencesKey.currentFiatCurrencyKey));
116 final currentTransactionPriority = TransactionPriority.deserialize(
136 - raw: sharedPreferences.getInt(currentTransactionPriorityKey));
117 + raw: sharedPreferences
118 + .getInt(PreferencesKey.currentTransactionPriorityKey));
119 final currentBalanceDisplayMode = BalanceDisplayMode.deserialize(
138 - raw: sharedPreferences.getInt(currentBalanceDisplayModeKey));
120 + raw: sharedPreferences
121 + .getInt(PreferencesKey.currentBalanceDisplayModeKey));
122 final shouldSaveRecipientAddress =
140 - sharedPreferences.getBool(shouldSaveRecipientAddressKey);
141 - final allowBiometricalAuthentication =
142 - sharedPreferences.getBool(allowBiometricalAuthenticationKey) ?? false;
143 - final savedDarkTheme = sharedPreferences.getBool(currentDarkTheme) ?? false;
123 + sharedPreferences.getBool(PreferencesKey.shouldSaveRecipientAddressKey);
124 + final allowBiometricalAuthentication = sharedPreferences
125 + .getBool(PreferencesKey.allowBiometricalAuthenticationKey) ??
126 + false;
127 + final savedDarkTheme =
128 + sharedPreferences.getBool(PreferencesKey.currentDarkTheme) ?? false;
129 final actionListDisplayMode = ObservableList<ActionListDisplayMode>();
130 actionListDisplayMode.addAll(deserializeActionlistDisplayModes(
146 - sharedPreferences.getInt(displayActionListModeKey) ??
147 - 11)); // FIXME: Unnamed constant.
148 - final defaultPinLength = sharedPreferences.getInt(currentPinLength) ??
149 - 4; // FIXME: Unnamed constant.
131 + sharedPreferences.getInt(PreferencesKey.displayActionListModeKey) ??
132 + defaultActionsMode));
133 + final pinLength =
134 + sharedPreferences.getInt(PreferencesKey.currentPinLength) ??
135 + defaultPinLength;
136 final savedLanguageCode =
151 - sharedPreferences.getString(currentLanguageCode) ??
137 + sharedPreferences.getString(PreferencesKey.currentLanguageCode) ??
138 await Language.localeDetection();
139 final initialCurrentLocale = await Devicelocale.currentLocale;
154 - final nodeId = sharedPreferences.getInt(currentNodeIdKey);
155 - final bitcoinElectrumServerId =
156 - sharedPreferences.getInt(currentBitcoinElectrumSererIdKey);
140 + final nodeId = sharedPreferences.getInt(PreferencesKey.currentNodeIdKey);
141 + final bitcoinElectrumServerId = sharedPreferences
142 + .getInt(PreferencesKey.currentBitcoinElectrumSererIdKey);
143 final moneroNode = nodeSource.get(nodeId);
144 final bitcoinElectrumServer = nodeSource.get(bitcoinElectrumServerId);
145 final packageInfo = await PackageInfo.fromPlatform();
@@ -173,8 +159,25 @@ abstract class SettingsStoreBase with Store {
159 initialAllowBiometricalAuthentication: allowBiometricalAuthentication,
160 initialDarkTheme: savedDarkTheme,
161 actionlistDisplayMode: actionListDisplayMode,
176 - initialPinLength: defaultPinLength,
162 + initialPinLength: pinLength,
163 initialLanguageCode: savedLanguageCode,
164 initialCurrentLocale: initialCurrentLocale);
165 }
166 +
167 + Future<void> setCurrentNode(Node node, WalletType walletType) async {
168 + switch (walletType) {
169 + case WalletType.bitcoin:
170 + await _sharedPreferences.setInt(
171 + PreferencesKey.currentBitcoinElectrumSererIdKey, node.key as int);
172 + break;
173 + case WalletType.monero:
174 + await _sharedPreferences.setInt(
175 + PreferencesKey.currentNodeIdKey, node.key as int);
176 + break;
177 + default:
178 + break;
179 + }
180 +
181 + nodes[walletType] = node;
182 + }
183 }
lib/store/templates/exchange_template_store.dart
+1 -1
@@ -1,7 +1,7 @@
1 import 'dart:async';
2 import 'package:mobx/mobx.dart';
3 import 'package:hive/hive.dart';
4 -import 'package:cake_wallet/src/domain/exchange/exchange_template.dart';
4 +import 'package:cake_wallet/exchange/exchange_template.dart';
5
6 part 'exchange_template_store.g.dart';
7
lib/store/templates/send_template_store.dart
+1 -1
@@ -1,7 +1,7 @@
1 import 'dart:async';
2 import 'package:mobx/mobx.dart';
3 import 'package:hive/hive.dart';
4 -import 'package:cake_wallet/src/domain/common/template.dart';
4 +import 'package:cake_wallet/entities/template.dart';
5
6 part 'send_template_store.g.dart';
7
lib/store/wallet_list_store.dart
+1 -1
@@ -1,5 +1,5 @@
1 import 'package:mobx/mobx.dart';
2 -import 'package:cake_wallet/src/domain/common/wallet_description.dart';
2 +import 'package:cake_wallet/entities/wallet_description.dart';
3
4 part 'wallet_list_store.g.dart';
5
lib/utils/date_formatter.dart new
+15
@@ -0,0 +1,15 @@
1 +import 'package:intl/intl.dart';
2 +import 'package:cake_wallet/di.dart';
3 +import 'package:cake_wallet/store/settings_store.dart';
4 +
5 +class DateFormatter {
6 + static String get currentLocalFormat {
7 + final isUSA = getIt.get<SettingsStore>().currentLocale == 'en_US';
8 + final format = isUSA ? 'yyyy.MM.dd, HH:mm' : 'dd.MM.yyyy, HH:mm';
9 +
10 + return format;
11 + }
12 +
13 + static DateFormat withCurrentLocal() =>
14 + DateFormat(currentLocalFormat, getIt.get<SettingsStore>().languageCode);
15 +}
lib/utils/language_list.dart new
+10
@@ -0,0 +1,10 @@
1 +class LanguageList {
2 + static const english = 'English';
3 + static const chineseSimplified = 'Chinese (simplified)';
4 + static const dutch = 'Dutch';
5 + static const german = 'German';
6 + static const japanese = 'Japanese';
7 + static const portuguese = 'Portuguese';
8 + static const russian = 'Russian';
9 + static const spanish = 'Spanish';
10 +}
\ No newline at end of file
lib/utils/mobx.dart
-1
@@ -1,5 +1,4 @@
1 import 'dart:async';
2 -
2 import 'package:hive/hive.dart';
3 import 'package:mobx/mobx.dart';
4
lib/view_model/auth_state.dart
+2 -14
@@ -1,18 +1,6 @@
1 -abstract class AuthState {}
1 +import 'package:cake_wallet/core/execution_state.dart';
2
3 -class AuthenticationStateInitial extends AuthState {}
4 -
5 -class AuthenticationInProgress extends AuthState {}
6 -
7 -class AuthenticatedSuccessfully extends AuthState {}
8 -
9 -class AuthenticationFailure extends AuthState {
10 - AuthenticationFailure({this.error});
11 -
12 - final String error;
13 -}
14 -
15 -class AuthenticationBanned extends AuthState {
3 +class AuthenticationBanned extends ExecutionState {
4 AuthenticationBanned({this.error});
5
6 final String error;
lib/view_model/auth_view_model.dart
+41 -19
@@ -1,38 +1,47 @@
1 import 'dart:async';
2 -import 'package:flutter/foundation.dart';
2 import 'package:shared_preferences/shared_preferences.dart';
3 import 'package:mobx/mobx.dart';
4 import 'package:cake_wallet/view_model/auth_state.dart';
5 import 'package:cake_wallet/core/auth_service.dart';
6 import 'package:cake_wallet/generated/i18n.dart';
7 +import 'package:cake_wallet/core/execution_state.dart';
8 +import 'package:cake_wallet/entities/biometric_auth.dart';
9 +import 'package:cake_wallet/store/settings_store.dart';
10
11 part 'auth_view_model.g.dart';
12
13 class AuthViewModel = AuthViewModelBase with _$AuthViewModel;
14
15 abstract class AuthViewModelBase with Store {
14 - AuthViewModelBase(
15 - {@required this.authService, @required this.sharedPreferences}) {
16 - state = AuthenticationStateInitial();
16 + AuthViewModelBase(this._authService, this._sharedPreferences,
17 + this._settingsStore, this._biometricAuth) {
18 + state = InitialExecutionState();
19 _failureCounter = 0;
20 }
21
22 static const maxFailedLogins = 3;
21 - static const banTimeout = 180; // 3 mins
23 + static const banTimeout = 180; // 3 minutes
24 final banTimeoutKey = S.current.auth_store_ban_timeout;
25
24 - final AuthService authService;
25 - final SharedPreferences sharedPreferences;
26 -
26 @observable
28 - AuthState state;
27 + ExecutionState state;
28 +
29 + int get pinLength => _settingsStore.pinCodeLength;
30 +
31 + bool get isBiometricalAuthenticationAllowed =>
32 + _settingsStore.allowBiometricalAuthentication;
33
34 @observable
35 int _failureCounter;
36
37 + final AuthService _authService;
38 + final BiometricAuth _biometricAuth;
39 + final SharedPreferences _sharedPreferences;
40 + final SettingsStore _settingsStore;
41 +
42 @action
43 Future<void> auth({String password}) async {
35 - state = AuthenticationStateInitial();
44 + state = InitialExecutionState();
45 final _banDuration = banDuration();
46
47 if (_banDuration != null) {
@@ -43,11 +52,11 @@ abstract class AuthViewModelBase with Store {
52 return;
53 }
54
46 - state = AuthenticationInProgress();
47 - final isAuth = await authService.authenticate(password);
55 + state = IsExecutingState();
56 + final isSuccessfulAuthenticated = await _authService.authenticate(password);
57
49 - if (isAuth) {
50 - state = AuthenticatedSuccessfully();
58 + if (isSuccessfulAuthenticated) {
59 + state = ExecutedSuccessfullyState();
60 _failureCounter = 0;
61 } else {
62 _failureCounter += 1;
@@ -61,13 +70,12 @@ abstract class AuthViewModelBase with Store {
70 return;
71 }
72
64 - state =
65 - AuthenticationFailure(error: S.current.auth_store_incorrect_password);
73 + state = FailureState(S.current.auth_store_incorrect_password);
74 }
75 }
76
77 Duration banDuration() {
70 - final unbanTimestamp = sharedPreferences.getInt(banTimeoutKey);
78 + final unbanTimestamp = _sharedPreferences.getInt(banTimeoutKey);
79
80 if (unbanTimestamp == null) {
81 return null;
@@ -87,11 +95,25 @@ abstract class AuthViewModelBase with Store {
95 final multiplier = _failureCounter - maxFailedLogins + 1;
96 final timeout = (multiplier * banTimeout) * 1000;
97 final unbanTimestamp = DateTime.now().millisecondsSinceEpoch + timeout;
90 - await sharedPreferences.setInt(banTimeoutKey, unbanTimestamp);
98 + await _sharedPreferences.setInt(banTimeoutKey, unbanTimestamp);
99
100 return Duration(milliseconds: timeout);
101 }
102
103 @action
96 - void biometricAuth() => state = AuthenticatedSuccessfully();
104 + Future<void> biometricAuth() async {
105 + try {
106 + final canBiometricAuth = await _biometricAuth.canCheckBiometrics();
107 +
108 + if (canBiometricAuth) {
109 + final isAuthenticated = await _biometricAuth.isAuthenticated();
110 +
111 + if (isAuthenticated) {
112 + state = ExecutedSuccessfullyState();
113 + }
114 + }
115 + } catch(e) {
116 + state = FailureState(e.toString());
117 + }
118 + }
119 }
lib/view_model/contact_list/contact_list_view_model.dart
+1 -2
@@ -1,10 +1,9 @@
1 import 'dart:async';
2 -
2 import 'package:hive/hive.dart';
3 import 'package:mobx/mobx.dart';
4 import 'package:cake_wallet/core/contact_service.dart';
5 import 'package:cake_wallet/store/contact_list_store.dart';
7 -import 'package:cake_wallet/src/domain/common/contact.dart';
6 +import 'package:cake_wallet/entities/contact.dart';
7 import 'package:cake_wallet/utils/mobx.dart';
8
9 part 'contact_list_view_model.g.dart';
lib/view_model/contact_list/contact_view_model.dart
+8 -13
@@ -1,10 +1,10 @@
1 import 'package:hive/hive.dart';
2 import 'package:mobx/mobx.dart';
3 +import 'package:cake_wallet/core/execution_state.dart';
4 import 'package:cake_wallet/core/wallet_base.dart';
5 import 'package:cake_wallet/core/contact_service.dart';
5 -import 'package:cake_wallet/src/domain/common/contact.dart';
6 -import 'package:cake_wallet/src/domain/common/crypto_currency.dart';
7 -import 'package:cake_wallet/view_model/contact_list/contact_view_model_state.dart';
6 +import 'package:cake_wallet/entities/contact.dart';
7 +import 'package:cake_wallet/entities/crypto_currency.dart';
8
9 part 'contact_view_model.g.dart';
10
@@ -12,7 +12,7 @@ class ContactViewModel = ContactViewModelBase with _$ContactViewModel;
12
13 abstract class ContactViewModelBase with Store {
14 ContactViewModelBase(this._contacts, this._wallet, {Contact contact})
15 - : state = InitialContactViewModelState(),
15 + : state = InitialExecutionState(),
16 currencies = CryptoCurrency.all,
17 _contact = contact {
18 name = _contact?.name;
@@ -21,7 +21,7 @@ abstract class ContactViewModelBase with Store {
21 }
22
23 @observable
24 - ContactViewModelState state;
24 + ExecutionState state;
25
26 @observable
27 String name;
@@ -39,7 +39,6 @@ abstract class ContactViewModelBase with Store {
39 (address?.isNotEmpty ?? false);
40
41 final List<CryptoCurrency> currencies;
42 - // final ContactService _contactService;
42 final WalletBase _wallet;
43 final Box<Contact> _contacts;
44 final Contact _contact;
@@ -48,30 +47,26 @@ abstract class ContactViewModelBase with Store {
47 void reset() {
48 address = '';
49 name = '';
51 - //currency = _wallet.currency;
50 currency = null;
51 }
52
53 Future save() async {
54 try {
57 - state = ContactIsCreating();
55 + state = IsExecutingState();
56
57 if (_contact != null) {
58 _contact.name = name;
59 _contact.address = address;
60 _contact.updateCryptoCurrency(currency: currency);
61 await _contacts.put(_contact.key, _contact);
64 - // await _contactService.update(_contact);
62 } else {
63 await _contacts
64 .add(Contact(name: name, address: address, type: currency));
68 - // await _contactService
69 - // .add(Contact(name: name, address: address, type: currency));
65 }
66
72 - state = ContactSavingSuccessfully();
67 + state = ExecutedSuccessfullyState();
68 } catch (e) {
74 - state = ContactCreationFailure(e.toString());
69 + state = FailureState(e.toString());
70 }
71 }
72 }
lib/view_model/contact_list/contact_view_model_state.dart deleted
-13
@@ -1,13 +0,0 @@
1 -abstract class ContactViewModelState {}
2 -
3 -class InitialContactViewModelState extends ContactViewModelState {}
4 -
5 -class ContactIsCreating extends ContactViewModelState {}
6 -
7 -class ContactSavingSuccessfully extends ContactViewModelState {}
8 -
9 -class ContactCreationFailure extends ContactViewModelState {
10 - ContactCreationFailure(this.error);
11 -
12 - final String error;
13 -}
\ No newline at end of file
lib/view_model/dashboard/balance_view_model.dart
+4 -4
@@ -1,11 +1,11 @@
1 import 'package:cake_wallet/bitcoin/bitcoin_wallet.dart';
2 import 'package:cake_wallet/core/wallet_base.dart';
3 import 'package:cake_wallet/monero/monero_wallet.dart';
4 -import 'package:cake_wallet/src/domain/common/balance_display_mode.dart';
5 -import 'package:cake_wallet/src/domain/common/calculate_fiat_amount.dart';
4 +import 'package:cake_wallet/entities/balance_display_mode.dart';
5 +import 'package:cake_wallet/entities/calculate_fiat_amount.dart';
6 import 'package:cake_wallet/view_model/dashboard/wallet_balance.dart';
7 import 'package:cake_wallet/store/settings_store.dart';
8 -import 'package:cake_wallet/store/dashboard/fiat_convertation_store.dart';
8 +import 'package:cake_wallet/store/dashboard/fiat_conversion_store.dart';
9 import 'package:flutter/cupertino.dart';
10 import 'package:mobx/mobx.dart';
11
@@ -22,7 +22,7 @@ abstract class BalanceViewModelBase with Store {
22
23 final WalletBase wallet;
24 final SettingsStore settingsStore;
25 - final FiatConvertationStore fiatConvertationStore;
25 + final FiatConversionStore fiatConvertationStore;
26
27 WalletBalance _getWalletBalance() {
28 final _wallet = wallet;
lib/view_model/dashboard/dashboard_view_model.dart
+8 -8
@@ -1,12 +1,12 @@
1 import 'package:cake_wallet/bitcoin/bitcoin_transaction_info.dart';
2 import 'package:cake_wallet/bitcoin/bitcoin_wallet.dart';
3 import 'package:cake_wallet/monero/monero_wallet.dart';
4 -import 'package:cake_wallet/src/domain/common/balance_display_mode.dart';
5 -import 'package:cake_wallet/src/domain/common/crypto_currency.dart';
6 -import 'package:cake_wallet/src/domain/common/transaction_direction.dart';
7 -import 'package:cake_wallet/src/domain/common/transaction_info.dart';
8 -import 'package:cake_wallet/src/domain/exchange/exchange_provider_description.dart';
9 -import 'package:cake_wallet/src/domain/exchange/trade.dart';
4 +import 'package:cake_wallet/entities/balance_display_mode.dart';
5 +import 'package:cake_wallet/entities/crypto_currency.dart';
6 +import 'package:cake_wallet/entities/transaction_direction.dart';
7 +import 'package:cake_wallet/entities/transaction_info.dart';
8 +import 'package:cake_wallet/exchange/exchange_provider_description.dart';
9 +import 'package:cake_wallet/exchange/trade.dart';
10 import 'package:cake_wallet/view_model/dashboard/balance_view_model.dart';
11 import 'package:cake_wallet/view_model/dashboard/filter_item.dart';
12 import 'package:cake_wallet/view_model/dashboard/trade_list_item.dart';
@@ -15,8 +15,8 @@ import 'package:cake_wallet/view_model/dashboard/action_list_item.dart';
15 import 'package:cake_wallet/view_model/dashboard/action_list_display_mode.dart';
16 import 'package:mobx/mobx.dart';
17 import 'package:cake_wallet/core/wallet_base.dart';
18 -import 'package:cake_wallet/src/domain/common/sync_status.dart';
19 -import 'package:cake_wallet/src/domain/common/wallet_type.dart';
18 +import 'package:cake_wallet/entities/sync_status.dart';
19 +import 'package:cake_wallet/entities/wallet_type.dart';
20 import 'package:cake_wallet/store/app_store.dart';
21 import 'package:cake_wallet/generated/i18n.dart';
22 import 'package:cake_wallet/store/dashboard/trades_store.dart';
lib/view_model/dashboard/trade_list_item.dart
+2 -2
@@ -1,6 +1,6 @@
1 -import 'package:cake_wallet/src/domain/exchange/trade.dart';
1 +import 'package:cake_wallet/exchange/trade.dart';
2 import 'package:cake_wallet/view_model/dashboard/action_list_item.dart';
3 -import 'package:cake_wallet/src/domain/common/balance_display_mode.dart';
3 +import 'package:cake_wallet/entities/balance_display_mode.dart';
4
5 class TradeListItem extends ActionListItem {
6 TradeListItem({this.trade, this.displayMode});
lib/view_model/dashboard/transaction_list_item.dart
+6 -6
@@ -1,12 +1,12 @@
1 -import 'package:cake_wallet/src/domain/common/balance_display_mode.dart';
2 -import 'package:cake_wallet/src/domain/common/fiat_currency.dart';
3 -import 'package:cake_wallet/src/domain/common/transaction_info.dart';
1 +import 'package:cake_wallet/entities/balance_display_mode.dart';
2 +import 'package:cake_wallet/entities/fiat_currency.dart';
3 +import 'package:cake_wallet/entities/transaction_info.dart';
4 import 'package:cake_wallet/view_model/dashboard/action_list_item.dart';
5 import 'package:cake_wallet/bitcoin/bitcoin_transaction_info.dart';
6 -import 'package:cake_wallet/src/domain/monero/monero_transaction_info.dart';
7 -import 'package:cake_wallet/src/domain/monero/monero_amount_format.dart';
6 +import 'package:cake_wallet/monero/monero_transaction_info.dart';
7 +import 'package:cake_wallet/monero/monero_amount_format.dart';
8 import 'package:cake_wallet/bitcoin/bitcoin_amount_format.dart';
9 -import 'package:cake_wallet/src/domain/common/calculate_fiat_amount_raw.dart';
9 +import 'package:cake_wallet/entities/calculate_fiat_amount_raw.dart';
10
11 class TransactionListItem extends ActionListItem {
12 TransactionListItem({
lib/view_model/exchange/exchange_trade_view_model.dart
+6 -6
@@ -1,11 +1,11 @@
1 import 'dart:async';
2 import 'package:cake_wallet/core/wallet_base.dart';
3 -import 'package:cake_wallet/src/domain/exchange/changenow/changenow_exchange_provider.dart';
4 -import 'package:cake_wallet/src/domain/exchange/exchange_provider.dart';
5 -import 'package:cake_wallet/src/domain/exchange/exchange_provider_description.dart';
6 -import 'package:cake_wallet/src/domain/exchange/morphtoken/morphtoken_exchange_provider.dart';
7 -import 'package:cake_wallet/src/domain/exchange/trade.dart';
8 -import 'package:cake_wallet/src/domain/exchange/xmrto/xmrto_exchange_provider.dart';
3 +import 'package:cake_wallet/exchange/changenow/changenow_exchange_provider.dart';
4 +import 'package:cake_wallet/exchange/exchange_provider.dart';
5 +import 'package:cake_wallet/exchange/exchange_provider_description.dart';
6 +import 'package:cake_wallet/exchange/morphtoken/morphtoken_exchange_provider.dart';
7 +import 'package:cake_wallet/exchange/trade.dart';
8 +import 'package:cake_wallet/exchange/xmrto/xmrto_exchange_provider.dart';
9 import 'package:cake_wallet/store/dashboard/trades_store.dart';
10 import 'package:hive/hive.dart';
11 import 'package:mobx/mobx.dart';
lib/view_model/exchange/exchange_view_model.dart
+15 -15
@@ -1,25 +1,25 @@
1 import 'package:cake_wallet/core/wallet_base.dart';
2 -import 'package:cake_wallet/src/domain/common/crypto_currency.dart';
3 -import 'package:cake_wallet/src/domain/common/wallet_type.dart';
4 -import 'package:cake_wallet/src/domain/exchange/exchange_provider.dart';
5 -import 'package:cake_wallet/src/domain/exchange/limits.dart';
6 -import 'package:cake_wallet/src/domain/exchange/trade.dart';
7 -import 'package:cake_wallet/src/stores/exchange/limits_state.dart';
2 +import 'package:cake_wallet/entities/crypto_currency.dart';
3 +import 'package:cake_wallet/entities/wallet_type.dart';
4 +import 'package:cake_wallet/exchange/exchange_provider.dart';
5 +import 'package:cake_wallet/exchange/limits.dart';
6 +import 'package:cake_wallet/exchange/trade.dart';
7 +import 'package:cake_wallet/exchange/limits_state.dart';
8 import 'package:cake_wallet/store/dashboard/trades_store.dart';
9 import 'package:intl/intl.dart';
10 import 'package:mobx/mobx.dart';
11 import 'package:cake_wallet/generated/i18n.dart';
12 import 'package:hive/hive.dart';
13 -import 'package:cake_wallet/src/stores/exchange/exchange_trade_state.dart';
14 -import 'package:cake_wallet/src/domain/exchange/changenow/changenow_exchange_provider.dart';
15 -import 'package:cake_wallet/src/domain/exchange/changenow/changenow_request.dart';
16 -import 'package:cake_wallet/src/domain/exchange/trade_request.dart';
17 -import 'package:cake_wallet/src/domain/exchange/xmrto/xmrto_exchange_provider.dart';
18 -import 'package:cake_wallet/src/domain/exchange/xmrto/xmrto_trade_request.dart';
19 -import 'package:cake_wallet/src/domain/exchange/morphtoken/morphtoken_exchange_provider.dart';
20 -import 'package:cake_wallet/src/domain/exchange/morphtoken/morphtoken_request.dart';
13 +import 'package:cake_wallet/exchange/exchange_trade_state.dart';
14 +import 'package:cake_wallet/exchange/changenow/changenow_exchange_provider.dart';
15 +import 'package:cake_wallet/exchange/changenow/changenow_request.dart';
16 +import 'package:cake_wallet/exchange/trade_request.dart';
17 +import 'package:cake_wallet/exchange/xmrto/xmrto_exchange_provider.dart';
18 +import 'package:cake_wallet/exchange/xmrto/xmrto_trade_request.dart';
19 +import 'package:cake_wallet/exchange/morphtoken/morphtoken_exchange_provider.dart';
20 +import 'package:cake_wallet/exchange/morphtoken/morphtoken_request.dart';
21 import 'package:cake_wallet/store/templates/exchange_template_store.dart';
22 -import 'package:cake_wallet/src/domain/exchange/exchange_template.dart';
22 +import 'package:cake_wallet/exchange/exchange_template.dart';
23
24 part 'exchange_view_model.g.dart';
25
lib/view_model/monero_account_list/monero_account_edit_or_create_state.dart deleted
-15
@@ -1,15 +0,0 @@
1 -import 'package:flutter/foundation.dart';
2 -
3 -abstract class MoneroAccountEditOrCreateState {}
4 -
5 -class InitialAccountCreationState extends MoneroAccountEditOrCreateState {}
6 -
7 -class AccountIsCreating extends MoneroAccountEditOrCreateState {}
8 -
9 -class AccountCreatedSuccessfully extends MoneroAccountEditOrCreateState {}
10 -
11 -class AccountCreationFailure extends MoneroAccountEditOrCreateState {
12 - AccountCreationFailure({@required this.error});
13 -
14 - final String error;
15 -}
\ No newline at end of file
lib/view_model/monero_account_list/monero_account_edit_or_create_view_model.dart
+6 -6
@@ -1,7 +1,7 @@
1 import 'package:mobx/mobx.dart';
2 +import 'package:cake_wallet/core/execution_state.dart';
3 import 'package:cake_wallet/monero/monero_account_list.dart';
4 import 'package:cake_wallet/view_model/monero_account_list/account_list_item.dart';
4 -import 'package:cake_wallet/view_model/monero_account_list/monero_account_edit_or_create_state.dart';
5
6 part 'monero_account_edit_or_create_view_model.g.dart';
7
@@ -11,14 +11,14 @@ class MoneroAccountEditOrCreateViewModel = MoneroAccountEditOrCreateViewModelBas
11 abstract class MoneroAccountEditOrCreateViewModelBase with Store {
12 MoneroAccountEditOrCreateViewModelBase(this._moneroAccountList,
13 {AccountListItem accountListItem})
14 - : state = InitialAccountCreationState(),
14 + : state = InitialExecutionState(),
15 isEdit = accountListItem != null,
16 _accountListItem = accountListItem;
17
18 final bool isEdit;
19
20 @observable
21 - MoneroAccountEditOrCreateState state;
21 + ExecutionState state;
22
23 @observable
24 String label;
@@ -28,7 +28,7 @@ abstract class MoneroAccountEditOrCreateViewModelBase with Store {
28
29 Future<void> save() async {
30 try {
31 - state = AccountIsCreating();
31 + state = IsExecutingState();
32
33 if (_accountListItem != null) {
34 await _moneroAccountList.setLabelAccount(
@@ -37,9 +37,9 @@ abstract class MoneroAccountEditOrCreateViewModelBase with Store {
37 await _moneroAccountList.addAccount(label: label);
38 }
39
40 - state = AccountCreatedSuccessfully();
40 + state = ExecutedSuccessfullyState();
41 } catch (e) {
42 - state = AccountCreationFailure(error: e.toString());
42 + state = FailureState(e.toString());
43 }
44 }
45 }
lib/view_model/monero_account_list/monero_account_list_view_model.dart
+1 -1
@@ -1,5 +1,5 @@
1 import 'package:mobx/mobx.dart';
2 -import 'package:cake_wallet/src/domain/monero/account.dart';
2 +import 'package:cake_wallet/monero/account.dart';
3 import 'package:cake_wallet/monero/monero_wallet.dart';
4 import 'package:cake_wallet/view_model/monero_account_list/account_list_item.dart';
5
lib/view_model/node_list/node_create_or_edit_view_model.dart
+8 -8
@@ -1,9 +1,9 @@
1 +import 'package:cake_wallet/core/execution_state.dart';
2 import 'package:hive/hive.dart';
3 import 'package:mobx/mobx.dart';
4 import 'package:cake_wallet/core/wallet_base.dart';
4 -import 'package:cake_wallet/src/domain/common/node.dart';
5 -import 'package:cake_wallet/src/domain/common/wallet_type.dart';
6 -import 'package:cake_wallet/view_model/node_list/node_create_or_edit_view_model_state.dart';
5 +import 'package:cake_wallet/entities/node.dart';
6 +import 'package:cake_wallet/entities/wallet_type.dart';
7
8 part 'node_create_or_edit_view_model.g.dart';
9
@@ -12,10 +12,10 @@ class NodeCreateOrEditViewModel = NodeCreateOrEditViewModelBase
12
13 abstract class NodeCreateOrEditViewModelBase with Store {
14 NodeCreateOrEditViewModelBase(this._nodeSource, this._wallet)
15 - : state = InitialNodeCreateOrEditViewModelState();
15 + : state = InitialExecutionState();
16
17 @observable
18 - NodeCreateOrEditViewModelState state;
18 + ExecutionState state;
19
20 @observable
21 String address;
@@ -59,13 +59,13 @@ abstract class NodeCreateOrEditViewModelBase with Store {
59 @action
60 Future<void> save() async {
61 try {
62 - state = NodeIsCreating();
62 + state = IsExecutingState();
63 final node =
64 Node(uri: uri, type: _wallet.type, login: login, password: password);
65 await _nodeSource.add(node);
66 - state = NodeCreatedSuccessfully();
66 + state = ExecutedSuccessfullyState();
67 } catch (e) {
68 - state = NodeCreateOrEditViewModelFailure(e.toString());
68 + state = FailureState(e.toString());
69 }
70 }
71 }
lib/view_model/node_list/node_create_or_edit_view_model_state.dart deleted
-14
@@ -1,14 +0,0 @@
1 -abstract class NodeCreateOrEditViewModelState {}
2 -
3 -class InitialNodeCreateOrEditViewModelState
4 - extends NodeCreateOrEditViewModelState {}
5 -
6 -class NodeIsCreating extends NodeCreateOrEditViewModelState {}
7 -
8 -class NodeCreatedSuccessfully extends NodeCreateOrEditViewModelState {}
9 -
10 -class NodeCreateOrEditViewModelFailure extends NodeCreateOrEditViewModelState {
11 - NodeCreateOrEditViewModelFailure(this.error);
12 -
13 - final String error;
14 -}
lib/view_model/node_list/node_list_view_model.dart
+4 -4
@@ -1,12 +1,12 @@
1 import 'package:hive/hive.dart';
2 import 'package:mobx/mobx.dart';
3 import 'package:cake_wallet/core/wallet_base.dart';
4 -import 'package:cake_wallet/src/domain/common/node.dart';
5 -import 'package:cake_wallet/src/domain/common/node_list.dart';
4 +import 'package:cake_wallet/entities/node.dart';
5 +import 'package:cake_wallet/entities/node_list.dart';
6 import 'package:cake_wallet/store/node_list_store.dart';
7 import 'package:cake_wallet/store/settings_store.dart';
8 -import 'package:cake_wallet/src/domain/common/default_settings_migration.dart';
9 -import 'package:cake_wallet/src/domain/common/wallet_type.dart';
8 +import 'package:cake_wallet/entities/default_settings_migration.dart';
9 +import 'package:cake_wallet/entities/wallet_type.dart';
10 import 'package:cake_wallet/utils/mobx.dart';
11 import 'package:cake_wallet/utils/item_cell.dart';
12
lib/view_model/rescan_view_model.dart new
+25
@@ -0,0 +1,25 @@
1 +import 'package:cake_wallet/core/wallet_base.dart';
2 +import 'package:mobx/mobx.dart';
3 +
4 +part 'rescan_view_model.g.dart';
5 +
6 +class RescanViewModel = RescanViewModelBase with _$RescanViewModel;
7 +
8 +enum RescanWalletState { rescaning, none }
9 +
10 +abstract class RescanViewModelBase with Store {
11 + RescanViewModelBase(this._wallet) {
12 + state = RescanWalletState.none;
13 + }
14 +
15 + @observable
16 + RescanWalletState state;
17 + final WalletBase _wallet;
18 +
19 + @action
20 + Future<void> rescanCurrentWallet({int restoreHeight}) async {
21 + state = RescanWalletState.rescaning;
22 + await _wallet.rescan(height: restoreHeight);
23 + state = RescanWalletState.none;
24 + }
25 +}
\ No newline at end of file
lib/view_model/send/send_view_model.dart
+50 -25
@@ -1,23 +1,26 @@
1 import 'package:intl/intl.dart';
2 import 'package:mobx/mobx.dart';
3 import 'package:cake_wallet/core/template_validator.dart';
4 -import 'package:cake_wallet/src/domain/common/calculate_fiat_amount.dart';
5 -import 'package:cake_wallet/store/dashboard/fiat_convertation_store.dart';
4 import 'package:cake_wallet/core/address_validator.dart';
5 import 'package:cake_wallet/core/amount_validator.dart';
6 import 'package:cake_wallet/core/pending_transaction.dart';
7 import 'package:cake_wallet/core/validator.dart';
8 import 'package:cake_wallet/core/wallet_base.dart';
9 +import 'package:cake_wallet/core/execution_state.dart';
10 import 'package:cake_wallet/bitcoin/bitcoin_wallet.dart';
11 +import 'package:cake_wallet/bitcoin/bitcoin_transaction_credentials.dart';
12 import 'package:cake_wallet/monero/monero_wallet.dart';
13 -import 'package:cake_wallet/src/domain/common/sync_status.dart';
14 -import 'package:cake_wallet/src/domain/common/crypto_currency.dart';
15 -import 'package:cake_wallet/src/domain/common/fiat_currency.dart';
16 -import 'package:cake_wallet/src/domain/common/transaction_priority.dart';
13 +import 'package:cake_wallet/monero/monero_transaction_creation_credentials.dart';
14 +import 'package:cake_wallet/entities/sync_status.dart';
15 +import 'package:cake_wallet/entities/crypto_currency.dart';
16 +import 'package:cake_wallet/entities/fiat_currency.dart';
17 +import 'package:cake_wallet/entities/transaction_priority.dart';
18 +import 'package:cake_wallet/entities/calculate_fiat_amount.dart';
19 +import 'package:cake_wallet/entities/wallet_type.dart';
20 +import 'package:cake_wallet/store/dashboard/fiat_conversion_store.dart';
21 import 'package:cake_wallet/store/settings_store.dart';
22 import 'package:cake_wallet/view_model/send/send_view_model_state.dart';
19 -import 'package:cake_wallet/src/domain/common/wallet_type.dart';
20 -import 'package:cake_wallet/bitcoin/bitcoin_transaction_credentials.dart';
23 +import 'package:cake_wallet/generated/i18n.dart';
24
25 part 'send_view_model.g.dart';
26
@@ -26,13 +29,14 @@ class SendViewModel = SendViewModelBase with _$SendViewModel;
29 abstract class SendViewModelBase with Store {
30 SendViewModelBase(
31 this._wallet, this._settingsStore, this._fiatConversationStore)
29 - : state = InitialSendViewModelState(),
30 - _cryptoNumberFormat = NumberFormat()..maximumFractionDigits = 12,
31 - // FIXME: need to be based on wallet type.
32 - sendAll = false;
32 + : state = InitialExecutionState(),
33 + _cryptoNumberFormat = NumberFormat(),
34 + sendAll = false {
35 + _setCryptoNumMaximumFractionDigits();
36 + }
37
38 @observable
35 - SendViewModelState state;
39 + ExecutionState state;
40
41 @observable
42 String fiatAmount;
@@ -82,7 +86,7 @@ abstract class SendViewModelBase with Store {
86
87 final WalletBase _wallet;
88 final SettingsStore _settingsStore;
85 - final FiatConvertationStore _fiatConversationStore;
89 + final FiatConversionStore _fiatConversationStore;
90 final NumberFormat _cryptoNumberFormat;
91
92 @action
@@ -98,11 +102,11 @@ abstract class SendViewModelBase with Store {
102 @action
103 Future<void> createTransaction() async {
104 try {
101 - state = TransactionIsCreating();
105 + state = IsExecutingState();
106 pendingTransaction = await _wallet.createTransaction(_credentials());
103 - state = TransactionCreatedSuccessfully();
107 + state = ExecutedSuccessfullyState();
108 } catch (e) {
105 - state = SendingFailed(error: e.toString());
109 + state = FailureState(e.toString());
110 }
111 }
112
@@ -113,14 +117,13 @@ abstract class SendViewModelBase with Store {
117 await pendingTransaction.commit();
118 state = TransactionCommitted();
119 } catch (e) {
116 - state = SendingFailed(error: e.toString());
120 + state = FailureState(e.toString());
121 }
122 }
123
124 @action
125 void setCryptoAmount(String amount) {
122 - // FIXME: hardcoded value.
123 - if (amount.toUpperCase() != 'ALL') {
126 + if (amount.toUpperCase() != S.current.all) {
127 sendAll = false;
128 }
129
@@ -164,19 +167,41 @@ abstract class SendViewModelBase with Store {
167 }
168
169 Object _credentials() {
167 - final amount =
168 - !sendAll ? double.parse(cryptoAmount.replaceAll(',', '.')) : null;
170 + final _amount = cryptoAmount.replaceAll(',', '.');
171
172 switch (_wallet.type) {
173 case WalletType.bitcoin:
174 + final amount = !sendAll ? double.parse(_amount) : null;
175 +
176 return BitcoinTransactionCredentials(
177 address, amount, _settingsStore.transactionPriority);
178 case WalletType.monero:
175 - // FIXME: Wrong credentials
176 - return BitcoinTransactionCredentials(
177 - address, amount, _settingsStore.transactionPriority);
179 + final amount = !sendAll ? _amount : null;
180 +
181 + return MoneroTransactionCreationCredentials(
182 + address: address,
183 + paymentId: '',
184 + priority: _settingsStore.transactionPriority,
185 + amount: amount);
186 default:
187 return null;
188 }
189 }
190 +
191 + void _setCryptoNumMaximumFractionDigits() {
192 + var maximumFractionDigits = 0;
193 +
194 + switch (_wallet.type) {
195 + case WalletType.monero:
196 + maximumFractionDigits = 12;
197 + break;
198 + case WalletType.bitcoin:
199 + maximumFractionDigits = 8;
200 + break;
201 + default:
202 + break;
203 + }
204 +
205 + _cryptoNumberFormat.maximumFractionDigits = maximumFractionDigits;
206 + }
207 }
lib/view_model/send/send_view_model_state.dart
+3 -17
@@ -1,18 +1,4 @@
1 -import 'package:flutter/foundation.dart';
1 +import 'package:cake_wallet/core/execution_state.dart';
2
3 -abstract class SendViewModelState {}
4 -
5 -class InitialSendViewModelState extends SendViewModelState {}
6 -
7 -class TransactionIsCreating extends SendViewModelState {}
8 -class TransactionCreatedSuccessfully extends SendViewModelState {}
9 -
10 -class TransactionCommitting extends SendViewModelState {}
11 -
12 -class TransactionCommitted extends SendViewModelState {}
13 -
14 -class SendingFailed extends SendViewModelState {
15 - SendingFailed({@required this.error});
16 -
17 - String error;
18 -}
\ No newline at end of file
3 +class TransactionCommitting extends ExecutionState {}
4 +class TransactionCommitted extends ExecutionState {}
lib/view_model/send_view_model.dart deleted
-216
@@ -1,216 +0,0 @@
1 -import 'package:flutter/foundation.dart';
2 -import 'package:intl/intl.dart';
3 -import 'package:mobx/mobx.dart';
4 -import 'package:cake_wallet/core/address_validator.dart';
5 -import 'package:cake_wallet/core/amount_validator.dart';
6 -import 'package:cake_wallet/core/template_validator.dart';
7 -import 'package:cake_wallet/core/validator.dart';
8 -import 'package:cake_wallet/core/wallet_base.dart';
9 -import 'package:cake_wallet/bitcoin/bitcoin_wallet.dart';
10 -import 'package:cake_wallet/monero/monero_wallet.dart';
11 -import 'package:cake_wallet/src/domain/common/balance_display_mode.dart';
12 -import 'package:cake_wallet/src/domain/common/calculate_estimated_fee.dart';
13 -import 'package:cake_wallet/src/domain/common/crypto_currency.dart';
14 -import 'package:cake_wallet/src/domain/common/fiat_currency.dart';
15 -import 'package:cake_wallet/src/domain/common/sync_status.dart';
16 -import 'package:cake_wallet/src/domain/common/transaction_priority.dart';
17 -import 'package:cake_wallet/store/settings_store.dart';
18 -import 'package:cake_wallet/store/templates/send_template_store.dart';
19 -import 'package:cake_wallet/generated/i18n.dart';
20 -import 'package:cake_wallet/src/domain/common/openalias_record.dart';
21 -import 'package:cake_wallet/store/dashboard/fiat_convertation_store.dart';
22 -import 'package:cake_wallet/src/domain/common/template.dart';
23 -
24 -part 'send_view_model.g.dart';
25 -
26 -abstract class SendViewModelState {}
27 -
28 -class InitialSendViewModelState extends SendViewModelState {}
29 -
30 -class TransactionIsCreating extends SendViewModelState {}
31 -
32 -class TransactionCreatedSuccessfully extends SendViewModelState {}
33 -
34 -class TransactionCommitting extends SendViewModelState {}
35 -
36 -class TransactionCommitted extends SendViewModelState {}
37 -
38 -class SendingFailed extends SendViewModelState {
39 - SendingFailed({@required this.error});
40 -
41 - String error;
42 -}
43 -
44 -class SendViewModel = SendViewModelBase with _$SendViewModel;
45 -
46 -abstract class SendViewModelBase with Store {
47 - SendViewModelBase(this._wallet, this._settingsStore,
48 - this._fiatConvertationStore, this.sendTemplateStore) {
49 - state = InitialSendViewModelState();
50 -
51 - _cryptoNumberFormat = NumberFormat()..maximumFractionDigits = 12;
52 - _fiatNumberFormat = NumberFormat()..maximumFractionDigits = 2;
53 - }
54 -
55 - NumberFormat _cryptoNumberFormat;
56 - NumberFormat _fiatNumberFormat;
57 -
58 - @observable
59 - SendViewModelState state;
60 -
61 - @observable
62 - String fiatAmount;
63 -
64 - @observable
65 - String cryptoAmount;
66 -
67 - @observable
68 - String address;
69 -
70 - String get cryptoCurrencyTitle {
71 - var _currencyTitle = '';
72 -
73 - if (_wallet is MoneroWallet) {
74 - _currencyTitle = 'Monero';
75 - }
76 -
77 - if (_wallet is BitcoinWallet) {
78 - _currencyTitle = 'Bitcoin';
79 - }
80 -
81 - return _currencyTitle;
82 - }
83 -
84 - String get pageTitle => S.current.send_title + ' ' + cryptoCurrencyTitle;
85 -
86 - FiatCurrency get fiat => _settingsStore.fiatCurrency;
87 -
88 - TransactionPriority get transactionPriority =>
89 - _settingsStore.transactionPriority;
90 -
91 - double get estimatedFee =>
92 - calculateEstimatedFee(priority: transactionPriority);
93 -
94 - String get name => _wallet.name;
95 -
96 - CryptoCurrency get currency => _wallet.currency;
97 -
98 - Validator get amountValidator => AmountValidator(type: _wallet.type);
99 -
100 - Validator get addressValidator => AddressValidator(type: _wallet.currency);
101 -
102 - Validator get templateValidator => TemplateValidator();
103 -
104 - @computed
105 - double get price => _fiatConvertationStore.price;
106 -
107 - @computed
108 - ObservableList<Template> get templates =>
109 - ObservableList.of(sendTemplateStore.templates
110 - .where((item) => item.cryptoCurrency == _wallet.currency.title)
111 - .toList());
112 -
113 - @computed
114 - String get balance {
115 - var _balance = '0.0';
116 -
117 - if (_wallet is MoneroWallet) {
118 - _balance = _wallet.balance.formattedUnlockedBalance.toString();
119 - }
120 -
121 - if (_wallet is BitcoinWallet) {
122 - _balance = _wallet.balance.confirmedFormatted.toString();
123 - }
124 -
125 - return _settingsStore.balanceDisplayMode == BalanceDisplayMode.hiddenBalance
126 - ? '---'
127 - : _balance;
128 - }
129 -
130 - @computed
131 - SyncStatus get status => _wallet.syncStatus;
132 -
133 - @action
134 - void changeCryptoAmount(String amount) {
135 - cryptoAmount = amount;
136 -
137 - if (cryptoAmount != null && cryptoAmount.isNotEmpty) {
138 - _calculateFiatAmount();
139 - } else {
140 - fiatAmount = '';
141 - }
142 - }
143 -
144 - @action
145 - void changeFiatAmount(String amount) {
146 - fiatAmount = amount;
147 -
148 - if (fiatAmount != null && fiatAmount.isNotEmpty) {
149 - _calculateCryptoAmount();
150 - } else {
151 - cryptoAmount = '';
152 - }
153 - }
154 -
155 - @action
156 - Future _calculateFiatAmount() async {
157 - try {
158 - final amount = double.parse(cryptoAmount) * price;
159 - fiatAmount = _fiatNumberFormat.format(amount);
160 - } catch (e) {
161 - fiatAmount = '0.00';
162 - }
163 - }
164 -
165 - @action
166 - Future _calculateCryptoAmount() async {
167 - try {
168 - final amount = double.parse(fiatAmount) / price;
169 - cryptoAmount = _cryptoNumberFormat.format(amount);
170 - } catch (e) {
171 - cryptoAmount = '0.00';
172 - }
173 - }
174 -
175 - @action
176 - void changeAddress(String address) {
177 - this.address = address;
178 - }
179 -
180 - @action
181 - void setSendAll() {
182 - cryptoAmount = 'ALL';
183 - fiatAmount = '';
184 - }
185 -
186 - @action
187 - void setTransactionPriority(TransactionPriority transactionPriority) {
188 - _settingsStore.transactionPriority = transactionPriority;
189 - }
190 -
191 - final WalletBase _wallet;
192 -
193 - final SettingsStore _settingsStore;
194 -
195 - final FiatConvertationStore _fiatConvertationStore;
196 -
197 - final SendTemplateStore sendTemplateStore;
198 -
199 - String recordName;
200 -
201 - String recordAddress;
202 -
203 - Future<bool> isOpenaliasRecord(String name) async {
204 - final _openaliasRecord = await OpenaliasRecord.fetchAddressAndName(
205 - OpenaliasRecord.formatDomainName(name));
206 -
207 - recordAddress = _openaliasRecord.address;
208 - recordName = _openaliasRecord.name;
209 -
210 - return recordAddress != name;
211 - }
212 -
213 - Future<void> createTransaction() async {}
214 -
215 - Future<void> commitTransaction() async {}
216 -}
lib/view_model/settings/settings_view_model.dart
+7 -7
@@ -1,6 +1,6 @@
1 import 'package:cake_wallet/core/wallet_base.dart';
2 -import 'package:cake_wallet/src/domain/common/biometric_auth.dart';
3 -import 'package:cake_wallet/src/domain/common/wallet_type.dart';
2 +import 'package:cake_wallet/entities/biometric_auth.dart';
3 +import 'package:cake_wallet/entities/wallet_type.dart';
4 import 'package:cake_wallet/di.dart';
5 import 'package:cake_wallet/store/theme_changer_store.dart';
6 import 'package:cake_wallet/themes.dart';
@@ -10,11 +10,11 @@ import 'package:mobx/mobx.dart';
10 import 'package:cake_wallet/routes.dart';
11 import 'package:cake_wallet/generated/i18n.dart';
12 import 'package:cake_wallet/store/settings_store.dart';
13 -import 'package:cake_wallet/src/domain/common/balance_display_mode.dart';
14 -import 'package:cake_wallet/src/domain/common/fiat_currency.dart';
15 -import 'package:cake_wallet/src/domain/common/node.dart';
16 -import 'package:cake_wallet/src/domain/common/transaction_priority.dart';
17 -import 'package:cake_wallet/src/stores/action_list/action_list_display_mode.dart';
13 +import 'package:cake_wallet/entities/balance_display_mode.dart';
14 +import 'package:cake_wallet/entities/fiat_currency.dart';
15 +import 'package:cake_wallet/entities/node.dart';
16 +import 'package:cake_wallet/entities/transaction_priority.dart';
17 +import 'package:cake_wallet/entities/action_list_display_mode.dart';
18 import 'package:cake_wallet/src/screens/auth/auth_page.dart';
19 import 'package:cake_wallet/view_model/settings/link_list_item.dart';
20 import 'package:cake_wallet/view_model/settings/picker_list_item.dart';
lib/view_model/setup_pin_code_view_model.dart new
+70
@@ -0,0 +1,70 @@
1 +import 'package:cake_wallet/core/auth_service.dart';
2 +import 'package:cake_wallet/store/settings_store.dart';
3 +
4 +class SetupPinCodeViewModel {
5 + SetupPinCodeViewModel(this._authService, this._settingsStore)
6 + : _pinCodeLength = _settingsStore.pinCodeLength;
7 +
8 + String originalPinCode = '';
9 +
10 + String repeatedPinCode = '';
11 +
12 + set pinCode(String pinCode) {
13 + if (!isOriginalPinCodeFull) {
14 + setOriginalPinCode(pinCode);
15 + return;
16 + }
17 +
18 + repeatedPinCode = pinCode;
19 + }
20 +
21 + int get pinCodeLength => _pinCodeLength;
22 +
23 + set pinCodeLength(int length) {
24 + _pinCodeLength = length;
25 + reset();
26 + }
27 +
28 + bool get isOriginalPinCodeFull => originalPinCode.length == pinCodeLength;
29 +
30 + bool get isRepeatedPinCodeFull => repeatedPinCode.length == pinCodeLength;
31 +
32 + bool get isPinCodeCorrect =>
33 + originalPinCode.length == pinCodeLength &&
34 + repeatedPinCode.length == pinCodeLength &&
35 + originalPinCode == repeatedPinCode;
36 +
37 + final SettingsStore _settingsStore;
38 + final AuthService _authService;
39 + int _pinCodeLength;
40 +
41 + void setOriginalPinCode(String pinCode) {
42 + if (isOriginalPinCodeFull) {
43 + return;
44 + }
45 +
46 + originalPinCode = pinCode;
47 + }
48 +
49 + void setRepeatedPinCode(String pinCode) {
50 + if (isRepeatedPinCodeFull) {
51 + return;
52 + }
53 +
54 + repeatedPinCode = pinCode;
55 + }
56 +
57 + void reset() {
58 + originalPinCode = '';
59 + repeatedPinCode = '';
60 + }
61 +
62 + Future<void> setupPinCode() async {
63 + if (!isPinCodeCorrect) {
64 + return;
65 + }
66 +
67 + await _authService.setPassword(repeatedPinCode);
68 + _settingsStore.pinCodeLength = pinCodeLength;
69 + }
70 +}
lib/view_model/wallet_address_list/wallet_address_list_view_model.dart
+1 -1
@@ -7,7 +7,7 @@ import 'package:cake_wallet/utils/list_item.dart';
7 import 'package:cake_wallet/view_model/wallet_address_list/wallet_account_list_header.dart';
8 import 'package:cake_wallet/view_model/wallet_address_list/wallet_address_list_header.dart';
9 import 'package:cake_wallet/view_model/wallet_address_list/wallet_address_list_item.dart';
10 -import 'package:cake_wallet/src/domain/common/wallet_type.dart';
10 +import 'package:cake_wallet/entities/wallet_type.dart';
11
12 part 'wallet_address_list_view_model.g.dart';
13
lib/view_model/wallet_creation_state.dart deleted
-15
@@ -1,15 +0,0 @@
1 -import 'package:flutter/foundation.dart';
2 -
3 -abstract class WalletCreationState {}
4 -
5 -class InitialWalletCreationState extends WalletCreationState {}
6 -
7 -class WalletCreating extends WalletCreationState {}
8 -
9 -class WalletCreatedSuccessfully extends WalletCreationState {}
10 -
11 -class WalletCreationFailure extends WalletCreationState {
12 - WalletCreationFailure({@required this.error});
13 -
14 - final String error;
15 -}
lib/view_model/wallet_creation_vm.dart
+22 -15
@@ -1,20 +1,22 @@
1 -import 'package:cake_wallet/core/wallet_base.dart';
2 -import 'package:cake_wallet/src/domain/common/wallet_info.dart';
1 import 'package:flutter/foundation.dart';
2 import 'package:hive/hive.dart';
3 import 'package:mobx/mobx.dart';
4 +import 'package:cake_wallet/core/execution_state.dart';
5 +import 'package:cake_wallet/core/wallet_base.dart';
6 import 'package:cake_wallet/core/wallet_credentials.dart';
7 -import 'package:cake_wallet/src/domain/common/wallet_type.dart';
8 -import 'package:cake_wallet/view_model/wallet_creation_state.dart';
7 +import 'package:cake_wallet/entities/pathForWallet.dart';
8 +import 'package:cake_wallet/entities/wallet_info.dart';
9 +import 'package:cake_wallet/entities/wallet_type.dart';
10 +import 'package:cake_wallet/store/app_store.dart';
11
12 part 'wallet_creation_vm.g.dart';
13
14 class WalletCreationVM = WalletCreationVMBase with _$WalletCreationVM;
15
16 abstract class WalletCreationVMBase with Store {
15 - WalletCreationVMBase(this._walletInfoSource,
17 + WalletCreationVMBase(this._appStore, this._walletInfoSource,
18 {@required this.type, @required this.isRecovery}) {
17 - state = InitialWalletCreationState();
19 + state = InitialExecutionState();
20 name = '';
21 }
22
@@ -22,17 +24,18 @@ abstract class WalletCreationVMBase with Store {
24 String name;
25
26 @observable
25 - WalletCreationState state;
27 + ExecutionState state;
28
29 final WalletType type;
28 -
30 final bool isRecovery;
30 -
31 final Box<WalletInfo> _walletInfoSource;
32 + final AppStore _appStore;
33
34 Future<void> create({dynamic options}) async {
35 try {
35 - state = WalletCreating();
36 + state = IsExecutingState();
37 + final dirPath = await pathForWalletDir(name: name, type: type);
38 + final path = await pathForWallet(name: name, type: type);
39 final credentials = getCredentials(options);
40 final walletInfo = WalletInfo.external(
41 id: WalletBase.idFor(name, type),
@@ -40,19 +43,23 @@ abstract class WalletCreationVMBase with Store {
43 type: type,
44 isRecovery: isRecovery,
45 restoreHeight: credentials.height ?? 0,
43 - date: DateTime.now());
46 + date: DateTime.now(),
47 + path: path,
48 + dirPath: dirPath);
49 credentials.walletInfo = walletInfo;
45 - await process(credentials);
50 + final wallet = await process(credentials);
51 await _walletInfoSource.add(walletInfo);
47 - state = WalletCreatedSuccessfully();
52 + _appStore.wallet = wallet;
53 + _appStore.authenticationStore.allowed();
54 + state = ExecutedSuccessfullyState();
55 } catch (e) {
49 - state = WalletCreationFailure(error: e.toString());
56 + state = FailureState(e.toString());
57 }
58 }
59
60 WalletCredentials getCredentials(dynamic options) =>
61 throw UnimplementedError();
62
56 - Future<void> process(WalletCredentials credentials) =>
63 + Future<WalletBase> process(WalletCredentials credentials) =>
64 throw UnimplementedError();
65 }
lib/view_model/wallet_list/wallet_list_item.dart
+1 -1
@@ -1,5 +1,5 @@
1 import 'package:flutter/foundation.dart';
2 -import 'package:cake_wallet/src/domain/common/wallet_type.dart';
2 +import 'package:cake_wallet/entities/wallet_type.dart';
3
4 class WalletListItem {
5 const WalletListItem(
lib/view_model/wallet_list/wallet_list_view_model.dart
+1 -1
@@ -5,7 +5,7 @@ import 'package:cake_wallet/store/app_store.dart';
5 import 'package:cake_wallet/core/key_service.dart';
6 import 'package:cake_wallet/core/wallet_service.dart';
7 import 'package:cake_wallet/view_model/wallet_list/wallet_list_item.dart';
8 -import 'package:cake_wallet/src/domain/common/wallet_info.dart';
8 +import 'package:cake_wallet/entities/wallet_info.dart';
9
10 part 'wallet_list_view_model.g.dart';
11
lib/view_model/wallet_new_vm.dart
+9 -5
@@ -3,10 +3,12 @@ import 'package:hive/hive.dart';
3 import 'package:mobx/mobx.dart';
4 import 'package:cake_wallet/monero/monero_wallet_service.dart';
5 import 'package:cake_wallet/bitcoin/bitcoin_wallet_creation_credentials.dart';
6 +import 'package:cake_wallet/store/app_store.dart';
7 +import 'package:cake_wallet/core/wallet_base.dart';
8 import 'package:cake_wallet/core/wallet_creation_service.dart';
9 import 'package:cake_wallet/core/wallet_credentials.dart';
8 -import 'package:cake_wallet/src/domain/common/wallet_info.dart';
9 -import 'package:cake_wallet/src/domain/common/wallet_type.dart';
10 +import 'package:cake_wallet/entities/wallet_info.dart';
11 +import 'package:cake_wallet/entities/wallet_type.dart';
12 import 'package:cake_wallet/view_model/wallet_creation_vm.dart';
13
14 part 'wallet_new_vm.g.dart';
@@ -14,9 +16,11 @@ part 'wallet_new_vm.g.dart';
16 class WalletNewVM = WalletNewVMBase with _$WalletNewVM;
17
18 abstract class WalletNewVMBase extends WalletCreationVM with Store {
17 - WalletNewVMBase(this._walletCreationService, Box<WalletInfo> walletInfoSource, {@required WalletType type})
19 + WalletNewVMBase(AppStore appStore, this._walletCreationService,
20 + Box<WalletInfo> walletInfoSource,
21 + {@required WalletType type})
22 : selectedMnemonicLanguage = '',
19 - super(walletInfoSource, type: type, isRecovery: false);
23 + super(appStore, walletInfoSource, type: type, isRecovery: false);
24
25 @observable
26 String selectedMnemonicLanguage;
@@ -39,6 +43,6 @@ abstract class WalletNewVMBase extends WalletCreationVM with Store {
43 }
44
45 @override
42 - Future<void> process(WalletCredentials credentials) async =>
46 + Future<WalletBase> process(WalletCredentials credentials) async =>
47 _walletCreationService.create(credentials);
48 }
lib/view_model/wallet_restoration_from_keys_vm.dart
+16 -8
@@ -3,12 +3,14 @@ import 'package:hive/hive.dart';
3 import 'package:mobx/mobx.dart';
4 import 'package:cake_wallet/monero/monero_wallet_service.dart';
5 import 'package:cake_wallet/bitcoin/bitcoin_wallet_creation_credentials.dart';
6 +import 'package:cake_wallet/store/app_store.dart';
7 +import 'package:cake_wallet/core/wallet_base.dart';
8 import 'package:cake_wallet/core/generate_wallet_password.dart';
9 import 'package:cake_wallet/core/wallet_creation_service.dart';
10 import 'package:cake_wallet/core/wallet_credentials.dart';
9 -import 'package:cake_wallet/src/domain/common/wallet_type.dart';
11 +import 'package:cake_wallet/entities/wallet_type.dart';
12 import 'package:cake_wallet/view_model/wallet_creation_vm.dart';
11 -import 'package:cake_wallet/src/domain/common/wallet_info.dart';
13 +import 'package:cake_wallet/entities/wallet_info.dart';
14
15 part 'wallet_restoration_from_keys_vm.g.dart';
16
@@ -17,9 +19,10 @@ class WalletRestorationFromKeysVM = WalletRestorationFromKeysVMBase
19
20 abstract class WalletRestorationFromKeysVMBase extends WalletCreationVM
21 with Store {
20 - WalletRestorationFromKeysVMBase(this._walletCreationService, Box<WalletInfo> walletInfoSource,
22 + WalletRestorationFromKeysVMBase(AppStore appStore,
23 + this._walletCreationService, Box<WalletInfo> walletInfoSource,
24 {@required WalletType type, @required this.language})
22 - : super(walletInfoSource, type: type, isRecovery: true);
25 + : super(appStore, walletInfoSource, type: type, isRecovery: true);
26
27 @observable
28 int height;
@@ -48,17 +51,22 @@ abstract class WalletRestorationFromKeysVMBase extends WalletCreationVM
51 switch (type) {
52 case WalletType.monero:
53 return MoneroRestoreWalletFromKeysCredentials(
51 - name: name, password: password, language: language, address: address,
52 - viewKey: viewKey, spendKey: spendKey, height: height);
54 + name: name,
55 + password: password,
56 + language: language,
57 + address: address,
58 + viewKey: viewKey,
59 + spendKey: spendKey,
60 + height: height);
61 case WalletType.bitcoin:
62 return BitcoinRestoreWalletFromWIFCredentials(
55 - name: name, password: password, wif: wif);
63 + name: name, password: password, wif: wif);
64 default:
65 return null;
66 }
67 }
68
69 @override
62 - Future<void> process(WalletCredentials credentials) async =>
70 + Future<WalletBase> process(WalletCredentials credentials) async =>
71 _walletCreationService.restoreFromKeys(credentials);
72 }
lib/view_model/wallet_restoration_from_seed_vm.dart
+8 -5
@@ -2,13 +2,15 @@ import 'package:flutter/foundation.dart';
2 import 'package:hive/hive.dart';
3 import 'package:mobx/mobx.dart';
4 import 'package:cake_wallet/monero/monero_wallet_service.dart';
5 +import 'package:cake_wallet/store/app_store.dart';
6 import 'package:cake_wallet/bitcoin/bitcoin_wallet_creation_credentials.dart';
7 +import 'package:cake_wallet/core/wallet_base.dart';
8 import 'package:cake_wallet/core/generate_wallet_password.dart';
9 import 'package:cake_wallet/core/wallet_creation_service.dart';
10 import 'package:cake_wallet/core/wallet_credentials.dart';
9 -import 'package:cake_wallet/src/domain/common/wallet_type.dart';
11 +import 'package:cake_wallet/entities/wallet_type.dart';
12 import 'package:cake_wallet/view_model/wallet_creation_vm.dart';
11 -import 'package:cake_wallet/src/domain/common/wallet_info.dart';
13 +import 'package:cake_wallet/entities/wallet_info.dart';
14
15 part 'wallet_restoration_from_seed_vm.g.dart';
16
@@ -17,9 +19,10 @@ class WalletRestorationFromSeedVM = WalletRestorationFromSeedVMBase
19
20 abstract class WalletRestorationFromSeedVMBase extends WalletCreationVM
21 with Store {
20 - WalletRestorationFromSeedVMBase(this._walletCreationService, Box<WalletInfo> walletInfoSource,
22 + WalletRestorationFromSeedVMBase(AppStore appStore,
23 + this._walletCreationService, Box<WalletInfo> walletInfoSource,
24 {@required WalletType type, @required this.language, this.seed})
22 - : super(walletInfoSource, type: type, isRecovery: true);
25 + : super(appStore, walletInfoSource, type: type, isRecovery: true);
26
27 @observable
28 String seed;
@@ -49,6 +52,6 @@ abstract class WalletRestorationFromSeedVMBase extends WalletCreationVM
52 }
53
54 @override
52 - Future<void> process(WalletCredentials credentials) async =>
55 + Future<WalletBase> process(WalletCredentials credentials) async =>
56 _walletCreationService.restoreFromSeed(credentials);
57 }
pubspec.lock
+39 -18
@@ -9,7 +9,7 @@ packages:
9 source: hosted
10 version: "6.0.0"
11 analyzer:
12 - dependency: "direct overridden"
12 + dependency: transitive
13 description:
14 name: analyzer
15 url: "https://pub.dartlang.org"
@@ -231,7 +231,7 @@ packages:
231 name: connectivity_macos
232 url: "https://pub.dartlang.org"
233 source: hosted
234 - version: "0.1.0+4"
234 + version: "0.1.0+5"
235 connectivity_platform_interface:
236 dependency: transitive
237 description:
@@ -252,7 +252,7 @@ packages:
252 name: crypto
253 url: "https://pub.dartlang.org"
254 source: hosted
255 - version: "2.1.4"
255 + version: "2.1.5"
256 csslib:
257 dependency: transitive
258 description:
@@ -280,7 +280,7 @@ packages:
280 name: dart_style
281 url: "https://pub.dartlang.org"
282 source: hosted
283 - version: "1.2.9"
283 + version: "1.3.6"
284 dartx:
285 dependency: "direct overridden"
286 description:
@@ -322,7 +322,7 @@ packages:
322 name: encrypt
323 url: "https://pub.dartlang.org"
324 source: hosted
325 - version: "4.0.2"
325 + version: "4.0.3"
326 esys_flutter_share:
327 dependency: "direct main"
328 description:
@@ -395,14 +395,14 @@ packages:
395 name: flutter_plugin_android_lifecycle
396 url: "https://pub.dartlang.org"
397 source: hosted
398 - version: "1.0.8"
398 + version: "1.0.9"
399 flutter_secure_storage:
400 dependency: "direct main"
401 description:
402 name: flutter_secure_storage
403 url: "https://pub.dartlang.org"
404 source: hosted
405 - version: "3.3.3"
405 + version: "3.3.4"
406 flutter_slidable:
407 dependency: "direct main"
408 description:
@@ -503,7 +503,7 @@ packages:
503 name: image
504 url: "https://pub.dartlang.org"
505 source: hosted
506 - version: "2.1.12"
506 + version: "2.1.17"
507 intl:
508 dependency: "direct main"
509 description:
@@ -643,7 +643,7 @@ packages:
643 name: path_provider
644 url: "https://pub.dartlang.org"
645 source: hosted
646 - version: "1.6.14"
646 + version: "1.6.16"
647 path_provider_linux:
648 dependency: transitive
649 description:
@@ -657,7 +657,7 @@ packages:
657 name: path_provider_macos
658 url: "https://pub.dartlang.org"
659 source: hosted
660 - version: "0.0.4+3"
660 + version: "0.0.4+4"
661 path_provider_platform_interface:
662 dependency: transitive
663 description:
@@ -665,6 +665,13 @@ packages:
665 url: "https://pub.dartlang.org"
666 source: hosted
667 version: "1.0.3"
668 + path_provider_windows:
669 + dependency: transitive
670 + description:
671 + name: path_provider_windows
672 + url: "https://pub.dartlang.org"
673 + source: hosted
674 + version: "0.0.3"
675 pedantic:
676 dependency: "direct dev"
677 description:
@@ -678,7 +685,7 @@ packages:
685 name: petitparser
686 url: "https://pub.dartlang.org"
687 source: hosted
681 - version: "2.4.0"
688 + version: "3.0.4"
689 platform:
690 dependency: transitive
691 description:
@@ -776,7 +783,7 @@ packages:
783 name: share
784 url: "https://pub.dartlang.org"
785 source: hosted
779 - version: "0.6.5"
786 + version: "0.6.5+1"
787 shared_preferences:
788 dependency: "direct main"
789 description:
@@ -844,7 +851,7 @@ packages:
851 name: source_gen
852 url: "https://pub.dartlang.org"
853 source: hosted
847 - version: "0.9.4+4"
854 + version: "0.9.6"
855 source_span:
856 dependency: transitive
857 description:
@@ -921,7 +928,7 @@ packages:
928 name: url_launcher
929 url: "https://pub.dartlang.org"
930 source: hosted
924 - version: "5.5.1"
931 + version: "5.6.0"
932 url_launcher_linux:
933 dependency: transitive
934 description:
@@ -935,7 +942,7 @@ packages:
942 name: url_launcher_macos
943 url: "https://pub.dartlang.org"
944 source: hosted
938 - version: "0.0.1+7"
945 + version: "0.0.1+8"
946 url_launcher_platform_interface:
947 dependency: transitive
948 description:
@@ -949,7 +956,14 @@ packages:
956 name: url_launcher_web
957 url: "https://pub.dartlang.org"
958 source: hosted
952 - version: "0.1.3"
959 + version: "0.1.3+2"
960 + url_launcher_windows:
961 + dependency: transitive
962 + description:
963 + name: url_launcher_windows
964 + url: "https://pub.dartlang.org"
965 + source: hosted
966 + version: "0.0.1+1"
967 uuid:
968 dependency: "direct main"
969 description:
@@ -978,6 +992,13 @@ packages:
992 url: "https://pub.dartlang.org"
993 source: hosted
994 version: "1.1.0"
995 + win32:
996 + dependency: transitive
997 + description:
998 + name: win32
999 + url: "https://pub.dartlang.org"
1000 + source: hosted
1001 + version: "1.7.3"
1002 xdg_directories:
1003 dependency: transitive
1004 description:
@@ -991,7 +1012,7 @@ packages:
1012 name: xml
1013 url: "https://pub.dartlang.org"
1014 source: hosted
994 - version: "3.6.1"
1015 + version: "4.5.1"
1016 yaml:
1017 dependency: "direct main"
1018 description:
@@ -1001,4 +1022,4 @@ packages:
1022 version: "2.2.1"
1023 sdks:
1024 dart: ">=2.9.0-14.0.dev <3.0.0"
1004 - flutter: ">=1.12.13+hotfix.5 <2.0.0"
1025 + flutter: ">=1.20.0 <2.0.0"
pubspec.yaml
+1 -2
@@ -75,7 +75,6 @@ dev_dependencies:
75 # Fix for hive https://github.com/hivedb/hive/issues/247#issuecomment-606838497
76 dependency_overrides:
77 dartx: ^0.5.0
78 - analyzer: 0.39.14
78
79 flutter_icons:
80 image_path: "assets/images/app_logo.png"
@@ -148,4 +147,4 @@ flutter:
147 # weight: 700
148 #
149 # For details regarding fonts from package dependencies,
151 - # see https://flutter.dev/custom-fonts/#from-packages
150 + # see https://flutter.dev/custom-fonts/#from-packages
\ No newline at end of file