Merge branch 'CW-438-add-nano' of https://github.com/cake-tech/cake_wallet into CW-459-12-words-btc

This commit is contained in:
fosse 2023-09-08 10:00:17 -04:00
commit 90c120dcc5
21 changed files with 90 additions and 268 deletions

View file

@ -1,4 +1,6 @@
-
uri: rpc.nano.to:443
uri: rpc.nano.to
useSSL: true
is_default: true
-
uri: node.perish.co:9076

View file

@ -1,5 +1,7 @@
-
uri: rpc.nano.to:443
uri: rpc.nano.to
useSSL: true
is_default: true
-
uri: workers.perish.co
-

View file

@ -80,7 +80,7 @@ class Node extends HiveObject with Keyable {
return Uri.https(uriRaw, '');
case WalletType.nano:
case WalletType.banano:
if (uriRaw.contains("https") || uriRaw.endsWith("443") || isSSL) {
if (isSSL) {
return Uri.https(uriRaw, '');
} else {
return Uri.http(uriRaw, '');

View file

@ -1,159 +0,0 @@
import 'dart:io';
import 'package:cw_core/keyable.dart';
import 'dart:convert';
import 'package:http/http.dart' as http;
import 'package:hive/hive.dart';
import 'package:cw_core/hive_type_ids.dart';
import 'package:cw_core/wallet_type.dart';
import 'package:http/io_client.dart' as ioc;
part 'pow_node.g.dart';
Uri createUriFromElectrumAddress(String address) => Uri.tryParse('tcp://$address')!;
@HiveType(typeId: PowNode.typeId)
class PowNode extends HiveObject with Keyable {
PowNode({
this.login,
this.password,
this.useSSL,
this.trusted = false,
this.socksProxyAddress,
String? uri,
WalletType? type,
}) {
if (uri != null) {
uriRaw = uri;
}
if (type != null) {
this.type = type;
}
}
PowNode.fromMap(Map<String, Object?> map)
: uriRaw = map['uri'] as String? ?? '',
login = map['login'] as String?,
password = map['password'] as String?,
useSSL = map['useSSL'] as bool?,
trusted = map['trusted'] as bool? ?? false,
socksProxyAddress = map['socksProxyPort'] as String?;
static const typeId = POW_NODE_TYPE_ID;
static const boxName = 'PowNodes';
@HiveField(0, defaultValue: '')
late String uriRaw;
@HiveField(1)
String? login;
@HiveField(2)
String? password;
@HiveField(3, defaultValue: 0)
late int typeRaw;
@HiveField(4)
bool? useSSL;
@HiveField(5, defaultValue: false)
bool trusted;
@HiveField(6)
String? socksProxyAddress;
bool get isSSL => useSSL ?? false;
bool get useSocksProxy => socksProxyAddress == null ? false : socksProxyAddress!.isNotEmpty;
Uri get uri {
switch (type) {
case WalletType.monero:
return Uri.http(uriRaw, '');
case WalletType.bitcoin:
return createUriFromElectrumAddress(uriRaw);
case WalletType.litecoin:
return createUriFromElectrumAddress(uriRaw);
case WalletType.haven:
return Uri.http(uriRaw, '');
case WalletType.ethereum:
return Uri.https(uriRaw, '');
case WalletType.nano:
case WalletType.banano:
if (uriRaw.contains("https") || uriRaw.endsWith("443") || isSSL) {
return Uri.https(uriRaw, '');
} else {
return Uri.http(uriRaw, '');
}
default:
throw Exception('Unexpected type ${type.toString()} for Node uri');
}
}
@override
bool operator ==(other) =>
other is PowNode &&
(other.uriRaw == uriRaw &&
other.login == login &&
other.password == password &&
other.typeRaw == typeRaw &&
other.useSSL == useSSL &&
other.trusted == trusted &&
other.socksProxyAddress == socksProxyAddress);
@override
int get hashCode =>
uriRaw.hashCode ^
login.hashCode ^
password.hashCode ^
typeRaw.hashCode ^
useSSL.hashCode ^
trusted.hashCode ^
socksProxyAddress.hashCode;
@override
dynamic get keyIndex {
_keyIndex ??= key;
return _keyIndex;
}
WalletType get type => deserializeFromInt(typeRaw);
set type(WalletType type) => typeRaw = serializeToInt(type);
dynamic _keyIndex;
Future<bool> requestNode() async {
try {
switch (type) {
case WalletType.nano:
return requestNanoPowNode();
default:
return false;
}
} catch (_) {
return false;
}
}
Future<bool> requestNanoPowNode() async {
return http
.post(
uri,
headers: {'Content-type': 'application/json'},
body: json.encode(
{
"action": "work_generate",
"hash": "0000000000000000000000000000000000000000000000000000000000000000",
},
),
)
.then((http.Response response) {
if (response.statusCode == 200) {
return true;
} else {
return false;
}
});
}
}

View file

@ -1,4 +1,3 @@
import 'package:cw_core/pow_node.dart';
import 'package:mobx/mobx.dart';
import 'package:cw_core/balance.dart';
import 'package:cw_core/transaction_info.dart';
@ -60,7 +59,7 @@ abstract class WalletBase<
Future<void> connectToNode({required Node node});
// there is a default definition here because only coins with a pow node (nano based) need to override this
Future<void> connectToPowNode({required PowNode node}) async {}
Future<void> connectToPowNode({required Node node}) async {}
Future<void> startSync();

View file

@ -1,14 +1,9 @@
import 'dart:async';
import 'dart:convert';
import 'dart:math';
import 'package:cw_core/crypto_currency.dart';
import 'package:cw_core/erc20_token.dart';
import 'package:cw_core/pow_node.dart';
import 'package:cw_nano/nano_balance.dart';
import 'package:cw_nano/nano_transaction_model.dart';
import 'package:cw_nano/nano_util.dart';
import 'package:flutter/services.dart';
import 'package:http/http.dart' as http;
import 'package:nanodart/nanodart.dart';
import 'package:cw_core/node.dart';
@ -18,7 +13,7 @@ class NanoClient {
"nano_38713x95zyjsqzx6nm1dsom1jmm668owkeb9913ax6nfgj15az3nu8xkx579";
Node? _node;
PowNode? _powNode;
Node? _powNode;
bool connect(Node node) {
try {
@ -29,7 +24,7 @@ class NanoClient {
}
}
bool connectPow(PowNode node) {
bool connectPow(Node node) {
try {
_powNode = node;
return true;

View file

@ -6,11 +6,9 @@ import 'package:cw_core/crypto_currency.dart';
import 'package:cw_core/node.dart';
import 'package:cw_core/pathForWallet.dart';
import 'package:cw_core/pending_transaction.dart';
import 'package:cw_core/pow_node.dart';
import 'package:cw_core/sync_status.dart';
import 'package:cw_core/transaction_direction.dart';
import 'package:cw_core/transaction_priority.dart';
import 'package:cw_core/wallet_addresses.dart';
import 'package:cw_core/wallet_info.dart';
import 'package:cw_nano/file.dart';
import 'package:cw_core/nano_account.dart';
@ -23,7 +21,6 @@ import 'package:cw_nano/nano_util.dart';
import 'package:cw_nano/nano_wallet_keys.dart';
import 'package:cw_nano/pending_nano_transaction.dart';
import 'package:mobx/mobx.dart';
import 'package:hive/hive.dart';
import 'dart:async';
import 'package:cw_nano/nano_wallet_addresses.dart';
import 'package:cw_core/wallet_base.dart';
@ -151,7 +148,7 @@ abstract class NanoWalletBase
}
@override
Future<void> connectToPowNode({required PowNode node}) async {
Future<void> connectToPowNode({required Node node}) async {
_client.connectPow(node);
}

View file

@ -93,7 +93,6 @@ import 'package:cake_wallet/view_model/wallet_list/wallet_list_item.dart';
import 'package:cake_wallet/view_model/wallet_restore_choose_derivation_view_model.dart';
import 'package:cw_core/erc20_token.dart';
import 'package:cw_core/nano_account.dart';
import 'package:cw_core/pow_node.dart';
import 'package:cw_core/unspent_coins_info.dart';
import 'package:cake_wallet/core/backup_service.dart';
import 'package:cw_core/wallet_service.dart';
@ -226,7 +225,7 @@ final getIt = GetIt.instance;
var _isSetupFinished = false;
late Box<WalletInfo> _walletInfoSource;
late Box<Node> _nodeSource;
late Box<PowNode> _powNodeSource;
late Box<Node> _powNodeSource;
late Box<Contact> _contactSource;
late Box<Trade> _tradesSource;
late Box<Template> _templates;
@ -239,7 +238,7 @@ late Box<AnonpayInvoiceInfo> _anonpayInvoiceInfoSource;
Future<void> setup({
required Box<WalletInfo> walletInfoSource,
required Box<Node> nodeSource,
required Box<PowNode> powNodeSource,
required Box<Node> powNodeSource,
required Box<Contact> contactSource,
required Box<Trade> tradesSource,
required Box<Template> templates,
@ -287,7 +286,7 @@ Future<void> setup({
}
getIt.registerFactory<Box<Node>>(() => _nodeSource);
getIt.registerFactory<Box<PowNode>>(() => _powNodeSource);
getIt.registerFactory<Box<Node>>(() => _powNodeSource, instanceName: Node.boxName + "pow");
getIt.registerSingleton<FlutterSecureStorage>(FlutterSecureStorage());
getIt.registerSingleton(AuthenticationStore());
@ -756,8 +755,8 @@ Future<void> setup({
editingNode: editingNode,
isSelected: isSelected));
getIt.registerFactoryParam<PowNodeCreateOrEditPage, PowNode?, bool?>(
(PowNode? editingNode, bool? isSelected) => PowNodeCreateOrEditPage(
getIt.registerFactoryParam<PowNodeCreateOrEditPage, Node?, bool?>(
(Node? editingNode, bool? isSelected) => PowNodeCreateOrEditPage(
nodeCreateOrEditViewModel: getIt.get<PowNodeCreateOrEditViewModel>(),
editingNode: editingNode,
isSelected: isSelected));

View file

@ -3,8 +3,6 @@ import 'package:cake_wallet/bitcoin/bitcoin.dart';
import 'package:cake_wallet/entities/exchange_api_mode.dart';
import 'package:cw_core/pathForWallet.dart';
import 'package:cake_wallet/entities/secret_store_key.dart';
import 'package:cw_core/pow_node.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
import 'package:hive/hive.dart';
import 'package:path_provider/path_provider.dart';
@ -36,7 +34,7 @@ Future<void> defaultSettingsMigration(
required SharedPreferences sharedPreferences,
required FlutterSecureStorage secureStorage,
required Box<Node> nodes,
required Box<PowNode> powNodes,
required Box<Node> powNodes,
required Box<WalletInfo> walletInfoSource,
required Box<Trade> tradeSource,
required Box<Contact> contactSource}) async {
@ -320,8 +318,8 @@ Node? getNanoDefaultNode({required Box<Node> nodes}) {
nodes.values.firstWhereOrNull((node) => node.type == WalletType.nano);
}
PowNode? getNanoDefaultPowNode({required Box<PowNode> nodes}) {
return nodes.values.firstWhereOrNull((PowNode node) => node.uriRaw == nanoDefaultPowNodeUri) ??
Node? getNanoDefaultPowNode({required Box<Node> nodes}) {
return nodes.values.firstWhereOrNull((Node node) => node.uriRaw == nanoDefaultPowNodeUri) ??
nodes.values.firstWhereOrNull((node) => (node.type == WalletType.nano));
}
@ -495,7 +493,7 @@ Future<void> changeDefaultMoneroNode(
}
Future<void> checkCurrentNodes(
Box<Node> nodeSource, Box<PowNode> powNodeSource, SharedPreferences sharedPreferences) async {
Box<Node> nodeSource, Box<Node> powNodeSource, SharedPreferences sharedPreferences) async {
final currentMoneroNodeId = sharedPreferences.getInt(PreferencesKey.currentNodeIdKey);
final currentBitcoinElectrumSeverId =
sharedPreferences.getInt(PreferencesKey.currentBitcoinElectrumSererIdKey);
@ -559,10 +557,10 @@ Future<void> checkCurrentNodes(
}
if (currentNanoPowNodeServer == null) {
PowNode? node = powNodeSource.values
Node? node = powNodeSource.values
.firstWhereOrNull((node) => node.uri.toString() == nanoDefaultPowNodeUri);
if (node == null) {
node = PowNode(uri: nanoDefaultPowNodeUri, type: WalletType.nano);
node = Node(uri: nanoDefaultPowNodeUri, type: WalletType.nano);
await powNodeSource.add(node);
}
await sharedPreferences.setInt(PreferencesKey.currentNanoPowNodeIdKey, node.key as int);
@ -647,7 +645,7 @@ Future<void> changeNanoCurrentNodeToDefault(
}
Future<void> changeNanoCurrentPowNodeToDefault(
{required SharedPreferences sharedPreferences, required Box<PowNode> nodes}) async {
{required SharedPreferences sharedPreferences, required Box<Node> nodes}) async {
final node = getNanoDefaultPowNode(nodes: nodes);
final nodeId = node?.key as int? ?? 0;
await sharedPreferences.setInt(PreferencesKey.currentNanoPowNodeIdKey, nodeId);

View file

@ -1,4 +1,3 @@
import 'package:cw_core/pow_node.dart';
import 'package:flutter/services.dart';
import 'package:hive/hive.dart';
import "package:yaml/yaml.dart";
@ -101,14 +100,14 @@ Future<List<Node>> loadDefaultNanoNodes() async {
return nodes;
}
Future<List<PowNode>> loadDefaultNanoPowNodes() async {
Future<List<Node>> loadDefaultNanoPowNodes() async {
final powNodesRaw = await rootBundle.loadString('assets/nano_pow_node_list.yml');
final loadedPowNodes = loadYaml(powNodesRaw) as YamlList;
final nodes = <PowNode>[];
final nodes = <Node>[];
for (final raw in loadedPowNodes) {
if (raw is Map) {
final node = PowNode.fromMap(Map<String, Object>.from(raw));
final node = Node.fromMap(Map<String, Object>.from(raw));
node.type = WalletType.nano;
nodes.add(node);
}
@ -136,7 +135,7 @@ Future resetToDefault(Box<Node> nodeSource) async {
await nodeSource.addAll(nodes);
}
Future resetPowToDefault(Box<PowNode> powNodeSource) async {
Future resetPowToDefault(Box<Node> powNodeSource) async {
final nanoPowNodes = await loadDefaultNanoPowNodes();
final nodes = nanoPowNodes;
await powNodeSource.clear();

View file

@ -9,7 +9,6 @@ import 'package:cake_wallet/utils/exception_handler.dart';
import 'package:cw_core/address_info.dart';
import 'package:cake_wallet/utils/responsive_layout_util.dart';
import 'package:cw_core/hive_type_ids.dart';
import 'package:cw_core/pow_node.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
@ -83,10 +82,6 @@ Future<void> initializeAppConfigs() async {
CakeHive.registerAdapter(NodeAdapter());
}
if (!CakeHive.isAdapterRegistered(PowNode.typeId)) {
CakeHive.registerAdapter(PowNodeAdapter());
}
if (!CakeHive.isAdapterRegistered(TransactionDescription.typeId)) {
CakeHive.registerAdapter(TransactionDescriptionAdapter());
}
@ -138,7 +133,7 @@ Future<void> initializeAppConfigs() async {
final ordersBoxKey = await getEncryptionKey(secureStorage: secureStorage, forKey: Order.boxKey);
final contacts = await CakeHive.openBox<Contact>(Contact.boxName);
final nodes = await CakeHive.openBox<Node>(Node.boxName);
final powNodes = await CakeHive.openBox<PowNode>(PowNode.boxName);
final powNodes = await CakeHive.openBox<Node>(Node.boxName + "pow");// must be different from Node.boxName
final transactionDescriptions = await CakeHive.openBox<TransactionDescription>(
TransactionDescription.boxName,
encryptionKey: transactionDescriptionsBoxKey);
@ -171,7 +166,7 @@ Future<void> initializeAppConfigs() async {
Future<void> initialSetup(
{required SharedPreferences sharedPreferences,
required Box<Node> nodes,
required Box<PowNode> powNodes,
required Box<Node> powNodes,
required Box<WalletInfo> walletInfoSource,
required Box<Contact> contactSource,
required Box<Trade> tradesSource,

View file

@ -57,7 +57,6 @@ import 'package:cake_wallet/view_model/node_list/node_create_or_edit_view_model.
import 'package:cake_wallet/view_model/advanced_privacy_settings_view_model.dart';
import 'package:cake_wallet/wallet_type_utils.dart';
import 'package:cw_core/nano_account.dart';
import 'package:cw_core/pow_node.dart';
import 'package:cw_core/wallet_info.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
@ -335,7 +334,7 @@ Route<dynamic> createRoute(RouteSettings settings) {
final args = settings.arguments as Map<String, dynamic>?;
return CupertinoPageRoute<void>(
builder: (_) => getIt.get<PowNodeCreateOrEditPage>(
param1: args?['editingNode'] as PowNode?, param2: args?['isSelected'] as bool?));
param1: args?['editingNode'] as Node?, param2: args?['isSelected'] as bool?));
case Routes.accountCreation:
return CupertinoPageRoute<String>(

View file

@ -1,13 +1,10 @@
import 'package:cake_wallet/core/execution_state.dart';
import 'package:cake_wallet/palette.dart';
import 'package:cake_wallet/src/screens/nodes/widgets/node_form.dart';
import 'package:cake_wallet/src/screens/nodes/widgets/pow_node_form.dart';
import 'package:cake_wallet/src/widgets/alert_with_one_action.dart';
import 'package:cake_wallet/src/widgets/alert_with_two_actions.dart';
import 'package:cake_wallet/utils/show_pop_up.dart';
import 'package:cake_wallet/view_model/node_list/pow_node_create_or_edit_view_model.dart';
import 'package:cw_core/node.dart';
import 'package:cw_core/pow_node.dart';
import 'package:flutter/material.dart';
import 'package:flutter_mobx/flutter_mobx.dart';
import 'package:mobx/mobx.dart';

View file

@ -7,7 +7,6 @@ import 'package:cake_wallet/src/widgets/alert_with_two_actions.dart';
import 'package:cake_wallet/utils/show_pop_up.dart';
import 'package:cake_wallet/view_model/node_list/pow_node_create_or_edit_view_model.dart';
import 'package:cw_core/node.dart';
import 'package:cw_core/pow_node.dart';
import 'package:flutter/material.dart';
import 'package:flutter_mobx/flutter_mobx.dart';
import 'package:mobx/mobx.dart';
@ -83,7 +82,7 @@ class PowNodeCreateOrEditPage extends BasePage {
);
final PowNodeCreateOrEditViewModel nodeCreateOrEditViewModel;
final PowNode? editingNode;
final Node? editingNode;
final bool? isSelected;
@override

View file

@ -5,7 +5,7 @@ import 'package:cake_wallet/src/widgets/base_text_form_field.dart';
import 'package:cake_wallet/src/widgets/standard_checkbox.dart';
import 'package:cake_wallet/view_model/node_list/node_create_or_edit_view_model.dart';
import 'package:cake_wallet/view_model/node_list/pow_node_create_or_edit_view_model.dart';
import 'package:cw_core/pow_node.dart';
import 'package:cw_core/node.dart';
import 'package:flutter/material.dart';
import 'package:flutter_mobx/flutter_mobx.dart';
import 'package:cake_wallet/generated/i18n.dart';
@ -66,7 +66,7 @@ class PowNodeForm extends StatelessWidget {
final PowNodeCreateOrEditViewModel nodeViewModel;
final GlobalKey<FormState> formKey;
final PowNode? editingNode;
final Node? editingNode;
final TextEditingController _addressController;
final TextEditingController _portController;

View file

@ -3,7 +3,7 @@ import 'package:cake_wallet/src/screens/nodes/widgets/node_indicator.dart';
import 'package:cake_wallet/src/widgets/standard_list.dart';
import 'package:cake_wallet/themes/extensions/filter_theme.dart';
import 'package:cake_wallet/themes/extensions/receive_page_theme.dart';
import 'package:cw_core/pow_node.dart';
import 'package:cw_core/node.dart';
import 'package:flutter/material.dart';
class PowNodeListRow extends StandardListRow {
@ -14,7 +14,7 @@ class PowNodeListRow extends StandardListRow {
required bool isSelected})
: super(title: title, onTap: onTap, isSelected: isSelected);
final PowNode node;
final Node node;
@override
Widget buildLeading(BuildContext context) {

View file

@ -34,12 +34,13 @@ class ManageNodesPage extends BasePage {
SizedBox(height: 20),
Observer(
builder: (BuildContext context) {
int nodesLength = nodeListViewModel.nodes.length;
return Flexible(
child: SectionStandardList(
sectionCount: 1,
dividerPadding: EdgeInsets.symmetric(horizontal: 24),
itemCounter: (int sectionIndex) {
return nodeListViewModel.nodes.length;
return nodesLength;
},
itemBuilder: (_, index) {
return Observer(

View file

@ -1,14 +1,11 @@
import 'package:cake_wallet/generated/i18n.dart';
import 'package:cake_wallet/routes.dart';
import 'package:cake_wallet/src/screens/base_page.dart';
import 'package:cake_wallet/src/screens/nodes/widgets/node_list_row.dart';
import 'package:cake_wallet/src/screens/nodes/widgets/pow_node_list_row.dart';
import 'package:cake_wallet/src/widgets/alert_with_two_actions.dart';
import 'package:cake_wallet/src/widgets/standard_list.dart';
import 'package:cake_wallet/utils/show_pop_up.dart';
import 'package:cake_wallet/view_model/node_list/node_list_view_model.dart';
import 'package:cake_wallet/view_model/node_list/pow_node_list_view_model.dart';
import 'package:cw_core/node.dart';
import 'package:flutter/material.dart';
import 'package:flutter_mobx/flutter_mobx.dart';
@ -37,14 +34,17 @@ class ManagePowNodesPage extends BasePage {
SizedBox(height: 20),
Observer(
builder: (BuildContext context) {
int nodesLength = nodeListViewModel.nodes.length;
return Flexible(
child: SectionStandardList(
sectionCount: 1,
dividerPadding: EdgeInsets.symmetric(horizontal: 24),
itemCounter: (int sectionIndex) {
return nodeListViewModel.nodes.length;
return nodesLength;
},
itemBuilder: (_, index) {
return Observer(
builder: (context) {
final node = nodeListViewModel.nodes[index];
final isSelected = node.keyIndex == nodeListViewModel.currentNode.keyIndex;
final nodeListRow = PowNodeListRow(
@ -76,6 +76,8 @@ class ManagePowNodesPage extends BasePage {
return nodeListRow;
},
);
},
),
);
},

View file

@ -11,7 +11,6 @@ import 'package:cake_wallet/entities/sort_balance_types.dart';
import 'package:cake_wallet/view_model/settings/sync_mode.dart';
import 'package:cake_wallet/utils/device_info.dart';
import 'package:cake_wallet/ethereum/ethereum.dart';
import 'package:cw_core/pow_node.dart';
import 'package:cw_core/transaction_priority.dart';
import 'package:cake_wallet/themes/theme_base.dart';
import 'package:cake_wallet/themes/theme_list.dart';
@ -63,7 +62,7 @@ abstract class SettingsStoreBase with Store {
required this.appVersion,
required this.deviceName,
required Map<WalletType, Node> nodes,
required Map<WalletType, PowNode> powNodes,
required Map<WalletType, Node> powNodes,
required this.shouldShowYatPopup,
required this.isBitcoinBuyEnabled,
required this.actionlistDisplayMode,
@ -86,7 +85,7 @@ abstract class SettingsStoreBase with Store {
TransactionPriority? initialLitecoinTransactionPriority,
TransactionPriority? initialEthereumTransactionPriority})
: nodes = ObservableMap<WalletType, Node>.of(nodes),
powNodes = ObservableMap<WalletType, PowNode>.of(powNodes),
powNodes = ObservableMap<WalletType, Node>.of(powNodes),
_sharedPreferences = sharedPreferences,
_backgroundTasks = backgroundTasks,
fiatCurrency = initialFiatCurrency,
@ -477,7 +476,7 @@ abstract class SettingsStoreBase with Store {
final BackgroundTasks _backgroundTasks;
ObservableMap<WalletType, Node> nodes;
ObservableMap<WalletType, PowNode> powNodes;
ObservableMap<WalletType, Node> powNodes;
Node getCurrentNode(WalletType walletType) {
final node = nodes[walletType];
@ -489,7 +488,7 @@ abstract class SettingsStoreBase with Store {
return node;
}
PowNode getCurrentPowNode(WalletType walletType) {
Node getCurrentPowNode(WalletType walletType) {
final node = powNodes[walletType];
if (node == null) {
@ -509,7 +508,7 @@ abstract class SettingsStoreBase with Store {
static Future<SettingsStore> load(
{required Box<Node> nodeSource,
required Box<PowNode> powNodeSource,
required Box<Node> powNodeSource,
required bool isBitcoinBuyEnabled,
FiatCurrency initialFiatCurrency = FiatCurrency.usd,
BalanceDisplayMode initialBalanceDisplayMode = BalanceDisplayMode.availableBalance,
@ -645,7 +644,7 @@ abstract class SettingsStoreBase with Store {
? AutoGenerateSubaddressStatus.deserialize(raw: generateSubaddresses)
: defaultAutoGenerateSubaddressStatus;
final nodes = <WalletType, Node>{};
final powNodes = <WalletType, PowNode>{};
final powNodes = <WalletType, Node>{};
if (moneroNode != null) {
nodes[WalletType.monero] = moneroNode;
@ -908,7 +907,7 @@ abstract class SettingsStoreBase with Store {
nodes[walletType] = node;
}
Future<void> _saveCurrentPowNode(PowNode node, WalletType walletType) async {
Future<void> _saveCurrentPowNode(Node node, WalletType walletType) async {
switch (walletType) {
case WalletType.nano:
await _sharedPreferences.setInt(PreferencesKey.currentNanoPowNodeIdKey, node.key as int);

View file

@ -1,7 +1,6 @@
import 'package:cake_wallet/core/execution_state.dart';
import 'package:cake_wallet/entities/qr_scanner.dart';
import 'package:cake_wallet/store/settings_store.dart';
import 'package:cw_core/pow_node.dart';
import 'package:hive/hive.dart';
import 'package:mobx/mobx.dart';
import 'package:cw_core/node.dart';
@ -74,7 +73,7 @@ abstract class PowNodeCreateOrEditViewModelBase with Store {
}
final WalletType _walletType;
final Box<PowNode> _nodeSource;
final Box<Node> _nodeSource;
final SettingsStore _settingsStore;
@action
@ -114,8 +113,8 @@ abstract class PowNodeCreateOrEditViewModelBase with Store {
void setSocksProxyAddress(String val) => socksProxyAddress = val;
@action
Future<void> save({PowNode? editingNode, bool saveAsCurrent = false}) async {
final node = PowNode(
Future<void> save({Node? editingNode, bool saveAsCurrent = false}) async {
final node = Node(
uri: uri,
type: _walletType,
login: login,
@ -145,7 +144,7 @@ abstract class PowNodeCreateOrEditViewModelBase with Store {
@action
Future<void> connect() async {
final node = PowNode(
final node = Node(
uri: uri,
type: _walletType,
login: login,
@ -162,7 +161,7 @@ abstract class PowNodeCreateOrEditViewModelBase with Store {
}
}
PowNode? _existingNode(PowNode node) {
Node? _existingNode(Node node) {
final nodes = _nodeSource.values.toList();
nodes.forEach((item) {
item.login ??= '';
@ -173,7 +172,7 @@ abstract class PowNodeCreateOrEditViewModelBase with Store {
}
@action
void setAsCurrent(PowNode node) => _settingsStore.powNodes[_walletType] = node;
void setAsCurrent(Node node) => _settingsStore.powNodes[_walletType] = node;
@action
Future<void> scanQRCodeForNewNode() async {

View file

@ -1,7 +1,6 @@
import 'package:cake_wallet/generated/i18n.dart';
import 'package:cake_wallet/store/app_store.dart';
import 'package:cake_wallet/utils/mobx.dart';
import 'package:cw_core/pow_node.dart';
import 'package:hive/hive.dart';
import 'package:mobx/mobx.dart';
import 'package:cw_core/wallet_base.dart';
@ -17,7 +16,7 @@ class PowNodeListViewModel = PowNodeListViewModelBase with _$PowNodeListViewMode
abstract class PowNodeListViewModelBase with Store {
PowNodeListViewModelBase(this._nodeSource, this._appStore)
: nodes = ObservableList<PowNode>(),
: nodes = ObservableList<Node>(),
settingsStore = _appStore.settingsStore {
_bindNodes();
@ -27,7 +26,7 @@ abstract class PowNodeListViewModelBase with Store {
}
@computed
PowNode get currentNode {
Node get currentNode {
final node = settingsStore.powNodes[_appStore.wallet!.type];
if (node == null) {
@ -41,15 +40,15 @@ abstract class PowNodeListViewModelBase with Store {
S.current.change_current_node(uri) +
'${uri.endsWith('.onion') || uri.contains('.onion:') ? '\n' + S.current.orbot_running_alert : ''}';
final ObservableList<PowNode> nodes;
final ObservableList<Node> nodes;
final SettingsStore settingsStore;
final Box<PowNode> _nodeSource;
final Box<Node> _nodeSource;
final AppStore _appStore;
Future<void> reset() async {
await resetPowToDefault(_nodeSource);
PowNode node;
Node node;
switch (_appStore.wallet!.type) {
case WalletType.nano:
@ -63,9 +62,9 @@ abstract class PowNodeListViewModelBase with Store {
}
@action
Future<void> delete(PowNode node) async => node.delete();
Future<void> delete(Node node) async => node.delete();
Future<void> setAsCurrent(PowNode node) async =>
Future<void> setAsCurrent(Node node) async =>
settingsStore.powNodes[_appStore.wallet!.type] = node;
@action