mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2024-12-22 11:39:22 +00:00
Part 1
This commit is contained in:
parent
5e1132a299
commit
e4ebfc94b2
273 changed files with 2472 additions and 7285 deletions
|
@ -1 +1 @@
|
|||
a2dce69f54a78f5b00e19850e4b2d402
|
||||
bc336703210c48e30d7216fac3fe1c0f
|
|
@ -47,6 +47,8 @@ PODS:
|
|||
- Flutter
|
||||
- path_provider_macos (0.0.1):
|
||||
- Flutter
|
||||
- path_provider_windows (0.0.1):
|
||||
- Flutter
|
||||
- Reachability (3.2)
|
||||
- share (0.0.1):
|
||||
- Flutter
|
||||
|
@ -67,6 +69,8 @@ PODS:
|
|||
- Flutter
|
||||
- url_launcher_web (0.0.1):
|
||||
- Flutter
|
||||
- url_launcher_windows (0.0.1):
|
||||
- Flutter
|
||||
|
||||
DEPENDENCIES:
|
||||
- barcode_scan (from `.symlinks/plugins/barcode_scan/ios`)
|
||||
|
@ -84,6 +88,7 @@ DEPENDENCIES:
|
|||
- path_provider (from `.symlinks/plugins/path_provider/ios`)
|
||||
- path_provider_linux (from `.symlinks/plugins/path_provider_linux/ios`)
|
||||
- path_provider_macos (from `.symlinks/plugins/path_provider_macos/ios`)
|
||||
- path_provider_windows (from `.symlinks/plugins/path_provider_windows/ios`)
|
||||
- share (from `.symlinks/plugins/share/ios`)
|
||||
- shared_preferences (from `.symlinks/plugins/shared_preferences/ios`)
|
||||
- shared_preferences_linux (from `.symlinks/plugins/shared_preferences_linux/ios`)
|
||||
|
@ -93,6 +98,7 @@ DEPENDENCIES:
|
|||
- url_launcher_linux (from `.symlinks/plugins/url_launcher_linux/ios`)
|
||||
- url_launcher_macos (from `.symlinks/plugins/url_launcher_macos/ios`)
|
||||
- url_launcher_web (from `.symlinks/plugins/url_launcher_web/ios`)
|
||||
- url_launcher_windows (from `.symlinks/plugins/url_launcher_windows/ios`)
|
||||
|
||||
SPEC REPOS:
|
||||
trunk:
|
||||
|
@ -131,6 +137,8 @@ EXTERNAL SOURCES:
|
|||
:path: ".symlinks/plugins/path_provider_linux/ios"
|
||||
path_provider_macos:
|
||||
:path: ".symlinks/plugins/path_provider_macos/ios"
|
||||
path_provider_windows:
|
||||
:path: ".symlinks/plugins/path_provider_windows/ios"
|
||||
share:
|
||||
:path: ".symlinks/plugins/share/ios"
|
||||
shared_preferences:
|
||||
|
@ -149,6 +157,8 @@ EXTERNAL SOURCES:
|
|||
:path: ".symlinks/plugins/url_launcher_macos/ios"
|
||||
url_launcher_web:
|
||||
:path: ".symlinks/plugins/url_launcher_web/ios"
|
||||
url_launcher_windows:
|
||||
:path: ".symlinks/plugins/url_launcher_windows/ios"
|
||||
|
||||
SPEC CHECKSUMS:
|
||||
barcode_scan: a5c27959edfafaa0c771905bad0b29d6d39e4479
|
||||
|
@ -167,6 +177,7 @@ SPEC CHECKSUMS:
|
|||
path_provider: abfe2b5c733d04e238b0d8691db0cfd63a27a93c
|
||||
path_provider_linux: 4d630dc393e1f20364f3e3b4a2ff41d9674a84e4
|
||||
path_provider_macos: f760a3c5b04357c380e2fddb6f9db6f3015897e0
|
||||
path_provider_windows: a2b81600c677ac1959367280991971cb9a1edb3b
|
||||
Reachability: 33e18b67625424e47b6cde6d202dce689ad7af96
|
||||
share: 0b2c3e82132f5888bccca3351c504d0003b3b410
|
||||
shared_preferences: af6bfa751691cdc24be3045c43ec037377ada40d
|
||||
|
@ -178,6 +189,7 @@ SPEC CHECKSUMS:
|
|||
url_launcher_linux: ac237cb7a8058736e4aae38bdbcc748a4b394cc0
|
||||
url_launcher_macos: fd7894421cd39320dce5f292fc99ea9270b2a313
|
||||
url_launcher_web: e5527357f037c87560776e36436bf2b0288b965c
|
||||
url_launcher_windows: 683d7c283894db8d1914d3ab2223b20cc1ad95d5
|
||||
|
||||
PODFILE CHECKSUM: c34e2287a9ccaa606aeceab922830efb9a6ff69a
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import 'package:intl/intl.dart';
|
||||
import 'package:cake_wallet/src/domain/common/crypto_amount_format.dart';
|
||||
import 'package:cake_wallet/entities/crypto_amount_format.dart';
|
||||
|
||||
const bitcoinAmountLength = 8;
|
||||
const bitcoinAmountDivider = 100000000;
|
||||
|
@ -11,3 +11,6 @@ String bitcoinAmountToString({int amount}) =>
|
|||
bitcoinAmountFormat.format(cryptoAmountToDouble(amount: amount, divider: bitcoinAmountDivider));
|
||||
|
||||
double bitcoinAmountToDouble({int amount}) => cryptoAmountToDouble(amount: amount, divider: bitcoinAmountDivider);
|
||||
|
||||
int doubleToBitcoinAmount(double amount) =>
|
||||
(amount * bitcoinAmountDivider).toInt();
|
|
@ -2,7 +2,7 @@ import 'dart:convert';
|
|||
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:cake_wallet/bitcoin/bitcoin_amount_format.dart';
|
||||
import 'package:cake_wallet/src/domain/common/balance.dart';
|
||||
import 'package:cake_wallet/entities/balance.dart';
|
||||
|
||||
class BitcoinBalance extends Balance {
|
||||
const BitcoinBalance({@required this.confirmed, @required this.unconfirmed}) : super();
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import 'package:cake_wallet/src/domain/common/transaction_priority.dart';
|
||||
import 'package:cake_wallet/entities/transaction_priority.dart';
|
||||
|
||||
class BitcoinTransactionCredentials {
|
||||
BitcoinTransactionCredentials(this.address, this.amount, this.priority);
|
||||
|
|
|
@ -58,16 +58,7 @@ abstract class BitcoinTransactionHistoryBase
|
|||
final histories =
|
||||
wallet.scriptHashes.map((scriptHash) => eclient.getHistory(scriptHash));
|
||||
final _historiesWithDetails = await Future.wait(histories)
|
||||
.then((histories) => histories
|
||||
// .map((h) => h.where((tx) {
|
||||
// final height = tx['height'] as int ?? 0;
|
||||
// // FIXME: Filter only needed transactions
|
||||
// final _tx = get(tx['tx_hash'] as String);
|
||||
//
|
||||
// return height == 0 || height > _height;
|
||||
// }))
|
||||
.expand((i) => i)
|
||||
.toList())
|
||||
.then((histories) => histories.expand((i) => i).toList())
|
||||
.then((histories) => histories.map((tx) => fetchTransactionInfo(
|
||||
hash: tx['tx_hash'] as String, height: tx['height'] as int)));
|
||||
final historiesWithDetails = await Future.wait(_historiesWithDetails);
|
||||
|
|
|
@ -1,22 +1,22 @@
|
|||
import 'package:flutter/foundation.dart';
|
||||
import 'package:bitcoin_flutter/bitcoin_flutter.dart' as bitcoin;
|
||||
import 'package:cake_wallet/bitcoin/bitcoin_address_record.dart';
|
||||
import 'package:bitcoin_flutter/src/payments/index.dart' show PaymentData;
|
||||
import 'package:cake_wallet/bitcoin/bitcoin_address_record.dart';
|
||||
import 'package:cake_wallet/bitcoin/bitcoin_amount_format.dart';
|
||||
import 'package:cake_wallet/src/domain/bitcoin/bitcoin_amount_format.dart';
|
||||
import 'package:cake_wallet/src/domain/common/transaction_direction.dart';
|
||||
import 'package:cake_wallet/src/domain/common/transaction_info.dart';
|
||||
import 'package:cake_wallet/src/domain/common/format_amount.dart';
|
||||
import 'package:cake_wallet/entities/transaction_direction.dart';
|
||||
import 'package:cake_wallet/entities/transaction_info.dart';
|
||||
import 'package:cake_wallet/entities/format_amount.dart';
|
||||
|
||||
class BitcoinTransactionInfo extends TransactionInfo {
|
||||
BitcoinTransactionInfo(
|
||||
{@required this.id,
|
||||
{@required String id,
|
||||
@required int height,
|
||||
@required int amount,
|
||||
@required TransactionDirection direction,
|
||||
@required bool isPending,
|
||||
@required DateTime date,
|
||||
@required int confirmations}) {
|
||||
this.id = id;
|
||||
this.height = height;
|
||||
this.amount = amount;
|
||||
this.direction = direction;
|
||||
|
@ -97,7 +97,6 @@ class BitcoinTransactionInfo extends TransactionInfo {
|
|||
? DateTime.fromMillisecondsSinceEpoch(timestamp * 1000)
|
||||
: DateTime.now();
|
||||
|
||||
// FIXME: Get transaction is pending
|
||||
return BitcoinTransactionInfo(
|
||||
id: tx.getId(),
|
||||
height: height,
|
||||
|
@ -119,8 +118,6 @@ class BitcoinTransactionInfo extends TransactionInfo {
|
|||
confirmations: data['confirmations'] as int);
|
||||
}
|
||||
|
||||
final String id;
|
||||
|
||||
String _fiatAmount;
|
||||
|
||||
@override
|
||||
|
|
|
@ -14,15 +14,15 @@ import 'package:cake_wallet/bitcoin/electrum.dart';
|
|||
import 'package:cake_wallet/bitcoin/pending_bitcoin_transaction.dart';
|
||||
import 'package:cake_wallet/bitcoin/script_hash.dart';
|
||||
import 'package:cake_wallet/bitcoin/utils.dart';
|
||||
import 'package:cake_wallet/src/domain/bitcoin/bitcoin_amount_format.dart';
|
||||
import 'package:cake_wallet/src/domain/common/sync_status.dart';
|
||||
import 'package:cake_wallet/src/domain/common/transaction_priority.dart';
|
||||
import 'package:cake_wallet/src/domain/common/wallet_info.dart';
|
||||
import 'package:cake_wallet/bitcoin/bitcoin_amount_format.dart';
|
||||
import 'package:cake_wallet/entities/sync_status.dart';
|
||||
import 'package:cake_wallet/entities/transaction_priority.dart';
|
||||
import 'package:cake_wallet/entities/wallet_info.dart';
|
||||
import 'package:cake_wallet/bitcoin/bitcoin_transaction_history.dart';
|
||||
import 'package:cake_wallet/bitcoin/bitcoin_address_record.dart';
|
||||
import 'package:cake_wallet/bitcoin/file.dart';
|
||||
import 'package:cake_wallet/bitcoin/bitcoin_balance.dart';
|
||||
import 'package:cake_wallet/src/domain/common/node.dart';
|
||||
import 'package:cake_wallet/entities/node.dart';
|
||||
import 'package:cake_wallet/core/wallet_base.dart';
|
||||
|
||||
part 'bitcoin_wallet.g.dart';
|
||||
|
@ -316,6 +316,11 @@ abstract class BitcoinWalletBase extends WalletBase<BitcoinBalance> with Store {
|
|||
bitcoin.ECPair keyPairFor({@required int index}) =>
|
||||
generateKeyPair(hd: hd, index: index);
|
||||
|
||||
@override
|
||||
Future<void> rescan({int height}) async {
|
||||
// FIXME: Unimplemented
|
||||
}
|
||||
|
||||
void _subscribeForUpdates() {
|
||||
scriptHashes.forEach((sh) async {
|
||||
await _scripthashesUpdateSubject[sh]?.close();
|
||||
|
|
|
@ -4,8 +4,8 @@ import 'package:cake_wallet/bitcoin/file.dart';
|
|||
import 'package:cake_wallet/bitcoin/bitcoin_wallet_creation_credentials.dart';
|
||||
import 'package:cake_wallet/core/wallet_service.dart';
|
||||
import 'package:cake_wallet/bitcoin/bitcoin_wallet.dart';
|
||||
import 'package:cake_wallet/src/domain/common/pathForWallet.dart';
|
||||
import 'package:cake_wallet/src/domain/common/wallet_type.dart';
|
||||
import 'package:cake_wallet/entities/pathForWallet.dart';
|
||||
import 'package:cake_wallet/entities/wallet_type.dart';
|
||||
|
||||
class BitcoinWalletService extends WalletService<
|
||||
BitcoinNewWalletCredentials,
|
||||
|
|
|
@ -40,6 +40,7 @@ class ElectrumClient {
|
|||
_tasks = {};
|
||||
|
||||
static const connectionTimeout = Duration(seconds: 5);
|
||||
static const aliveTimerDuration = Duration(seconds: 2);
|
||||
|
||||
bool get isConnected => _isConnected;
|
||||
Socket socket;
|
||||
|
@ -97,8 +98,7 @@ class ElectrumClient {
|
|||
|
||||
void keepAlive() {
|
||||
_aliveTimer?.cancel();
|
||||
// FIXME: Unnamed constant.
|
||||
_aliveTimer = Timer.periodic(Duration(seconds: 2), (_) async => ping());
|
||||
_aliveTimer = Timer.periodic(aliveTimerDuration, (_) async => ping());
|
||||
}
|
||||
|
||||
Future<void> ping() async {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import 'package:cake_wallet/bitcoin/bitcoin_amount_format.dart';
|
||||
import 'package:cake_wallet/bitcoin/bitcoin_transaction_info.dart';
|
||||
import 'package:cake_wallet/src/domain/common/transaction_direction.dart';
|
||||
import 'package:cake_wallet/entities/transaction_direction.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:bitcoin_flutter/bitcoin_flutter.dart' as bitcoin;
|
||||
import 'package:cake_wallet/core/pending_transaction.dart';
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import 'package:cake_wallet/core/validator.dart';
|
||||
import 'package:cake_wallet/generated/i18n.dart';
|
||||
import 'package:cake_wallet/src/domain/common/wallet_type.dart';
|
||||
import 'package:cake_wallet/entities/wallet_type.dart';
|
||||
|
||||
class AddressLabelValidator extends TextValidator {
|
||||
AddressLabelValidator({WalletType type})
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import 'package:flutter/foundation.dart';
|
||||
import 'package:cake_wallet/generated/i18n.dart';
|
||||
import 'package:cake_wallet/core/validator.dart';
|
||||
import 'package:cake_wallet/src/domain/common/crypto_currency.dart';
|
||||
import 'package:cake_wallet/entities/crypto_currency.dart';
|
||||
|
||||
class AddressValidator extends TextValidator {
|
||||
AddressValidator({@required CryptoCurrency type})
|
||||
|
|
37
lib/core/amount.dart
Normal file
37
lib/core/amount.dart
Normal file
|
@ -0,0 +1,37 @@
|
|||
abstract class Amount {
|
||||
Amount(this.value);
|
||||
|
||||
int value;
|
||||
|
||||
int minorDigits;
|
||||
|
||||
String code;
|
||||
|
||||
String formatted();
|
||||
}
|
||||
|
||||
class MoneroAmount extends Amount {
|
||||
MoneroAmount(int value) : super(value) {
|
||||
minorDigits = 12;
|
||||
code = 'XMR';
|
||||
}
|
||||
|
||||
// const moneroAmountLength = 12;
|
||||
// const moneroAmountDivider = 1000000000000;
|
||||
// final moneroAmountFormat = NumberFormat()
|
||||
// ..maximumFractionDigits = moneroAmountLength
|
||||
// ..minimumFractionDigits = 1;
|
||||
|
||||
// String moneroAmountToString({int amount}) =>
|
||||
// moneroAmountFormat.format(cryptoAmountToDouble(amount: amount, divider: moneroAmountDivider));
|
||||
|
||||
// double moneroAmountToDouble({int amount}) => cryptoAmountToDouble(amount: amount, divider: moneroAmountDivider);
|
||||
|
||||
// int moneroParseAmount({String amount}) => moneroAmountFormat.parse(amount).toInt();
|
||||
|
||||
@override
|
||||
String formatted() {
|
||||
// TODO: implement formatted
|
||||
throw UnimplementedError();
|
||||
}
|
||||
}
|
92
lib/core/amount_converter.dart
Normal file
92
lib/core/amount_converter.dart
Normal file
|
@ -0,0 +1,92 @@
|
|||
import 'package:intl/intl.dart';
|
||||
import 'package:cake_wallet/entities/crypto_currency.dart';
|
||||
|
||||
class AmountConverter {
|
||||
static const _moneroAmountLength = 12;
|
||||
static const _moneroAmountDivider = 1000000000000;
|
||||
static const _litecoinAmountDivider = 100000000;
|
||||
static const _ethereumAmountDivider = 1000000000000000000;
|
||||
static const _dashAmountDivider = 100000000;
|
||||
static const _bitcoinCashAmountDivider = 100000000;
|
||||
static const _bitcoinAmountDivider = 100000000;
|
||||
static const _bitcoinAmountLength = 8;
|
||||
static final _bitcoinAmountFormat = NumberFormat()
|
||||
..maximumFractionDigits = _bitcoinAmountLength
|
||||
..minimumFractionDigits = 1;
|
||||
static final _moneroAmountFormat = NumberFormat()
|
||||
..maximumFractionDigits = _moneroAmountLength
|
||||
..minimumFractionDigits = 1;
|
||||
|
||||
static double amountIntToDouble(CryptoCurrency cryptoCurrency, int amount) {
|
||||
switch (cryptoCurrency) {
|
||||
case CryptoCurrency.xmr:
|
||||
return _moneroAmountToDouble(amount);
|
||||
case CryptoCurrency.btc:
|
||||
return _bitcoinAmountToDouble(amount);
|
||||
case CryptoCurrency.bch:
|
||||
return _bitcoinCashAmountToDouble(amount);
|
||||
case CryptoCurrency.dash:
|
||||
return _dashAmountToDouble(amount);
|
||||
case CryptoCurrency.eth:
|
||||
return _ethereumAmountToDouble(amount);
|
||||
case CryptoCurrency.ltc:
|
||||
return _litecoinAmountToDouble(amount);
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
static int amountStringToInt(CryptoCurrency cryptoCurrency, String amount) {
|
||||
switch (cryptoCurrency) {
|
||||
case CryptoCurrency.xmr:
|
||||
return _moneroParseAmount(amount);
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
static String amountIntToString(CryptoCurrency cryptoCurrency, int amount) {
|
||||
switch (cryptoCurrency) {
|
||||
case CryptoCurrency.xmr:
|
||||
return _moneroAmountToString(amount);
|
||||
case CryptoCurrency.btc:
|
||||
return _bitcoinAmountToString(amount);
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
static double cryptoAmountToDouble({num amount, num divider}) =>
|
||||
amount / divider;
|
||||
|
||||
static String _moneroAmountToString(int amount) => _moneroAmountFormat.format(
|
||||
cryptoAmountToDouble(amount: amount, divider: _moneroAmountDivider));
|
||||
|
||||
static double _moneroAmountToDouble(int amount) =>
|
||||
cryptoAmountToDouble(amount: amount, divider: _moneroAmountDivider);
|
||||
|
||||
static int _moneroParseAmount(String amount) =>
|
||||
_moneroAmountFormat.parse(amount).toInt();
|
||||
|
||||
static String _bitcoinAmountToString(int amount) =>
|
||||
_bitcoinAmountFormat.format(
|
||||
cryptoAmountToDouble(amount: amount, divider: _bitcoinAmountDivider));
|
||||
|
||||
static double _bitcoinAmountToDouble(int amount) =>
|
||||
cryptoAmountToDouble(amount: amount, divider: _bitcoinAmountDivider);
|
||||
|
||||
static int _doubleToBitcoinAmount(double amount) =>
|
||||
(amount * _bitcoinAmountDivider).toInt();
|
||||
|
||||
static double _bitcoinCashAmountToDouble(int amount) =>
|
||||
cryptoAmountToDouble(amount: amount, divider: _bitcoinCashAmountDivider);
|
||||
|
||||
static double _dashAmountToDouble(int amount) =>
|
||||
cryptoAmountToDouble(amount: amount, divider: _dashAmountDivider);
|
||||
|
||||
static double _ethereumAmountToDouble(num amount) =>
|
||||
cryptoAmountToDouble(amount: amount, divider: _ethereumAmountDivider);
|
||||
|
||||
static double _litecoinAmountToDouble(int amount) =>
|
||||
cryptoAmountToDouble(amount: amount, divider: _litecoinAmountDivider);
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
import 'package:cake_wallet/core/validator.dart';
|
||||
import 'package:cake_wallet/generated/i18n.dart';
|
||||
import 'package:cake_wallet/src/domain/common/wallet_type.dart';
|
||||
import 'package:cake_wallet/entities/wallet_type.dart';
|
||||
|
||||
class AmountValidator extends TextValidator {
|
||||
AmountValidator({WalletType type, bool isAutovalidate = false})
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
import 'package:mobx/mobx.dart';
|
||||
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
import 'package:cake_wallet/src/domain/common/secret_store_key.dart';
|
||||
import 'package:cake_wallet/src/domain/common/encrypt.dart';
|
||||
import 'package:cake_wallet/entities/preferences_key.dart';
|
||||
import 'package:cake_wallet/entities/secret_store_key.dart';
|
||||
import 'package:cake_wallet/entities/encrypt.dart';
|
||||
|
||||
class AuthService with Store {
|
||||
AuthService({this.secureStorage, this.sharedPreferences});
|
||||
|
@ -18,7 +19,8 @@ class AuthService with Store {
|
|||
|
||||
Future<bool> canAuthenticate() async {
|
||||
final key = generateStoreKeyFor(key: SecretStoreKey.pinCodePassword);
|
||||
final walletName = sharedPreferences.getString('current_wallet_name') ?? '';
|
||||
final walletName =
|
||||
sharedPreferences.getString(PreferencesKey.currentWalletName) ?? '';
|
||||
var password = '';
|
||||
|
||||
try {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import 'package:hive/hive.dart';
|
||||
import 'package:cake_wallet/store/contact_list_store.dart';
|
||||
import 'package:cake_wallet/src/domain/common/contact.dart';
|
||||
import 'package:cake_wallet/entities/contact.dart';
|
||||
|
||||
class ContactService {
|
||||
ContactService(this.contactSource, this.contactListStore) {
|
||||
|
|
13
lib/core/execution_state.dart
Normal file
13
lib/core/execution_state.dart
Normal file
|
@ -0,0 +1,13 @@
|
|||
abstract class ExecutionState {}
|
||||
|
||||
class InitialExecutionState extends ExecutionState {}
|
||||
|
||||
class IsExecutingState extends ExecutionState {}
|
||||
|
||||
class ExecutedSuccessfullyState extends ExecutionState {}
|
||||
|
||||
class FailureState extends ExecutionState {
|
||||
FailureState(this.error);
|
||||
|
||||
final String error;
|
||||
}
|
|
@ -1,13 +1,16 @@
|
|||
import 'package:cake_wallet/entities/crypto_currency.dart';
|
||||
import 'package:cake_wallet/entities/fiat_currency.dart';
|
||||
import 'dart:convert';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:http/http.dart';
|
||||
import 'package:cake_wallet/src/domain/common/crypto_currency.dart';
|
||||
import 'package:cake_wallet/src/domain/common/fiat_currency.dart';
|
||||
import 'package:cake_wallet/src/domain/common/currency_formatter.dart';
|
||||
import 'package:cake_wallet/entities/currency_formatter.dart';
|
||||
|
||||
const fiatApiAuthority = 'fiat-api.cakewallet.com';
|
||||
const fiatApiPath = '/v1/rates';
|
||||
|
||||
Future<double> fetchPriceFor({CryptoCurrency crypto, FiatCurrency fiat}) async {
|
||||
Future<double> _fetchPrice(Map<String, dynamic> args) async {
|
||||
final crypto = args['crypto'] as CryptoCurrency;
|
||||
final fiat = args['fiat'] as FiatCurrency;
|
||||
double price = 0.0;
|
||||
|
||||
try {
|
||||
|
@ -35,3 +38,12 @@ Future<double> fetchPriceFor({CryptoCurrency crypto, FiatCurrency fiat}) async {
|
|||
return price;
|
||||
}
|
||||
}
|
||||
|
||||
Future<double> _fetchPriceAsync(
|
||||
CryptoCurrency crypto, FiatCurrency fiat) async =>
|
||||
compute(_fetchPrice, {'fiat': fiat, 'crypto': crypto});
|
||||
|
||||
class FiatConversionService {
|
||||
static Future<double> fetchPrice(CryptoCurrency crypto, FiatCurrency fiat) async =>
|
||||
await _fetchPriceAsync(crypto, fiat);
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
import 'package:uuid/uuid.dart';
|
||||
import 'package:cake_wallet/bitcoin/key.dart';
|
||||
import 'package:cake_wallet/src/domain/common/wallet_type.dart';
|
||||
import 'package:cake_wallet/entities/wallet_type.dart';
|
||||
|
||||
String generateWalletPassword(WalletType type) {
|
||||
switch (type) {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
|
||||
import 'package:cake_wallet/src/domain/common/secret_store_key.dart';
|
||||
import 'package:cake_wallet/src/domain/common/encrypt.dart';
|
||||
import 'package:cake_wallet/entities/secret_store_key.dart';
|
||||
import 'package:cake_wallet/entities/encrypt.dart';
|
||||
|
||||
class KeyService {
|
||||
KeyService(this._secureStorage);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import 'package:cake_wallet/src/domain/common/wallet_type.dart';
|
||||
import 'package:cake_wallet/entities/wallet_type.dart';
|
||||
|
||||
const bitcoinMnemonicLength = 12;
|
||||
const moneroMnemonicLength = 25;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import 'package:flutter/foundation.dart';
|
||||
import 'package:cake_wallet/generated/i18n.dart';
|
||||
import 'package:cake_wallet/core/validator.dart';
|
||||
import 'package:cake_wallet/src/domain/common/crypto_currency.dart';
|
||||
import 'package:cake_wallet/entities/crypto_currency.dart';
|
||||
|
||||
class MoneroLabelValidator extends TextValidator {
|
||||
MoneroLabelValidator({@required CryptoCurrency type})
|
||||
|
|
|
@ -1,15 +1,16 @@
|
|||
import 'package:bip39/src/wordlists/english.dart' as bitcoin_english;
|
||||
import 'package:cake_wallet/core/validator.dart';
|
||||
import 'package:cake_wallet/src/domain/common/mnemonic_item.dart';
|
||||
import 'package:cake_wallet/src/domain/common/wallet_type.dart';
|
||||
import 'package:cake_wallet/src/domain/monero/mnemonics/chinese_simplified.dart';
|
||||
import 'package:cake_wallet/src/domain/monero/mnemonics/dutch.dart';
|
||||
import 'package:cake_wallet/src/domain/monero/mnemonics/english.dart';
|
||||
import 'package:cake_wallet/src/domain/monero/mnemonics/german.dart';
|
||||
import 'package:cake_wallet/src/domain/monero/mnemonics/japanese.dart';
|
||||
import 'package:cake_wallet/src/domain/monero/mnemonics/portuguese.dart';
|
||||
import 'package:cake_wallet/src/domain/monero/mnemonics/russian.dart';
|
||||
import 'package:cake_wallet/src/domain/monero/mnemonics/spanish.dart';
|
||||
import 'package:cake_wallet/entities/mnemonic_item.dart';
|
||||
import 'package:cake_wallet/entities/wallet_type.dart';
|
||||
import 'package:cake_wallet/monero/mnemonics/chinese_simplified.dart';
|
||||
import 'package:cake_wallet/monero/mnemonics/dutch.dart';
|
||||
import 'package:cake_wallet/monero/mnemonics/english.dart';
|
||||
import 'package:cake_wallet/monero/mnemonics/german.dart';
|
||||
import 'package:cake_wallet/monero/mnemonics/japanese.dart';
|
||||
import 'package:cake_wallet/monero/mnemonics/portuguese.dart';
|
||||
import 'package:cake_wallet/monero/mnemonics/russian.dart';
|
||||
import 'package:cake_wallet/monero/mnemonics/spanish.dart';
|
||||
import 'package:cake_wallet/utils/language_list.dart';
|
||||
|
||||
class SeedValidator extends Validator<MnemonicItem> {
|
||||
SeedValidator({this.type, this.language})
|
||||
|
@ -31,31 +32,29 @@ class SeedValidator extends Validator<MnemonicItem> {
|
|||
}
|
||||
|
||||
static List<String> getMoneroWordList(String language) {
|
||||
// FIXME: Unnamed constants; Need to be sure that string are in same case;
|
||||
|
||||
switch (language) {
|
||||
case 'English':
|
||||
case LanguageList.english:
|
||||
return EnglishMnemonics.words;
|
||||
break;
|
||||
case 'Chinese (simplified)':
|
||||
case LanguageList.chineseSimplified:
|
||||
return ChineseSimplifiedMnemonics.words;
|
||||
break;
|
||||
case 'Dutch':
|
||||
case LanguageList.dutch:
|
||||
return DutchMnemonics.words;
|
||||
break;
|
||||
case 'German':
|
||||
case LanguageList.german:
|
||||
return GermanMnemonics.words;
|
||||
break;
|
||||
case 'Japanese':
|
||||
case LanguageList.japanese:
|
||||
return JapaneseMnemonics.words;
|
||||
break;
|
||||
case 'Portuguese':
|
||||
case LanguageList.portuguese:
|
||||
return PortugueseMnemonics.words;
|
||||
break;
|
||||
case 'Russian':
|
||||
case LanguageList.russian:
|
||||
return RussianMnemonics.words;
|
||||
break;
|
||||
case 'Spanish':
|
||||
case LanguageList.spanish:
|
||||
return SpanishMnemonics.words;
|
||||
break;
|
||||
default:
|
||||
|
@ -64,7 +63,7 @@ class SeedValidator extends Validator<MnemonicItem> {
|
|||
}
|
||||
|
||||
static List<String> getBitcoinWordList(String language) {
|
||||
assert(language.toLowerCase() == 'english');
|
||||
assert(language.toLowerCase() == LanguageList.english.toLowerCase());
|
||||
return bitcoin_english.WORDLIST;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import 'package:flutter/foundation.dart';
|
||||
import 'package:mobx/mobx.dart';
|
||||
import 'package:cake_wallet/src/domain/common/transaction_info.dart';
|
||||
import 'package:cake_wallet/entities/transaction_info.dart';
|
||||
|
||||
abstract class TransactionHistoryBase<TransactionType extends TransactionInfo> {
|
||||
TransactionHistoryBase() : _isUpdating = false;
|
||||
|
|
|
@ -1,24 +1,13 @@
|
|||
import 'package:flutter/foundation.dart';
|
||||
import 'package:cake_wallet/src/domain/common/wallet_info.dart';
|
||||
import 'package:cake_wallet/entities/wallet_info.dart';
|
||||
import 'package:cake_wallet/core/pending_transaction.dart';
|
||||
import 'package:cake_wallet/core/transaction_history.dart';
|
||||
import 'package:cake_wallet/src/domain/common/transaction_priority.dart';
|
||||
import 'package:cake_wallet/src/domain/common/crypto_currency.dart';
|
||||
import 'package:cake_wallet/src/domain/common/sync_status.dart';
|
||||
import 'package:cake_wallet/src/domain/common/node.dart';
|
||||
import 'package:cake_wallet/src/domain/common/wallet_type.dart';
|
||||
|
||||
// FIXME: Move me.
|
||||
CryptoCurrency currencyForWalletType(WalletType type) {
|
||||
switch (type) {
|
||||
case WalletType.bitcoin:
|
||||
return CryptoCurrency.btc;
|
||||
case WalletType.monero:
|
||||
return CryptoCurrency.xmr;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
import 'package:cake_wallet/entities/currency_for_wallet_type.dart';
|
||||
import 'package:cake_wallet/entities/transaction_priority.dart';
|
||||
import 'package:cake_wallet/entities/crypto_currency.dart';
|
||||
import 'package:cake_wallet/entities/sync_status.dart';
|
||||
import 'package:cake_wallet/entities/node.dart';
|
||||
import 'package:cake_wallet/entities/wallet_type.dart';
|
||||
|
||||
abstract class WalletBase<BalaceType> {
|
||||
WalletBase(this.walletInfo);
|
||||
|
@ -61,4 +50,6 @@ abstract class WalletBase<BalaceType> {
|
|||
double calculateEstimatedFee(TransactionPriority priority);
|
||||
|
||||
Future<void> save();
|
||||
|
||||
Future<void> rescan({int height});
|
||||
}
|
||||
|
|
|
@ -3,18 +3,15 @@ import 'package:flutter/foundation.dart';
|
|||
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
import 'package:cake_wallet/core/key_service.dart';
|
||||
import 'package:cake_wallet/core/wallet_base.dart';
|
||||
import 'package:cake_wallet/core/generate_wallet_password.dart';
|
||||
import 'package:cake_wallet/store/app_store.dart';
|
||||
import 'package:cake_wallet/core/wallet_credentials.dart';
|
||||
import 'package:cake_wallet/bitcoin/bitcoin_wallet_service.dart';
|
||||
import 'package:cake_wallet/monero/monero_wallet_service.dart';
|
||||
import 'package:cake_wallet/core/wallet_service.dart';
|
||||
import 'package:cake_wallet/src/domain/common/wallet_type.dart';
|
||||
import 'package:cake_wallet/entities/wallet_type.dart';
|
||||
|
||||
class WalletCreationService {
|
||||
WalletCreationService(
|
||||
{WalletType initialType,
|
||||
this.appStore,
|
||||
this.secureStorage,
|
||||
this.keyService,
|
||||
this.sharedPreferences})
|
||||
|
@ -25,7 +22,6 @@ class WalletCreationService {
|
|||
}
|
||||
|
||||
WalletType type;
|
||||
final AppStore appStore;
|
||||
final FlutterSecureStorage secureStorage;
|
||||
final SharedPreferences sharedPreferences;
|
||||
final KeyService keyService;
|
||||
|
@ -36,33 +32,27 @@ class WalletCreationService {
|
|||
_service = getIt.get<WalletService>(param1: type);
|
||||
}
|
||||
|
||||
Future<void> create(WalletCredentials credentials) async {
|
||||
Future<WalletBase> create(WalletCredentials credentials) async {
|
||||
final password = generateWalletPassword(type);
|
||||
credentials.password = password;
|
||||
await keyService.saveWalletPassword(
|
||||
password: password, walletName: credentials.name);
|
||||
final wallet = await _service.create(credentials);
|
||||
appStore.wallet = wallet;
|
||||
appStore.authenticationStore.allowed();
|
||||
return await _service.create(credentials);
|
||||
}
|
||||
|
||||
Future<void> restoreFromKeys(WalletCredentials credentials) async {
|
||||
Future<WalletBase> restoreFromKeys(WalletCredentials credentials) async {
|
||||
final password = generateWalletPassword(type);
|
||||
credentials.password = password;
|
||||
await keyService.saveWalletPassword(
|
||||
password: password, walletName: credentials.name);
|
||||
final wallet = await _service.restoreFromKeys(credentials);
|
||||
appStore.wallet = wallet;
|
||||
appStore.authenticationStore.allowed();
|
||||
return await _service.restoreFromKeys(credentials);
|
||||
}
|
||||
|
||||
Future<void> restoreFromSeed(WalletCredentials credentials) async {
|
||||
Future<WalletBase> restoreFromSeed(WalletCredentials credentials) async {
|
||||
final password = generateWalletPassword(type);
|
||||
credentials.password = password;
|
||||
await keyService.saveWalletPassword(
|
||||
password: password, walletName: credentials.name);
|
||||
final wallet = await _service.restoreFromSeed(credentials);
|
||||
appStore.wallet = wallet;
|
||||
appStore.authenticationStore.allowed();
|
||||
return await _service.restoreFromSeed(credentials);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import 'package:cake_wallet/src/domain/common/wallet_info.dart';
|
||||
import 'package:cake_wallet/entities/wallet_info.dart';
|
||||
|
||||
abstract class WalletCredentials {
|
||||
WalletCredentials({this.name, this.password, this.height});
|
||||
|
|
118
lib/di.dart
118
lib/di.dart
|
@ -1,10 +1,12 @@
|
|||
import 'package:cake_wallet/bitcoin/bitcoin_wallet_service.dart';
|
||||
import 'package:cake_wallet/core/contact_service.dart';
|
||||
import 'package:cake_wallet/core/wallet_service.dart';
|
||||
import 'package:cake_wallet/entities/biometric_auth.dart';
|
||||
import 'package:cake_wallet/monero/monero_wallet_service.dart';
|
||||
import 'package:cake_wallet/src/domain/common/contact.dart';
|
||||
import 'package:cake_wallet/src/domain/common/node.dart';
|
||||
import 'package:cake_wallet/src/domain/exchange/trade.dart';
|
||||
import 'package:cake_wallet/entities/contact.dart';
|
||||
import 'package:cake_wallet/entities/node.dart';
|
||||
import 'package:cake_wallet/exchange/trade.dart';
|
||||
|
||||
// import 'package:cake_wallet/src/domain/services/wallet_service.dart';
|
||||
import 'package:cake_wallet/src/screens/contact/contact_list_page.dart';
|
||||
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
|
|||
import 'package:cake_wallet/src/screens/exchange_trade/exchange_trade_page.dart';
|
||||
import 'package:cake_wallet/src/screens/nodes/node_create_or_edit_page.dart';
|
||||
import 'package:cake_wallet/src/screens/nodes/nodes_list_page.dart';
|
||||
import 'package:cake_wallet/src/screens/rescan/rescan_page.dart';
|
||||
import 'package:cake_wallet/src/screens/seed/wallet_seed_page.dart';
|
||||
import 'package:cake_wallet/src/screens/send/send_template_page.dart';
|
||||
import 'package:cake_wallet/src/screens/settings/settings.dart';
|
||||
import 'package:cake_wallet/src/screens/setup_pin_code/setup_pin_code.dart';
|
||||
import 'package:cake_wallet/src/screens/wallet_keys/wallet_keys_page.dart';
|
||||
import 'package:cake_wallet/src/screens/exchange/exchange_page.dart';
|
||||
import 'package:cake_wallet/src/screens/exchange/exchange_template_page.dart';
|
||||
|
@ -24,7 +28,7 @@ import 'package:cake_wallet/store/settings_store.dart';
|
|||
import 'package:cake_wallet/core/auth_service.dart';
|
||||
import 'package:cake_wallet/core/key_service.dart';
|
||||
import 'package:cake_wallet/monero/monero_wallet.dart';
|
||||
import 'package:cake_wallet/src/domain/common/wallet_info.dart';
|
||||
import 'package:cake_wallet/entities/wallet_info.dart';
|
||||
import 'package:cake_wallet/src/screens/monero_accounts/monero_account_list_page.dart';
|
||||
import 'package:cake_wallet/src/screens/monero_accounts/monero_account_edit_or_create_page.dart';
|
||||
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';
|
|||
import 'package:cake_wallet/view_model/exchange/exchange_trade_view_model.dart';
|
||||
import 'package:cake_wallet/view_model/node_list/node_list_view_model.dart';
|
||||
import 'package:cake_wallet/view_model/node_list/node_create_or_edit_view_model.dart';
|
||||
import 'package:cake_wallet/view_model/rescan_view_model.dart';
|
||||
import 'package:cake_wallet/view_model/setup_pin_code_view_model.dart';
|
||||
import 'package:cake_wallet/view_model/wallet_address_list/wallet_address_edit_or_create_view_model.dart';
|
||||
import 'package:cake_wallet/view_model/auth_view_model.dart';
|
||||
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';
|
|||
import 'package:cake_wallet/view_model/wallet_seed_view_model.dart';
|
||||
import 'package:cake_wallet/view_model/exchange/exchange_view_model.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/widgets.dart';
|
||||
import 'package:get_it/get_it.dart';
|
||||
import 'package:hive/hive.dart';
|
||||
import 'package:mobx/mobx.dart';
|
||||
|
@ -65,51 +72,20 @@ import 'package:cake_wallet/view_model/wallet_restoration_from_seed_vm.dart';
|
|||
import 'package:cake_wallet/view_model/wallet_restoration_from_keys_vm.dart';
|
||||
import 'package:cake_wallet/core/wallet_creation_service.dart';
|
||||
import 'package:cake_wallet/store/app_store.dart';
|
||||
import 'package:cake_wallet/src/domain/common/wallet_type.dart';
|
||||
import 'package:cake_wallet/entities/wallet_type.dart';
|
||||
import 'package:cake_wallet/view_model/wallet_new_vm.dart';
|
||||
import 'package:cake_wallet/store/authentication_store.dart';
|
||||
import 'package:cake_wallet/store/dashboard/trades_store.dart';
|
||||
import 'package:cake_wallet/store/dashboard/trade_filter_store.dart';
|
||||
import 'package:cake_wallet/store/dashboard/transaction_filter_store.dart';
|
||||
import 'package:cake_wallet/store/dashboard/fiat_convertation_store.dart';
|
||||
import 'package:cake_wallet/store/dashboard/fiat_conversion_store.dart';
|
||||
import 'package:cake_wallet/store/templates/send_template_store.dart';
|
||||
import 'package:cake_wallet/store/templates/exchange_template_store.dart';
|
||||
import 'package:cake_wallet/src/domain/common/template.dart';
|
||||
import 'package:cake_wallet/src/domain/exchange/exchange_template.dart';
|
||||
import 'package:cake_wallet/entities/template.dart';
|
||||
import 'package:cake_wallet/exchange/exchange_template.dart';
|
||||
|
||||
final getIt = GetIt.instance;
|
||||
|
||||
// FIXME: Move me.
|
||||
|
||||
Stream<BoxEvent> _onNodesSourceChange;
|
||||
NodeListStore _nodeListStore;
|
||||
|
||||
NodeListStore setupNodeListStore(Box<Node> nodeSource) {
|
||||
if (_nodeListStore != null) {
|
||||
return _nodeListStore;
|
||||
}
|
||||
|
||||
_nodeListStore = NodeListStore();
|
||||
_nodeListStore.replaceValues(nodeSource.values);
|
||||
_onNodesSourceChange = nodeSource.watch();
|
||||
_onNodesSourceChange.listen((event) {
|
||||
// print(event);
|
||||
|
||||
if (event.deleted) {
|
||||
_nodeListStore.nodes.removeWhere((n) {
|
||||
return n.key != null ? n.key == event.key : true;
|
||||
});
|
||||
}
|
||||
|
||||
if (event.value is Node) {
|
||||
final val = event.value as Node;
|
||||
_nodeListStore.nodes.add(val);
|
||||
}
|
||||
});
|
||||
|
||||
return _nodeListStore;
|
||||
}
|
||||
|
||||
Future setup(
|
||||
{Box<WalletInfo> walletInfoSource,
|
||||
Box<Node> nodeSource,
|
||||
|
@ -122,11 +98,13 @@ Future setup(
|
|||
|
||||
final settingsStore = await SettingsStoreBase.load(nodeSource: nodeSource);
|
||||
|
||||
getIt.registerSingleton<Box<Node>>(nodeSource);
|
||||
|
||||
getIt.registerSingleton<FlutterSecureStorage>(FlutterSecureStorage());
|
||||
getIt.registerSingleton(AuthenticationStore());
|
||||
getIt.registerSingleton<WalletListStore>(WalletListStore());
|
||||
getIt.registerSingleton(ContactListStore());
|
||||
getIt.registerSingleton(setupNodeListStore(nodeSource));
|
||||
getIt.registerSingleton(NodeListStoreBase.instance);
|
||||
getIt.registerSingleton<SettingsStore>(settingsStore);
|
||||
getIt.registerSingleton<AppStore>(AppStore(
|
||||
authenticationStore: getIt.get<AuthenticationStore>(),
|
||||
|
@ -140,7 +118,7 @@ Future setup(
|
|||
tradesSource: tradesSource, settingsStore: getIt.get<SettingsStore>()));
|
||||
getIt.registerSingleton<TradeFilterStore>(TradeFilterStore());
|
||||
getIt.registerSingleton<TransactionFilterStore>(TransactionFilterStore());
|
||||
getIt.registerSingleton<FiatConvertationStore>(FiatConvertationStore());
|
||||
getIt.registerSingleton<FiatConversionStore>(FiatConversionStore());
|
||||
getIt.registerSingleton<SendTemplateStore>(
|
||||
SendTemplateStore(templateSource: templates));
|
||||
getIt.registerSingleton<ExchangeTemplateStore>(
|
||||
|
@ -152,13 +130,12 @@ Future setup(
|
|||
getIt.registerFactoryParam<WalletCreationService, WalletType, void>(
|
||||
(type, _) => WalletCreationService(
|
||||
initialType: type,
|
||||
appStore: getIt.get<AppStore>(),
|
||||
keyService: getIt.get<KeyService>(),
|
||||
secureStorage: getIt.get<FlutterSecureStorage>(),
|
||||
sharedPreferences: getIt.get<SharedPreferences>()));
|
||||
|
||||
getIt.registerFactoryParam<WalletNewVM, WalletType, void>((type, _) =>
|
||||
WalletNewVM(
|
||||
WalletNewVM(getIt.get<AppStore>(),
|
||||
getIt.get<WalletCreationService>(param1: type), walletInfoSource,
|
||||
type: type));
|
||||
|
||||
|
@ -168,7 +145,7 @@ Future setup(
|
|||
final language = args[1] as String;
|
||||
final mnemonic = args[2] as String;
|
||||
|
||||
return WalletRestorationFromSeedVM(
|
||||
return WalletRestorationFromSeedVM(getIt.get<AppStore>(),
|
||||
getIt.get<WalletCreationService>(param1: type), walletInfoSource,
|
||||
type: type, language: language, seed: mnemonic);
|
||||
});
|
||||
|
@ -178,7 +155,7 @@ Future setup(
|
|||
final type = args.first as WalletType;
|
||||
final language = args[1] as String;
|
||||
|
||||
return WalletRestorationFromKeysVM(
|
||||
return WalletRestorationFromKeysVM(getIt.get<AppStore>(),
|
||||
getIt.get<WalletCreationService>(param1: type), walletInfoSource,
|
||||
type: type, language: language);
|
||||
});
|
||||
|
@ -189,7 +166,7 @@ Future setup(
|
|||
getIt.registerFactory(() => BalanceViewModel(
|
||||
wallet: getIt.get<AppStore>().wallet,
|
||||
settingsStore: getIt.get<SettingsStore>(),
|
||||
fiatConvertationStore: getIt.get<FiatConvertationStore>()));
|
||||
fiatConvertationStore: getIt.get<FiatConversionStore>()));
|
||||
|
||||
getIt.registerFactory(() => DashboardViewModel(
|
||||
balanceViewModel: getIt.get<BalanceViewModel>(),
|
||||
|
@ -203,38 +180,24 @@ Future setup(
|
|||
sharedPreferences: getIt.get<SharedPreferences>()));
|
||||
|
||||
getIt.registerFactory<AuthViewModel>(() => AuthViewModel(
|
||||
authService: getIt.get<AuthService>(),
|
||||
sharedPreferences: getIt.get<SharedPreferences>()));
|
||||
getIt.get<AuthService>(),
|
||||
getIt.get<SharedPreferences>(),
|
||||
getIt.get<SettingsStore>(),
|
||||
BiometricAuth()));
|
||||
|
||||
getIt.registerFactory<AuthPage>(
|
||||
() => AuthPage(
|
||||
allowBiometricalAuthentication: getIt
|
||||
.get<AppStore>()
|
||||
.settingsStore
|
||||
.allowBiometricalAuthentication,
|
||||
authViewModel: getIt.get<AuthViewModel>(),
|
||||
onAuthenticationFinished: (isAuthenticated, __) {
|
||||
() => AuthPage(getIt.get<AuthViewModel>(),
|
||||
onAuthenticationFinished: (isAuthenticated, __) {
|
||||
if (isAuthenticated) {
|
||||
getIt.get<AuthenticationStore>().allowed();
|
||||
}
|
||||
},
|
||||
closable: false),
|
||||
}, closable: false),
|
||||
instanceName: 'login');
|
||||
|
||||
getIt
|
||||
.registerFactoryParam<AuthPage, void Function(bool, AuthPageState), void>(
|
||||
(onAuthFinished, _) {
|
||||
final allowBiometricalAuthentication =
|
||||
getIt.get<AppStore>().settingsStore.allowBiometricalAuthentication;
|
||||
|
||||
print('allowBiometricalAuthentication $allowBiometricalAuthentication');
|
||||
|
||||
return AuthPage(
|
||||
allowBiometricalAuthentication: allowBiometricalAuthentication,
|
||||
authViewModel: getIt.get<AuthViewModel>(),
|
||||
onAuthenticationFinished: onAuthFinished,
|
||||
closable: false);
|
||||
});
|
||||
(onAuthFinished, _) => AuthPage(getIt.get<AuthViewModel>(),
|
||||
onAuthenticationFinished: onAuthFinished, closable: false));
|
||||
|
||||
getIt.registerFactory<DashboardPage>(() => DashboardPage(
|
||||
walletViewModel: getIt.get<DashboardViewModel>(),
|
||||
|
@ -256,13 +219,13 @@ Future setup(
|
|||
getIt.registerFactory<SendViewModel>(() => SendViewModel(
|
||||
getIt.get<AppStore>().wallet,
|
||||
getIt.get<AppStore>().settingsStore,
|
||||
getIt.get<FiatConvertationStore>()));
|
||||
getIt.get<FiatConversionStore>()));
|
||||
|
||||
getIt.registerFactory(
|
||||
() => SendPage(sendViewModel: getIt.get<SendViewModel>()));
|
||||
|
||||
getIt.registerFactory(
|
||||
() => SendTemplatePage(sendViewModel: getIt.get<SendViewModel>()));
|
||||
() => SendTemplatePage(sendViewModel: getIt.get<SendViewModel>()));
|
||||
|
||||
getIt.registerFactory(() => WalletListViewModel(
|
||||
walletInfoSource, getIt.get<AppStore>(), getIt.get<KeyService>()));
|
||||
|
@ -387,6 +350,19 @@ Future setup(
|
|||
return null;
|
||||
}
|
||||
});
|
||||
|
||||
getIt.registerFactory<SetupPinCodeViewModel>(() => SetupPinCodeViewModel(
|
||||
getIt.get<AuthService>(), getIt.get<SettingsStore>()));
|
||||
|
||||
getIt.registerFactoryParam<SetupPinCodePage,
|
||||
void Function(BuildContext, String), void>(
|
||||
(onSuccessfulPinSetup, _) => SetupPinCodePage(
|
||||
getIt.get<SetupPinCodeViewModel>(),
|
||||
onSuccessfulPinSetup: onSuccessfulPinSetup));
|
||||
|
||||
getIt.registerFactory(() => RescanViewModel(getIt.get<AppStore>().wallet));
|
||||
|
||||
getIt.registerFactory(() => RescanPage(getIt.get<RescanViewModel>()));
|
||||
}
|
||||
|
||||
void setupThemeChangerStore(ThemeChanger themeChanger) {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import 'package:flutter/foundation.dart';
|
||||
import 'package:cake_wallet/generated/i18n.dart';
|
||||
import 'package:cake_wallet/src/domain/common/enumerable_item.dart';
|
||||
import 'package:cake_wallet/entities/enumerable_item.dart';
|
||||
|
||||
class BalanceDisplayMode extends EnumerableItem<int> with Serializable<int> {
|
||||
const BalanceDisplayMode({@required String title, @required int raw})
|
|
@ -1,4 +1,4 @@
|
|||
import 'package:cake_wallet/src/domain/common/transaction_priority.dart';
|
||||
import 'package:cake_wallet/entities/transaction_priority.dart';
|
||||
|
||||
double calculateEstimatedFee({TransactionPriority priority}) {
|
||||
if (priority == TransactionPriority.slow) {
|
|
@ -1,6 +1,6 @@
|
|||
import 'package:flutter/foundation.dart';
|
||||
import 'package:hive/hive.dart';
|
||||
import 'package:cake_wallet/src/domain/common/crypto_currency.dart';
|
||||
import 'package:cake_wallet/entities/crypto_currency.dart';
|
||||
import 'package:cake_wallet/utils/mobx.dart';
|
||||
|
||||
part 'contact.g.dart';
|
|
@ -1,7 +1,7 @@
|
|||
// import 'package:hive/hive.dart';
|
||||
// import 'package:mobx/mobx.dart';
|
||||
// import 'package:cake_wallet/src/domain/common/contact.dart';
|
||||
// import 'package:cake_wallet/src/domain/common/crypto_currency.dart';
|
||||
// import 'package:cake_wallet/entities/contact.dart';
|
||||
// import 'package:cake_wallet/entities/crypto_currency.dart';
|
||||
|
||||
// part 'contact_model.g.dart';
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
import 'package:cake_wallet/src/domain/common/enumerable_item.dart';
|
||||
import 'package:cake_wallet/entities/enumerable_item.dart';
|
||||
import 'package:hive/hive.dart';
|
||||
|
||||
part 'crypto_currency.g.dart';
|
13
lib/entities/currency_for_wallet_type.dart
Normal file
13
lib/entities/currency_for_wallet_type.dart
Normal file
|
@ -0,0 +1,13 @@
|
|||
import 'package:cake_wallet/entities/crypto_currency.dart';
|
||||
import 'package:cake_wallet/entities/wallet_type.dart';
|
||||
|
||||
CryptoCurrency currencyForWalletType(WalletType type) {
|
||||
switch (type) {
|
||||
case WalletType.bitcoin:
|
||||
return CryptoCurrency.btc;
|
||||
case WalletType.monero:
|
||||
return CryptoCurrency.xmr;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
import 'package:cake_wallet/src/domain/common/crypto_currency.dart';
|
||||
import 'package:cake_wallet/entities/crypto_currency.dart';
|
||||
|
||||
String cryptoToString(CryptoCurrency crypto) {
|
||||
switch (crypto) {
|
|
@ -1,13 +1,13 @@
|
|||
import 'package:cake_wallet/src/domain/common/wallet_type.dart';
|
||||
import 'package:cake_wallet/store/settings_store.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:hive/hive.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
import 'package:cake_wallet/src/domain/common/node.dart';
|
||||
import 'package:cake_wallet/src/domain/common/balance_display_mode.dart';
|
||||
import 'package:cake_wallet/src/domain/common/fiat_currency.dart';
|
||||
import 'package:cake_wallet/src/domain/common/node_list.dart';
|
||||
import 'package:cake_wallet/src/domain/common/transaction_priority.dart';
|
||||
import 'package:cake_wallet/entities/preferences_key.dart';
|
||||
import 'package:cake_wallet/entities/wallet_type.dart';
|
||||
import 'package:cake_wallet/entities/node.dart';
|
||||
import 'package:cake_wallet/entities/balance_display_mode.dart';
|
||||
import 'package:cake_wallet/entities/fiat_currency.dart';
|
||||
import 'package:cake_wallet/entities/node_list.dart';
|
||||
import 'package:cake_wallet/entities/transaction_priority.dart';
|
||||
|
||||
Future defaultSettingsMigration(
|
||||
{@required int version,
|
||||
|
@ -29,13 +29,13 @@ Future defaultSettingsMigration(
|
|||
switch (version) {
|
||||
case 1:
|
||||
await sharedPreferences.setString(
|
||||
SettingsStoreBase.currentFiatCurrencyKey,
|
||||
PreferencesKey.currentFiatCurrencyKey,
|
||||
FiatCurrency.usd.toString());
|
||||
await sharedPreferences.setInt(
|
||||
SettingsStoreBase.currentTransactionPriorityKey,
|
||||
PreferencesKey.currentTransactionPriorityKey,
|
||||
TransactionPriority.standart.raw);
|
||||
await sharedPreferences.setInt(
|
||||
SettingsStoreBase.currentBalanceDisplayModeKey,
|
||||
PreferencesKey.currentBalanceDisplayModeKey,
|
||||
BalanceDisplayMode.availableBalance.raw);
|
||||
await sharedPreferences.setBool('save_recipient_address', true);
|
||||
await resetToDefault(nodes);
|
|
@ -1,4 +1,4 @@
|
|||
import 'package:cake_wallet/src/domain/common/enumerable_item.dart';
|
||||
import 'package:cake_wallet/entities/enumerable_item.dart';
|
||||
|
||||
class FiatCurrency extends EnumerableItem<String> with Serializable<String> {
|
||||
const FiatCurrency({String symbol}) : super(title: symbol, raw: symbol);
|
|
@ -1,10 +1,10 @@
|
|||
import 'dart:io';
|
||||
import 'dart:convert';
|
||||
import 'package:cake_wallet/src/domain/common/contact.dart';
|
||||
import 'package:cake_wallet/src/domain/common/crypto_currency.dart';
|
||||
import 'package:cake_wallet/src/domain/common/wallet_info.dart';
|
||||
import 'package:cake_wallet/src/domain/common/wallet_type.dart';
|
||||
import 'package:cake_wallet/src/domain/exchange/trade.dart';
|
||||
import 'package:cake_wallet/entities/contact.dart';
|
||||
import 'package:cake_wallet/entities/crypto_currency.dart';
|
||||
import 'package:cake_wallet/entities/wallet_info.dart';
|
||||
import 'package:cake_wallet/entities/wallet_type.dart';
|
||||
import 'package:cake_wallet/exchange/trade.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:hive/hive.dart';
|
||||
import 'package:path_provider/path_provider.dart';
|
23
lib/entities/load_current_wallet.dart
Normal file
23
lib/entities/load_current_wallet.dart
Normal file
|
@ -0,0 +1,23 @@
|
|||
import 'package:cake_wallet/di.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
import 'package:cake_wallet/store/app_store.dart';
|
||||
import 'package:cake_wallet/core/key_service.dart';
|
||||
import 'package:cake_wallet/core/wallet_service.dart';
|
||||
import 'package:cake_wallet/entities/preferences_key.dart';
|
||||
import 'package:cake_wallet/entities/wallet_type.dart';
|
||||
|
||||
Future<void> loadCurrentWallet() async {
|
||||
final appStore = getIt.get<AppStore>();
|
||||
final name = getIt
|
||||
.get<SharedPreferences>()
|
||||
.getString(PreferencesKey.currentWalletName);
|
||||
final typeRaw =
|
||||
getIt.get<SharedPreferences>().getInt(PreferencesKey.currentWalletType) ??
|
||||
0;
|
||||
final type = deserializeFromInt(typeRaw);
|
||||
final password =
|
||||
await getIt.get<KeyService>().getWalletPassword(walletName: name);
|
||||
final _service = getIt.get<WalletService>(param1: type);
|
||||
final wallet = await _service.openWallet(name, password);
|
||||
appStore.wallet = wallet;
|
||||
}
|
|
@ -3,8 +3,8 @@ import 'package:flutter/foundation.dart';
|
|||
import 'dart:convert';
|
||||
import 'package:http/http.dart' as http;
|
||||
import 'package:hive/hive.dart';
|
||||
import 'package:cake_wallet/src/domain/common/wallet_type.dart';
|
||||
import 'package:cake_wallet/src/domain/common/digest_request.dart';
|
||||
import 'package:cake_wallet/entities/wallet_type.dart';
|
||||
import 'package:cake_wallet/entities/digest_request.dart';
|
||||
|
||||
part 'node.g.dart';
|
||||
|
|
@ -1,8 +1,8 @@
|
|||
import 'package:flutter/services.dart';
|
||||
import 'package:hive/hive.dart';
|
||||
import "package:yaml/yaml.dart";
|
||||
import 'package:cake_wallet/src/domain/common/node.dart';
|
||||
import 'package:cake_wallet/src/domain/common/wallet_type.dart';
|
||||
import 'package:cake_wallet/entities/node.dart';
|
||||
import 'package:cake_wallet/entities/wallet_type.dart';
|
||||
|
||||
Future<List<Node>> loadDefaultNodes() async {
|
||||
final nodesRaw = await rootBundle.loadString('assets/node_list.yml');
|
|
@ -1,5 +1,5 @@
|
|||
import 'dart:io';
|
||||
import 'package:cake_wallet/src/domain/common/wallet_type.dart';
|
||||
import 'package:cake_wallet/entities/wallet_type.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:path_provider/path_provider.dart';
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
import 'package:flutter/foundation.dart';
|
||||
import 'package:cw_monero/transaction_history.dart' as transaction_history;
|
||||
import 'package:cw_monero/structs/pending_transaction.dart';
|
||||
import 'package:cake_wallet/src/domain/monero/monero_amount_format.dart';
|
||||
import 'package:cake_wallet/monero/monero_amount_format.dart';
|
||||
|
||||
class PendingTransaction {
|
||||
PendingTransaction(
|
16
lib/entities/preferences_key.dart
Normal file
16
lib/entities/preferences_key.dart
Normal file
|
@ -0,0 +1,16 @@
|
|||
class PreferencesKey {
|
||||
static const currentWalletType ='current_wallet_type';
|
||||
static const currentWalletName ='current_wallet_name';
|
||||
static const currentNodeIdKey = 'current_node_id';
|
||||
static const currentBitcoinElectrumSererIdKey = 'current_node_id_btc';
|
||||
static const currentFiatCurrencyKey = 'current_fiat_currency';
|
||||
static const currentTransactionPriorityKey = 'current_fee_priority';
|
||||
static const currentBalanceDisplayModeKey = 'current_balance_display_mode';
|
||||
static const shouldSaveRecipientAddressKey = 'save_recipient_address';
|
||||
static const allowBiometricalAuthenticationKey =
|
||||
'allow_biometrical_authentication';
|
||||
static const currentDarkTheme = 'dark_theme';
|
||||
static const displayActionListModeKey = 'display_list_mode';
|
||||
static const currentPinLength = 'current_pin_length';
|
||||
static const currentLanguageCode = 'language_code';
|
||||
}
|
|
@ -7,6 +7,7 @@ class TransactionDescription extends HiveObject {
|
|||
TransactionDescription({this.id, this.recipientAddress});
|
||||
|
||||
static const boxName = 'TransactionDescriptions';
|
||||
static const boxKey = 'transactionDescriptionsBoxKey';
|
||||
|
||||
@HiveField(0)
|
||||
String id;
|
|
@ -1,5 +1,5 @@
|
|||
import 'package:rxdart/rxdart.dart';
|
||||
import 'package:cake_wallet/src/domain/common/transaction_info.dart';
|
||||
import 'package:cake_wallet/entities/transaction_info.dart';
|
||||
|
||||
abstract class TransactionHistory {
|
||||
Observable<List<TransactionInfo>> transactions;
|
|
@ -1,4 +1,4 @@
|
|||
import 'package:cake_wallet/src/domain/common/transaction_direction.dart';
|
||||
import 'package:cake_wallet/entities/transaction_direction.dart';
|
||||
|
||||
abstract class TransactionInfo extends Object {
|
||||
String id;
|
|
@ -1,5 +1,5 @@
|
|||
import 'package:cake_wallet/generated/i18n.dart';
|
||||
import 'package:cake_wallet/src/domain/common/enumerable_item.dart';
|
||||
import 'package:cake_wallet/entities/enumerable_item.dart';
|
||||
|
||||
class TransactionPriority extends EnumerableItem<int> with Serializable<int> {
|
||||
const TransactionPriority({String title, int raw})
|
|
@ -1,11 +1,11 @@
|
|||
import 'package:rxdart/rxdart.dart';
|
||||
import 'package:cake_wallet/src/domain/common/sync_status.dart';
|
||||
import 'package:cake_wallet/src/domain/common/transaction_history.dart';
|
||||
import 'package:cake_wallet/src/domain/common/wallet_type.dart';
|
||||
import 'package:cake_wallet/src/domain/common/transaction_creation_credentials.dart';
|
||||
import 'package:cake_wallet/src/domain/common/pending_transaction.dart';
|
||||
import 'package:cake_wallet/src/domain/common/balance.dart';
|
||||
import 'package:cake_wallet/src/domain/common/node.dart';
|
||||
import 'package:cake_wallet/entities/sync_status.dart';
|
||||
import 'package:cake_wallet/entities/transaction_history.dart';
|
||||
import 'package:cake_wallet/entities/wallet_type.dart';
|
||||
import 'package:cake_wallet/entities/transaction_creation_credentials.dart';
|
||||
import 'package:cake_wallet/entities/pending_transaction.dart';
|
||||
import 'package:cake_wallet/entities/balance.dart';
|
||||
import 'package:cake_wallet/entities/node.dart';
|
||||
|
||||
abstract class Wallet {
|
||||
WalletType getType();
|
|
@ -1,4 +1,4 @@
|
|||
import 'package:cake_wallet/src/domain/common/wallet_type.dart';
|
||||
import 'package:cake_wallet/entities/wallet_type.dart';
|
||||
|
||||
class WalletDescription {
|
||||
WalletDescription({this.name, this.type});
|
|
@ -1,6 +1,6 @@
|
|||
import 'package:flutter/foundation.dart';
|
||||
import 'package:hive/hive.dart';
|
||||
import 'package:cake_wallet/src/domain/common/wallet_type.dart';
|
||||
import 'package:cake_wallet/entities/wallet_type.dart';
|
||||
|
||||
part 'wallet_info.g.dart';
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
import 'package:cake_wallet/src/domain/common/wallet.dart';
|
||||
import 'package:cake_wallet/src/domain/common/wallet_description.dart';
|
||||
import 'package:cake_wallet/entities/wallet.dart';
|
||||
import 'package:cake_wallet/entities/wallet_description.dart';
|
||||
|
||||
abstract class WalletsManager {
|
||||
Future<Wallet> create(String name, String password, String language);
|
|
@ -1,18 +1,18 @@
|
|||
import 'dart:convert';
|
||||
import 'package:cake_wallet/src/domain/exchange/trade_not_found_exeption.dart';
|
||||
import 'package:cake_wallet/exchange/trade_not_found_exeption.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:http/http.dart';
|
||||
import 'package:cake_wallet/.secrets.g.dart' as secrets;
|
||||
import 'package:cake_wallet/src/domain/common/crypto_currency.dart';
|
||||
import 'package:cake_wallet/src/domain/exchange/exchange_pair.dart';
|
||||
import 'package:cake_wallet/src/domain/exchange/exchange_provider.dart';
|
||||
import 'package:cake_wallet/src/domain/exchange/limits.dart';
|
||||
import 'package:cake_wallet/src/domain/exchange/trade.dart';
|
||||
import 'package:cake_wallet/src/domain/exchange/trade_request.dart';
|
||||
import 'package:cake_wallet/src/domain/exchange/trade_state.dart';
|
||||
import 'package:cake_wallet/src/domain/exchange/changenow/changenow_request.dart';
|
||||
import 'package:cake_wallet/src/domain/exchange/exchange_provider_description.dart';
|
||||
import 'package:cake_wallet/src/domain/exchange/trade_not_created_exeption.dart';
|
||||
import 'package:cake_wallet/entities/crypto_currency.dart';
|
||||
import 'package:cake_wallet/exchange/exchange_pair.dart';
|
||||
import 'package:cake_wallet/exchange/exchange_provider.dart';
|
||||
import 'package:cake_wallet/exchange/limits.dart';
|
||||
import 'package:cake_wallet/exchange/trade.dart';
|
||||
import 'package:cake_wallet/exchange/trade_request.dart';
|
||||
import 'package:cake_wallet/exchange/trade_state.dart';
|
||||
import 'package:cake_wallet/exchange/changenow/changenow_request.dart';
|
||||
import 'package:cake_wallet/exchange/exchange_provider_description.dart';
|
||||
import 'package:cake_wallet/exchange/trade_not_created_exeption.dart';
|
||||
|
||||
class ChangeNowExchangeProvider extends ExchangeProvider {
|
||||
ChangeNowExchangeProvider()
|
|
@ -1,6 +1,6 @@
|
|||
import 'package:flutter/foundation.dart';
|
||||
import 'package:cake_wallet/src/domain/common/crypto_currency.dart';
|
||||
import 'package:cake_wallet/src/domain/exchange/trade_request.dart';
|
||||
import 'package:cake_wallet/entities/crypto_currency.dart';
|
||||
import 'package:cake_wallet/exchange/trade_request.dart';
|
||||
|
||||
class ChangeNowRequest extends TradeRequest {
|
||||
ChangeNowRequest(
|
|
@ -1,4 +1,4 @@
|
|||
import 'package:cake_wallet/src/domain/common/crypto_currency.dart';
|
||||
import 'package:cake_wallet/entities/crypto_currency.dart';
|
||||
|
||||
class ExchangePair {
|
||||
ExchangePair({this.from, this.to, this.reverse = true});
|
|
@ -1,10 +1,10 @@
|
|||
import 'package:flutter/foundation.dart';
|
||||
import 'package:cake_wallet/src/domain/common/crypto_currency.dart';
|
||||
import 'package:cake_wallet/src/domain/exchange/trade_request.dart';
|
||||
import 'package:cake_wallet/src/domain/exchange/exchange_pair.dart';
|
||||
import 'package:cake_wallet/src/domain/exchange/limits.dart';
|
||||
import 'package:cake_wallet/src/domain/exchange/trade.dart';
|
||||
import 'package:cake_wallet/src/domain/exchange/exchange_provider_description.dart';
|
||||
import 'package:cake_wallet/entities/crypto_currency.dart';
|
||||
import 'package:cake_wallet/exchange/trade_request.dart';
|
||||
import 'package:cake_wallet/exchange/exchange_pair.dart';
|
||||
import 'package:cake_wallet/exchange/limits.dart';
|
||||
import 'package:cake_wallet/exchange/trade.dart';
|
||||
import 'package:cake_wallet/exchange/exchange_provider_description.dart';
|
||||
|
||||
abstract class ExchangeProvider {
|
||||
ExchangeProvider({this.pairList});
|
|
@ -1,4 +1,4 @@
|
|||
import 'package:cake_wallet/src/domain/common/enumerable_item.dart';
|
||||
import 'package:cake_wallet/entities/enumerable_item.dart';
|
||||
|
||||
class ExchangeProviderDescription extends EnumerableItem<int>
|
||||
with Serializable<int> {
|
|
@ -1,5 +1,5 @@
|
|||
import 'package:flutter/foundation.dart';
|
||||
import 'package:cake_wallet/src/domain/exchange/trade.dart';
|
||||
import 'package:cake_wallet/exchange/trade.dart';
|
||||
|
||||
abstract class ExchangeTradeState {}
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
import 'package:flutter/foundation.dart';
|
||||
import 'package:cake_wallet/src/domain/exchange/limits.dart';
|
||||
import 'package:cake_wallet/exchange/limits.dart';
|
||||
|
||||
abstract class LimitsState {}
|
||||
|
202
lib/exchange/morphtoken/morphtoken_exchange_provider.dart
Normal file
202
lib/exchange/morphtoken/morphtoken_exchange_provider.dart
Normal file
|
@ -0,0 +1,202 @@
|
|||
import 'dart:convert';
|
||||
import 'package:cake_wallet/core/amount_converter.dart';
|
||||
import 'package:cake_wallet/monero/monero_amount_format.dart';
|
||||
import 'package:hive/hive.dart';
|
||||
import 'package:cake_wallet/exchange/trade_not_found_exeption.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:http/http.dart';
|
||||
import 'package:cake_wallet/entities/crypto_currency.dart';
|
||||
import 'package:cake_wallet/exchange/exchange_pair.dart';
|
||||
import 'package:cake_wallet/exchange/exchange_provider.dart';
|
||||
import 'package:cake_wallet/exchange/limits.dart';
|
||||
import 'package:cake_wallet/exchange/trade.dart';
|
||||
import 'package:cake_wallet/exchange/trade_request.dart';
|
||||
import 'package:cake_wallet/exchange/trade_state.dart';
|
||||
import 'package:cake_wallet/exchange/morphtoken/morphtoken_request.dart';
|
||||
import 'package:cake_wallet/exchange/exchange_provider_description.dart';
|
||||
import 'package:cake_wallet/exchange/trade_not_created_exeption.dart';
|
||||
|
||||
class MorphTokenExchangeProvider extends ExchangeProvider {
|
||||
MorphTokenExchangeProvider({@required this.trades})
|
||||
: super(pairList: [
|
||||
ExchangePair(from: CryptoCurrency.xmr, to: CryptoCurrency.eth),
|
||||
ExchangePair(from: CryptoCurrency.xmr, to: CryptoCurrency.bch),
|
||||
ExchangePair(from: CryptoCurrency.xmr, to: CryptoCurrency.ltc),
|
||||
ExchangePair(from: CryptoCurrency.xmr, to: CryptoCurrency.dash),
|
||||
ExchangePair(from: CryptoCurrency.dash, to: CryptoCurrency.btc),
|
||||
ExchangePair(from: CryptoCurrency.dash, to: CryptoCurrency.eth),
|
||||
ExchangePair(from: CryptoCurrency.dash, to: CryptoCurrency.bch),
|
||||
ExchangePair(from: CryptoCurrency.dash, to: CryptoCurrency.ltc),
|
||||
ExchangePair(from: CryptoCurrency.dash, to: CryptoCurrency.xmr),
|
||||
ExchangePair(from: CryptoCurrency.ltc, to: CryptoCurrency.btc),
|
||||
ExchangePair(from: CryptoCurrency.ltc, to: CryptoCurrency.eth),
|
||||
ExchangePair(from: CryptoCurrency.ltc, to: CryptoCurrency.bch),
|
||||
ExchangePair(from: CryptoCurrency.ltc, to: CryptoCurrency.dash),
|
||||
ExchangePair(from: CryptoCurrency.ltc, to: CryptoCurrency.xmr),
|
||||
ExchangePair(from: CryptoCurrency.bch, to: CryptoCurrency.btc),
|
||||
ExchangePair(from: CryptoCurrency.bch, to: CryptoCurrency.eth),
|
||||
ExchangePair(from: CryptoCurrency.bch, to: CryptoCurrency.ltc),
|
||||
ExchangePair(from: CryptoCurrency.bch, to: CryptoCurrency.dash),
|
||||
ExchangePair(from: CryptoCurrency.bch, to: CryptoCurrency.xmr),
|
||||
ExchangePair(from: CryptoCurrency.eth, to: CryptoCurrency.btc),
|
||||
ExchangePair(from: CryptoCurrency.eth, to: CryptoCurrency.bch),
|
||||
ExchangePair(from: CryptoCurrency.eth, to: CryptoCurrency.ltc),
|
||||
ExchangePair(from: CryptoCurrency.eth, to: CryptoCurrency.dash),
|
||||
ExchangePair(from: CryptoCurrency.eth, to: CryptoCurrency.xmr),
|
||||
ExchangePair(from: CryptoCurrency.btc, to: CryptoCurrency.eth),
|
||||
ExchangePair(from: CryptoCurrency.btc, to: CryptoCurrency.bch),
|
||||
ExchangePair(from: CryptoCurrency.btc, to: CryptoCurrency.ltc),
|
||||
ExchangePair(from: CryptoCurrency.btc, to: CryptoCurrency.dash),
|
||||
ExchangePair(from: CryptoCurrency.btc, to: CryptoCurrency.xmr)
|
||||
]);
|
||||
|
||||
Box<Trade> trades;
|
||||
|
||||
static const apiUri = 'https://api.morphtoken.com';
|
||||
static const _morphURISuffix = '/morph';
|
||||
static const _limitsURISuffix = '/limits';
|
||||
static const _ratesURISuffix = '/rates';
|
||||
static const weight = 10000;
|
||||
|
||||
@override
|
||||
String get title => 'MorphToken';
|
||||
|
||||
@override
|
||||
ExchangeProviderDescription get description =>
|
||||
ExchangeProviderDescription.morphToken;
|
||||
|
||||
@override
|
||||
Future<Limits> fetchLimits({CryptoCurrency from, CryptoCurrency to}) async {
|
||||
final url = apiUri + _limitsURISuffix;
|
||||
final headers = {'Content-type': 'application/json'};
|
||||
final body = json.encode({
|
||||
"input": {"asset": from.toString()},
|
||||
"output": [
|
||||
{"asset": to.toString(), "weight": weight}
|
||||
]
|
||||
});
|
||||
final response = await post(url, headers: headers, body: body);
|
||||
final responseJSON = json.decode(response.body) as Map<String, dynamic>;
|
||||
|
||||
final min = responseJSON['input']['limits']['min'] as int;
|
||||
int max;
|
||||
double ethMax;
|
||||
|
||||
if (from == CryptoCurrency.eth) {
|
||||
ethMax = responseJSON['input']['limits']['max'] as double;
|
||||
} else {
|
||||
max = responseJSON['input']['limits']['max'] as int;
|
||||
}
|
||||
|
||||
double minFormatted = AmountConverter.amountIntToDouble(from, min);
|
||||
double maxFormatted = AmountConverter.amountIntToDouble(from, max);
|
||||
|
||||
return Limits(min: minFormatted, max: maxFormatted);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<Trade> createTrade({TradeRequest request}) async {
|
||||
const url = apiUri + _morphURISuffix;
|
||||
final _request = request as MorphTokenRequest;
|
||||
final body = {
|
||||
"input": {
|
||||
"asset": _request.from.toString(),
|
||||
"refund": _request.refundAddress
|
||||
},
|
||||
"output": [
|
||||
{
|
||||
"asset": _request.to.toString(),
|
||||
"weight": weight,
|
||||
"address": _request.address
|
||||
}
|
||||
],
|
||||
"tag": "cakewallet"
|
||||
};
|
||||
|
||||
final response = await post(url,
|
||||
headers: {'Content-Type': 'application/json'}, body: json.encode(body));
|
||||
|
||||
if (response.statusCode != 200) {
|
||||
if (response.statusCode == 400) {
|
||||
final responseJSON = json.decode(response.body) as Map<String, dynamic>;
|
||||
final error = responseJSON['description'] as String;
|
||||
|
||||
throw TradeNotCreatedException(description, description: error);
|
||||
}
|
||||
|
||||
throw TradeNotCreatedException(description);
|
||||
}
|
||||
|
||||
final responseJSON = json.decode(response.body) as Map<String, dynamic>;
|
||||
final id = responseJSON['id'] as String;
|
||||
|
||||
return Trade(
|
||||
id: id,
|
||||
provider: description,
|
||||
from: _request.from,
|
||||
to: _request.to,
|
||||
state: TradeState.created,
|
||||
amount: _request.amount,
|
||||
createdAt: DateTime.now());
|
||||
}
|
||||
|
||||
@override
|
||||
Future<Trade> findTradeById({@required String id}) async {
|
||||
final url = apiUri + _morphURISuffix + '/' + id;
|
||||
final response = await get(url);
|
||||
|
||||
if (response.statusCode != 200) {
|
||||
if (response.statusCode == 400) {
|
||||
final responseJSON = json.decode(response.body) as Map<String, dynamic>;
|
||||
final error = responseJSON['description'] as String;
|
||||
|
||||
throw TradeNotFoundException(id,
|
||||
provider: description, description: error);
|
||||
}
|
||||
|
||||
throw TradeNotFoundException(id, provider: description);
|
||||
}
|
||||
|
||||
final responseJSON = json.decode(response.body) as Map<String, dynamic>;
|
||||
final fromCurrency = responseJSON['input']['asset'] as String;
|
||||
final from = CryptoCurrency.fromString(fromCurrency.toLowerCase());
|
||||
final toCurrency = responseJSON['output'][0]['asset'] as String;
|
||||
final to = CryptoCurrency.fromString(toCurrency.toLowerCase());
|
||||
final inputAddress = responseJSON['input']['deposit_address'] as String;
|
||||
final status = responseJSON['state'] as String;
|
||||
final state = TradeState.deserialize(raw: status.toLowerCase());
|
||||
|
||||
String amount = "";
|
||||
for (final trade in trades.values) {
|
||||
if (trade.id == id) {
|
||||
amount = trade.amount;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return Trade(
|
||||
id: id,
|
||||
from: from,
|
||||
to: to,
|
||||
provider: description,
|
||||
inputAddress: inputAddress,
|
||||
amount: amount,
|
||||
state: state);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<double> calculateAmount(
|
||||
{CryptoCurrency from, CryptoCurrency to, double amount}) async {
|
||||
final url = apiUri + _ratesURISuffix;
|
||||
final response = await get(url);
|
||||
final responseJSON = json.decode(response.body) as Map<String, dynamic>;
|
||||
final rate = responseJSON['data'][from.toString()][to.toString()] as String;
|
||||
|
||||
try {
|
||||
final estimatedAmount = double.parse(rate) * amount;
|
||||
return estimatedAmount;
|
||||
} catch (e) {
|
||||
return 0.0;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
import 'package:flutter/foundation.dart';
|
||||
import 'package:cake_wallet/src/domain/common/crypto_currency.dart';
|
||||
import 'package:cake_wallet/src/domain/exchange/trade_request.dart';
|
||||
import 'package:cake_wallet/entities/crypto_currency.dart';
|
||||
import 'package:cake_wallet/exchange/trade_request.dart';
|
||||
|
||||
class MorphTokenRequest extends TradeRequest {
|
||||
MorphTokenRequest(
|
|
@ -1,8 +1,8 @@
|
|||
import 'package:hive/hive.dart';
|
||||
import 'package:cake_wallet/src/domain/common/crypto_currency.dart';
|
||||
import 'package:cake_wallet/src/domain/exchange/exchange_provider_description.dart';
|
||||
import 'package:cake_wallet/src/domain/exchange/trade_state.dart';
|
||||
import 'package:cake_wallet/src/domain/common/format_amount.dart';
|
||||
import 'package:cake_wallet/entities/crypto_currency.dart';
|
||||
import 'package:cake_wallet/exchange/exchange_provider_description.dart';
|
||||
import 'package:cake_wallet/exchange/trade_state.dart';
|
||||
import 'package:cake_wallet/entities/format_amount.dart';
|
||||
|
||||
part 'trade.g.dart';
|
||||
|
||||
|
@ -28,6 +28,7 @@ class Trade extends HiveObject {
|
|||
stateRaw = state?.raw;
|
||||
|
||||
static const boxName = 'Trades';
|
||||
static const boxKey = 'tradesBoxKey';
|
||||
|
||||
@HiveField(0)
|
||||
String id;
|
|
@ -1,4 +1,4 @@
|
|||
import 'package:cake_wallet/src/domain/exchange/exchange_provider_description.dart';
|
||||
import 'package:cake_wallet/exchange/exchange_provider_description.dart';
|
||||
import 'package:cake_wallet/generated/i18n.dart';
|
||||
|
||||
class TradeNotCreatedException implements Exception {
|
|
@ -1,4 +1,4 @@
|
|||
import 'package:cake_wallet/src/domain/exchange/exchange_provider_description.dart';
|
||||
import 'package:cake_wallet/exchange/exchange_provider_description.dart';
|
||||
import 'package:cake_wallet/generated/i18n.dart';
|
||||
|
||||
class TradeNotFoundException implements Exception {
|
|
@ -1,5 +1,5 @@
|
|||
import 'package:flutter/foundation.dart';
|
||||
import 'package:cake_wallet/src/domain/common/enumerable_item.dart';
|
||||
import 'package:cake_wallet/entities/enumerable_item.dart';
|
||||
|
||||
class TradeState extends EnumerableItem<String> with Serializable<String> {
|
||||
const TradeState({@required String raw, @required String title})
|
|
@ -1,17 +1,17 @@
|
|||
import 'dart:convert';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:http/http.dart';
|
||||
import 'package:cake_wallet/src/domain/common/crypto_currency.dart';
|
||||
import 'package:cake_wallet/src/domain/exchange/exchange_pair.dart';
|
||||
import 'package:cake_wallet/src/domain/exchange/exchange_provider.dart';
|
||||
import 'package:cake_wallet/src/domain/exchange/limits.dart';
|
||||
import 'package:cake_wallet/src/domain/exchange/trade.dart';
|
||||
import 'package:cake_wallet/src/domain/exchange/trade_request.dart';
|
||||
import 'package:cake_wallet/src/domain/exchange/trade_state.dart';
|
||||
import 'package:cake_wallet/src/domain/exchange/xmrto/xmrto_trade_request.dart';
|
||||
import 'package:cake_wallet/src/domain/exchange/trade_not_created_exeption.dart';
|
||||
import 'package:cake_wallet/src/domain/exchange/exchange_provider_description.dart';
|
||||
import 'package:cake_wallet/src/domain/exchange/trade_not_found_exeption.dart';
|
||||
import 'package:cake_wallet/entities/crypto_currency.dart';
|
||||
import 'package:cake_wallet/exchange/exchange_pair.dart';
|
||||
import 'package:cake_wallet/exchange/exchange_provider.dart';
|
||||
import 'package:cake_wallet/exchange/limits.dart';
|
||||
import 'package:cake_wallet/exchange/trade.dart';
|
||||
import 'package:cake_wallet/exchange/trade_request.dart';
|
||||
import 'package:cake_wallet/exchange/trade_state.dart';
|
||||
import 'package:cake_wallet/exchange/xmrto/xmrto_trade_request.dart';
|
||||
import 'package:cake_wallet/exchange/trade_not_created_exeption.dart';
|
||||
import 'package:cake_wallet/exchange/exchange_provider_description.dart';
|
||||
import 'package:cake_wallet/exchange/trade_not_found_exeption.dart';
|
||||
|
||||
class XMRTOExchangeProvider extends ExchangeProvider {
|
||||
XMRTOExchangeProvider()
|
|
@ -1,6 +1,6 @@
|
|||
import 'package:flutter/foundation.dart';
|
||||
import 'package:cake_wallet/src/domain/common/crypto_currency.dart';
|
||||
import 'package:cake_wallet/src/domain/exchange/trade_request.dart';
|
||||
import 'package:cake_wallet/entities/crypto_currency.dart';
|
||||
import 'package:cake_wallet/exchange/trade_request.dart';
|
||||
|
||||
class XMRTOTradeRequest extends TradeRequest {
|
||||
XMRTOTradeRequest(
|
232
lib/main.dart
232
lib/main.dart
|
@ -1,3 +1,5 @@
|
|||
import 'package:cake_wallet/entities/transaction_description.dart';
|
||||
import 'package:cake_wallet/entities/transaction_description.dart';
|
||||
import 'package:cake_wallet/reactions/bootstrap.dart';
|
||||
import 'package:cake_wallet/routes.dart';
|
||||
import 'package:cake_wallet/store/app_store.dart';
|
||||
|
@ -21,38 +23,41 @@ import 'package:cw_monero/wallet.dart' as monero_wallet;
|
|||
import 'package:cake_wallet/router.dart';
|
||||
import 'theme_changer.dart';
|
||||
import 'themes.dart';
|
||||
import 'package:cake_wallet/src/domain/common/get_encryption_key.dart';
|
||||
import 'package:cake_wallet/src/domain/common/contact.dart';
|
||||
import 'package:cake_wallet/src/domain/common/node.dart';
|
||||
import 'package:cake_wallet/src/domain/common/wallet_info.dart';
|
||||
import 'package:cake_wallet/src/domain/exchange/trade.dart';
|
||||
import 'package:cake_wallet/src/domain/monero/transaction_description.dart';
|
||||
import 'package:cake_wallet/entities/get_encryption_key.dart';
|
||||
import 'package:cake_wallet/entities/contact.dart';
|
||||
import 'package:cake_wallet/entities/node.dart';
|
||||
import 'package:cake_wallet/entities/wallet_info.dart';
|
||||
import 'package:cake_wallet/exchange/trade.dart';
|
||||
|
||||
// import 'package:cake_wallet/monero/transaction_description.dart';
|
||||
import 'package:cake_wallet/src/reactions/set_reactions.dart';
|
||||
import 'package:cake_wallet/src/stores/login/login_store.dart';
|
||||
import 'package:cake_wallet/src/stores/balance/balance_store.dart';
|
||||
import 'package:cake_wallet/src/stores/sync/sync_store.dart';
|
||||
import 'package:cake_wallet/src/stores/wallet/wallet_store.dart';
|
||||
import 'package:cake_wallet/src/stores/send_template/send_template_store.dart';
|
||||
import 'package:cake_wallet/src/stores/exchange_template/exchange_template_store.dart';
|
||||
|
||||
// import 'package:cake_wallet/src/stores/login/login_store.dart';
|
||||
// import 'package:cake_wallet/src/stores/balance/balance_store.dart';
|
||||
// import 'package:cake_wallet/src/stores/sync/sync_store.dart';
|
||||
// import 'package:cake_wallet/src/stores/wallet/wallet_store.dart';
|
||||
// import 'package:cake_wallet/src/stores/send_template/send_template_store.dart';
|
||||
// import 'package:cake_wallet/src/stores/exchange_template/exchange_template_store.dart';
|
||||
import 'package:cake_wallet/src/screens/root/root.dart';
|
||||
|
||||
//import 'package:cake_wallet/src/stores/authentication/authentication_store.dart';
|
||||
import 'package:cake_wallet/src/stores/settings/settings_store.dart';
|
||||
import 'package:cake_wallet/src/stores/price/price_store.dart';
|
||||
import 'package:cake_wallet/src/domain/services/user_service.dart';
|
||||
import 'package:cake_wallet/src/domain/services/wallet_list_service.dart';
|
||||
import 'package:cake_wallet/src/domain/common/balance_display_mode.dart';
|
||||
import 'package:cake_wallet/src/domain/common/default_settings_migration.dart';
|
||||
import 'package:cake_wallet/src/domain/common/fiat_currency.dart';
|
||||
import 'package:cake_wallet/src/domain/common/transaction_priority.dart';
|
||||
import 'package:cake_wallet/src/domain/common/wallet_type.dart';
|
||||
import 'package:cake_wallet/src/domain/common/template.dart';
|
||||
import 'package:cake_wallet/src/domain/exchange/exchange_template.dart';
|
||||
import 'package:cake_wallet/src/domain/services/wallet_service.dart';
|
||||
import 'package:cake_wallet/src/domain/services/fiat_convertation_service.dart';
|
||||
// import 'package:cake_wallet/src/stores/settings/settings_store.dart';
|
||||
// import 'package:cake_wallet/src/stores/price/price_store.dart';
|
||||
// import 'package:cake_wallet/src/domain/services/user_service.dart';
|
||||
// import 'package:cake_wallet/src/domain/services/wallet_list_service.dart';
|
||||
import 'package:cake_wallet/entities/balance_display_mode.dart';
|
||||
import 'package:cake_wallet/entities/default_settings_migration.dart';
|
||||
import 'package:cake_wallet/entities/fiat_currency.dart';
|
||||
import 'package:cake_wallet/entities/transaction_priority.dart';
|
||||
import 'package:cake_wallet/entities/wallet_type.dart';
|
||||
import 'package:cake_wallet/entities/template.dart';
|
||||
import 'package:cake_wallet/exchange/exchange_template.dart';
|
||||
|
||||
// import 'package:cake_wallet/src/domain/services/wallet_service.dart';
|
||||
// import 'package:cake_wallet/src/domain/services/fiat_convertation_service.dart';
|
||||
import 'package:cake_wallet/generated/i18n.dart';
|
||||
import 'package:cake_wallet/src/domain/common/language.dart';
|
||||
import 'package:cake_wallet/src/stores/seed_language/seed_language_store.dart';
|
||||
import 'package:cake_wallet/entities/language.dart';
|
||||
// import 'package:cake_wallet/src/stores/seed_language/seed_language_store.dart';
|
||||
|
||||
bool isThemeChangerRegistered = false;
|
||||
|
||||
|
@ -74,12 +79,9 @@ void main() async {
|
|||
|
||||
final secureStorage = FlutterSecureStorage();
|
||||
final transactionDescriptionsBoxKey = await getEncryptionKey(
|
||||
secureStorage: secureStorage,
|
||||
forKey: 'transactionDescriptionsBoxKey'); // FIXME: Unnamed constant
|
||||
secureStorage: secureStorage, forKey: TransactionDescription.boxKey);
|
||||
final tradesBoxKey = await getEncryptionKey(
|
||||
secureStorage: secureStorage,
|
||||
forKey: 'tradesBoxKey'); // FIXME: Unnamed constant
|
||||
|
||||
secureStorage: secureStorage, forKey: Trade.boxKey);
|
||||
final contacts = await Hive.openBox<Contact>(Contact.boxName);
|
||||
final nodes = await Hive.openBox<Node>(Node.boxName);
|
||||
final transactionDescriptions = await Hive.openBox<TransactionDescription>(
|
||||
|
@ -93,35 +95,35 @@ void main() async {
|
|||
await Hive.openBox<ExchangeTemplate>(ExchangeTemplate.boxName);
|
||||
|
||||
final sharedPreferences = await SharedPreferences.getInstance();
|
||||
final walletService = WalletService();
|
||||
final fiatConvertationService = FiatConvertationService();
|
||||
final walletListService = WalletListService(
|
||||
secureStorage: secureStorage,
|
||||
walletInfoSource: walletInfoSource,
|
||||
walletService: walletService,
|
||||
sharedPreferences: sharedPreferences);
|
||||
final userService = UserService(
|
||||
sharedPreferences: sharedPreferences, secureStorage: secureStorage);
|
||||
final settingsStore = await SettingsStoreBase.load(
|
||||
nodes: nodes,
|
||||
sharedPreferences: sharedPreferences,
|
||||
initialFiatCurrency: FiatCurrency.usd,
|
||||
initialTransactionPriority: TransactionPriority.slow,
|
||||
initialBalanceDisplayMode: BalanceDisplayMode.availableBalance);
|
||||
final priceStore = PriceStore();
|
||||
final walletStore =
|
||||
WalletStore(walletService: walletService, settingsStore: settingsStore);
|
||||
final syncStore = SyncStore(walletService: walletService);
|
||||
final balanceStore = BalanceStore(
|
||||
walletService: walletService,
|
||||
settingsStore: settingsStore,
|
||||
priceStore: priceStore);
|
||||
final loginStore = LoginStore(
|
||||
sharedPreferences: sharedPreferences, walletsService: walletListService);
|
||||
final seedLanguageStore = SeedLanguageStore();
|
||||
final sendTemplateStore = SendTemplateStore(templateSource: templates);
|
||||
final exchangeTemplateStore =
|
||||
ExchangeTemplateStore(templateSource: exchangeTemplates);
|
||||
// final walletService = WalletService();
|
||||
// final fiatConvertationService = FiatConvertationService();
|
||||
// final walletListService = WalletListService(
|
||||
// secureStorage: secureStorage,
|
||||
// walletInfoSource: walletInfoSource,
|
||||
// walletService: walletService,
|
||||
// sharedPreferences: sharedPreferences);
|
||||
// final userService = UserService(
|
||||
// sharedPreferences: sharedPreferences, secureStorage: secureStorage);
|
||||
// final settingsStore = await SettingsStoreBase.load(
|
||||
// nodes: nodes,
|
||||
// sharedPreferences: sharedPreferences,
|
||||
// initialFiatCurrency: FiatCurrency.usd,
|
||||
// initialTransactionPriority: TransactionPriority.slow,
|
||||
// initialBalanceDisplayMode: BalanceDisplayMode.availableBalance);
|
||||
// final priceStore = PriceStore();
|
||||
// final walletStore =
|
||||
// WalletStore(walletService: walletService, settingsStore: settingsStore);
|
||||
// final syncStore = SyncStore(walletService: walletService);
|
||||
// final balanceStore = BalanceStore(
|
||||
// walletService: walletService,
|
||||
// settingsStore: settingsStore,
|
||||
// priceStore: priceStore);
|
||||
// final loginStore = LoginStore(
|
||||
// sharedPreferences: sharedPreferences, walletsService: walletListService);
|
||||
// final seedLanguageStore = SeedLanguageStore();
|
||||
// final sendTemplateStore = SendTemplateStore(templateSource: templates);
|
||||
// final exchangeTemplateStore =
|
||||
// ExchangeTemplateStore(templateSource: exchangeTemplates);
|
||||
|
||||
final walletCreationService = WalletCreationService();
|
||||
final authService = AuthService();
|
||||
|
@ -132,42 +134,21 @@ void main() async {
|
|||
walletInfoSource: walletInfoSource,
|
||||
contactSource: contacts,
|
||||
tradesSource: trades,
|
||||
fiatConvertationService: fiatConvertationService,
|
||||
// fiatConvertationService: fiatConvertationService,
|
||||
templates: templates,
|
||||
exchangeTemplates: exchangeTemplates,
|
||||
initialMigrationVersion: 4);
|
||||
|
||||
setReactions(
|
||||
settingsStore: settingsStore,
|
||||
priceStore: priceStore,
|
||||
syncStore: syncStore,
|
||||
walletStore: walletStore,
|
||||
walletService: walletService,
|
||||
// authenticationStore: authenticationStore,
|
||||
loginStore: loginStore);
|
||||
// setReactions(
|
||||
// settingsStore: settingsStore,
|
||||
// priceStore: priceStore,
|
||||
// syncStore: syncStore,
|
||||
// walletStore: walletStore,
|
||||
// walletService: walletService,
|
||||
// // authenticationStore: authenticationStore,
|
||||
// loginStore: loginStore);
|
||||
|
||||
runApp(MultiProvider(providers: [
|
||||
Provider(create: (_) => sharedPreferences),
|
||||
Provider(create: (_) => walletService),
|
||||
Provider(create: (_) => walletListService),
|
||||
Provider(create: (_) => userService),
|
||||
Provider(create: (_) => settingsStore),
|
||||
Provider(create: (_) => priceStore),
|
||||
Provider(create: (_) => walletStore),
|
||||
Provider(create: (_) => syncStore),
|
||||
Provider(create: (_) => balanceStore),
|
||||
// Provider(create: (_) => authenticationStore),
|
||||
Provider(create: (_) => contacts),
|
||||
Provider(create: (_) => nodes),
|
||||
Provider(create: (_) => transactionDescriptions),
|
||||
Provider(create: (_) => trades),
|
||||
Provider(create: (_) => seedLanguageStore),
|
||||
Provider(create: (_) => sendTemplateStore),
|
||||
Provider(create: (_) => exchangeTemplateStore),
|
||||
// Provider(create: (_) => appStore),
|
||||
Provider(create: (_) => walletCreationService),
|
||||
Provider(create: (_) => authService)
|
||||
], child: CakeWalletApp()));
|
||||
runApp(CakeWalletApp());
|
||||
}
|
||||
|
||||
Future<void> initialSetup(
|
||||
|
@ -176,7 +157,7 @@ Future<void> initialSetup(
|
|||
@required Box<WalletInfo> walletInfoSource,
|
||||
@required Box<Contact> contactSource,
|
||||
@required Box<Trade> tradesSource,
|
||||
@required FiatConvertationService fiatConvertationService,
|
||||
// @required FiatConvertationService fiatConvertationService,
|
||||
@required Box<Template> templates,
|
||||
@required Box<ExchangeTemplate> exchangeTemplates,
|
||||
int initialMigrationVersion = 4}) async {
|
||||
|
@ -191,9 +172,7 @@ Future<void> initialSetup(
|
|||
tradesSource: tradesSource,
|
||||
templates: templates,
|
||||
exchangeTemplates: exchangeTemplates);
|
||||
await bootstrap(
|
||||
fiatConvertationService: fiatConvertationService,
|
||||
navigatorKey: navigatorKey);
|
||||
await bootstrap(navigatorKey);
|
||||
monero_wallet.onStartup();
|
||||
}
|
||||
|
||||
|
@ -220,22 +199,22 @@ class CakeWalletApp extends StatelessWidget {
|
|||
class MaterialAppWithTheme extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final sharedPreferences = Provider.of<SharedPreferences>(context);
|
||||
final walletService = Provider.of<WalletService>(context);
|
||||
final walletListService = Provider.of<WalletListService>(context);
|
||||
final userService = Provider.of<UserService>(context);
|
||||
final settingsStore = Provider.of<SettingsStore>(context);
|
||||
final priceStore = Provider.of<PriceStore>(context);
|
||||
final walletStore = Provider.of<WalletStore>(context);
|
||||
final syncStore = Provider.of<SyncStore>(context);
|
||||
final balanceStore = Provider.of<BalanceStore>(context);
|
||||
// final sharedPreferences = Provider.of<SharedPreferences>(context);
|
||||
// final walletService = Provider.of<WalletService>(context);
|
||||
// final walletListService = Provider.of<WalletListService>(context);
|
||||
// final userService = Provider.of<UserService>(context);
|
||||
// final settingsStore = Provider.of<SettingsStore>(context);
|
||||
// final priceStore = Provider.of<PriceStore>(context);
|
||||
// final walletStore = Provider.of<WalletStore>(context);
|
||||
// final syncStore = Provider.of<SyncStore>(context);
|
||||
// final balanceStore = Provider.of<BalanceStore>(context);
|
||||
final theme = Provider.of<ThemeChanger>(context);
|
||||
final currentLanguage = Provider.of<Language>(context);
|
||||
final contacts = Provider.of<Box<Contact>>(context);
|
||||
final nodes = Provider.of<Box<Node>>(context);
|
||||
final trades = Provider.of<Box<Trade>>(context);
|
||||
final transactionDescriptions =
|
||||
Provider.of<Box<TransactionDescription>>(context);
|
||||
// final currentLanguage = Provider.of<Language>(context);
|
||||
// final contacts = Provider.of<Box<Contact>>(context);
|
||||
// final nodes = Provider.of<Box<Node>>(context);
|
||||
// final trades = Provider.of<Box<Trade>>(context);
|
||||
// final transactionDescriptions =
|
||||
// Provider.of<Box<TransactionDescription>>(context);
|
||||
|
||||
if (!isThemeChangerRegistered) {
|
||||
setupThemeChangerStore(theme);
|
||||
|
@ -252,16 +231,9 @@ class MaterialAppWithTheme extends StatelessWidget {
|
|||
final statusBarIconBrightness =
|
||||
_settingsStore.isDarkTheme ? Brightness.light : Brightness.dark;
|
||||
final authenticationStore = getIt.get<AuthenticationStore>();
|
||||
String initialRoute;
|
||||
|
||||
switch (authenticationStore.state) {
|
||||
case AuthenticationState.denied:
|
||||
initialRoute = Routes.welcome;
|
||||
break;
|
||||
default:
|
||||
initialRoute = Routes.login;
|
||||
break;
|
||||
}
|
||||
final initialRoute = authenticationStore.state == AuthenticationState.denied
|
||||
? Routes.welcome
|
||||
: Routes.login;
|
||||
|
||||
SystemChrome.setSystemUIOverlayStyle(SystemUiOverlayStyle(
|
||||
statusBarColor: statusBarColor,
|
||||
|
@ -281,22 +253,8 @@ class MaterialAppWithTheme extends StatelessWidget {
|
|||
GlobalWidgetsLocalizations.delegate,
|
||||
],
|
||||
supportedLocales: S.delegate.supportedLocales,
|
||||
locale: Locale(currentLanguage.getCurrentLanguage()),
|
||||
onGenerateRoute: (settings) => Router.generateRoute(
|
||||
sharedPreferences: sharedPreferences,
|
||||
walletListService: walletListService,
|
||||
walletService: walletService,
|
||||
userService: userService,
|
||||
settings: settings,
|
||||
priceStore: priceStore,
|
||||
walletStore: walletStore,
|
||||
syncStore: syncStore,
|
||||
balanceStore: balanceStore,
|
||||
settingsStore: settingsStore,
|
||||
contacts: contacts,
|
||||
nodes: nodes,
|
||||
trades: trades,
|
||||
transactionDescriptions: transactionDescriptions),
|
||||
// locale: Locale(currentLanguage.getCurrentLanguage()),
|
||||
onGenerateRoute: (settings) => Router.generateRoute(settings),
|
||||
initialRoute: initialRoute,
|
||||
));
|
||||
}
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
import 'package:intl/intl.dart';
|
||||
|
||||
// FIXME: Hardcoded values; Works only for monero
|
||||
|
||||
final dateFormat = DateFormat('yyyy-MM');
|
||||
final dates = {
|
||||
"2014-5": 18844,
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue