Merge branch 'main' of https://github.com/cake-tech/cake_wallet into CW-180-advanced-startup-privacy-settings

 Conflicts:
	cw_core/lib/node.dart
	lib/di.dart
	lib/router.dart
	lib/routes.dart
	lib/view_model/node_list/node_create_or_edit_view_model.dart
	res/values/strings_de.arb
	res/values/strings_en.arb
	res/values/strings_es.arb
	res/values/strings_fr.arb
	res/values/strings_hi.arb
	res/values/strings_hr.arb
	res/values/strings_it.arb
	res/values/strings_ja.arb
	res/values/strings_ko.arb
	res/values/strings_nl.arb
	res/values/strings_pl.arb
	res/values/strings_pt.arb
	res/values/strings_ru.arb
	res/values/strings_uk.arb
	res/values/strings_zh.arb
This commit is contained in:
OmarHatem
2022-11-09 15:40:12 +02:00
543 changed files with 7981 additions and 6389 deletions
@@ -1,6 +1,7 @@
import 'package:cake_wallet/core/execution_state.dart';
import 'package:hive/hive.dart';
import 'package:mobx/mobx.dart';
import 'package:cw_core/wallet_base.dart';
import 'package:cw_core/node.dart';
import 'package:cw_core/wallet_type.dart';
@@ -10,11 +11,15 @@ class NodeCreateOrEditViewModel = NodeCreateOrEditViewModelBase
with _$NodeCreateOrEditViewModel;
abstract class NodeCreateOrEditViewModelBase with Store {
NodeCreateOrEditViewModelBase(this._nodeSource, this._walletType)
NodeCreateOrEditViewModelBase(this._nodeSource, this._wallet)
: state = InitialExecutionState(),
connectionState = InitialExecutionState(),
useSSL = false,
trusted = false;
trusted = false,
address = '',
port = '',
login = '',
password = '';
@observable
ExecutionState state;
@@ -42,22 +47,22 @@ abstract class NodeCreateOrEditViewModelBase with Store {
@computed
bool get isReady =>
(address?.isNotEmpty ?? false) && (port?.isNotEmpty ?? false);
address.isNotEmpty && port.isNotEmpty;
bool get hasAuthCredentials => _walletType == WalletType.monero ||
_walletType == WalletType.haven;
bool get hasAuthCredentials => _wallet.type == WalletType.monero ||
_wallet.type == WalletType.haven;
String get uri {
var uri = address;
if (port != null && port.isNotEmpty) {
if (port.isNotEmpty) {
uri += ':' + port;
}
return uri;
}
final WalletType _walletType;
final WalletBase _wallet;
final Box<Node> _nodeSource;
@action
@@ -75,7 +80,7 @@ abstract class NodeCreateOrEditViewModelBase with Store {
try {
state = IsExecutingState();
final node =
Node(uri: uri, type: _walletType, login: login, password: password,
Node(uri: uri, type: _wallet.type, login: login, password: password,
useSSL: useSSL, trusted: trusted);
await _nodeSource.add(node);
state = ExecutedSuccessfullyState();
@@ -89,7 +94,7 @@ abstract class NodeCreateOrEditViewModelBase with Store {
try {
connectionState = IsExecutingState();
final node =
Node(uri: uri, type: _walletType, login: login, password: password);
Node(uri: uri, type: _wallet.type, login: login, password: password);
final isAlive = await node.requestNode();
connectionState = ExecutedSuccessfullyState(payload: isAlive);
} catch (e) {
@@ -20,7 +20,15 @@ abstract class NodeListViewModelBase with Store {
}
@computed
Node get currentNode => settingsStore.nodes[wallet.type];
Node get currentNode {
final node = settingsStore.nodes[wallet.type];
if (node == null) {
throw Exception('No node for wallet type: ${wallet.type}');
}
return node;
}
final ObservableList<Node> nodes;
final SettingsStore settingsStore;
@@ -34,16 +42,19 @@ abstract class NodeListViewModelBase with Store {
switch (wallet.type) {
case WalletType.bitcoin:
node = getBitcoinDefaultElectrumServer(nodes: _nodeSource);
node = getBitcoinDefaultElectrumServer(nodes: _nodeSource)!;
break;
case WalletType.monero:
node = getMoneroDefaultNode(nodes: _nodeSource);
break;
case WalletType.litecoin:
node = getLitecoinDefaultElectrumServer(nodes: _nodeSource);
node = getLitecoinDefaultElectrumServer(nodes: _nodeSource)!;
break;
case WalletType.haven:
node = getHavenDefaultNode(nodes: _nodeSource)!;
break;
default:
break;
throw Exception('Unexpected wallet type: ${wallet.type}');
}
await setAsCurrent(node);