mirror of
https://github.com/Such-Software/hash-wallet.git
synced 2026-10-26 06:08:40 +01:00
Reformat the whole codebase with 100 line width (#3403)
This commit is contained in:
@@ -12,28 +12,25 @@ import 'package:permission_handler/permission_handler.dart';
|
||||
|
||||
part 'node_create_or_edit_view_model.g.dart';
|
||||
|
||||
class NodeCreateOrEditViewModel = NodeCreateOrEditViewModelBase
|
||||
with _$NodeCreateOrEditViewModel;
|
||||
class NodeCreateOrEditViewModel = NodeCreateOrEditViewModelBase with _$NodeCreateOrEditViewModel;
|
||||
|
||||
abstract class NodeCreateOrEditViewModelBase with Store {
|
||||
NodeCreateOrEditViewModelBase(
|
||||
this.isPow, this.walletType, this._settingsStore, {this.editingNode})
|
||||
NodeCreateOrEditViewModelBase(this.isPow, this.walletType, this._settingsStore,
|
||||
{this.editingNode})
|
||||
: state = InitialExecutionState(),
|
||||
connectionState = InitialExecutionState(),
|
||||
label = editingNode?.label ?? '',
|
||||
address = editingNode?.uri.host.toString() ?? '',
|
||||
path = editingNode?.path.toString() ?? '',
|
||||
port = (editingNode != null && editingNode.uri.hasPort)
|
||||
? editingNode.uri.port.toString()
|
||||
: '',
|
||||
port =
|
||||
(editingNode != null && editingNode.uri.hasPort) ? editingNode.uri.port.toString() : '',
|
||||
login = editingNode?.login ?? '',
|
||||
password = editingNode?.password ?? '',
|
||||
socksProxyAddress = editingNode?.socksProxyAddress ?? '',
|
||||
trusted = editingNode?.trusted ?? false,
|
||||
isEnabledForAutoSwitching =
|
||||
editingNode?.isEnabledForAutoSwitching ?? false,
|
||||
useSocksProxy = editingNode?.socksProxyAddress != null &&
|
||||
editingNode!.socksProxyAddress!.isNotEmpty,
|
||||
isEnabledForAutoSwitching = editingNode?.isEnabledForAutoSwitching ?? false,
|
||||
useSocksProxy =
|
||||
editingNode?.socksProxyAddress != null && editingNode!.socksProxyAddress!.isNotEmpty,
|
||||
useSSL = editingNode?.useSSL ?? false {}
|
||||
|
||||
final nodeLabelUIKey = 'node_label_row_key';
|
||||
@@ -113,11 +110,9 @@ abstract class NodeCreateOrEditViewModelBase with Store {
|
||||
@observable
|
||||
bool isPow;
|
||||
|
||||
|
||||
@computed
|
||||
bool get isReady =>
|
||||
(address.isNotEmpty) ||
|
||||
walletType == WalletType.decred; // Allow an empty address.
|
||||
(address.isNotEmpty) || walletType == WalletType.decred; // Allow an empty address.
|
||||
|
||||
bool get hasAuthCredentials =>
|
||||
walletType == WalletType.monero ||
|
||||
@@ -240,8 +235,7 @@ abstract class NodeCreateOrEditViewModelBase with Store {
|
||||
void setTrusted(bool val) => trusted = val;
|
||||
|
||||
@action
|
||||
void setIsEnabledForAutoSwitching(bool val) =>
|
||||
isEnabledForAutoSwitching = val;
|
||||
void setIsEnabledForAutoSwitching(bool val) => isEnabledForAutoSwitching = val;
|
||||
|
||||
@action
|
||||
void setSocksProxy(bool val) => useSocksProxy = val;
|
||||
@@ -276,7 +270,6 @@ abstract class NodeCreateOrEditViewModelBase with Store {
|
||||
}
|
||||
|
||||
state = ExecutedSuccessfullyState();
|
||||
|
||||
} catch (e) {
|
||||
state = FailureState(e.toString());
|
||||
}
|
||||
@@ -303,7 +296,6 @@ abstract class NodeCreateOrEditViewModelBase with Store {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@action
|
||||
void setAsCurrent(Node node) => _settingsStore.nodes[walletType] = node;
|
||||
|
||||
@@ -320,8 +312,7 @@ abstract class NodeCreateOrEditViewModelBase with Store {
|
||||
throw Exception('Unexpected scan QR code value: value is empty');
|
||||
}
|
||||
|
||||
if (code.startsWith("monero_node:"))
|
||||
code = code.replaceFirst("monero_node:", "tcp://");
|
||||
if (code.startsWith("monero_node:")) code = code.replaceFirst("monero_node:", "tcp://");
|
||||
if (!code.contains('://')) code = 'tcp://$code';
|
||||
|
||||
final uri = Uri.tryParse(code);
|
||||
|
||||
@@ -16,7 +16,6 @@ import 'package:cake_wallet/reactions/wallet_connect.dart';
|
||||
|
||||
part 'node_list_view_model.g.dart';
|
||||
|
||||
|
||||
class NodeSpeed {
|
||||
final String iconPath;
|
||||
final String darkIconPath;
|
||||
@@ -24,21 +23,20 @@ class NodeSpeed {
|
||||
// fraction of best node ping needed to be classified as this speed.
|
||||
final double treshold;
|
||||
|
||||
const NodeSpeed._(this.iconPath, this.darkIconPath, this.treshold);
|
||||
const NodeSpeed._(this.iconPath, this.darkIconPath, this.treshold);
|
||||
|
||||
static const disconnected = NodeSpeed._(
|
||||
"assets/new-ui/node_speed_badges/disconnected.svg", "assets/new-ui/node_speed_badges/disconnected-dark.svg", 0);
|
||||
static const slow = NodeSpeed._(
|
||||
"assets/new-ui/node_speed_badges/slow.svg", "assets/new-ui/node_speed_badges/slow-dark.svg", 0);
|
||||
static const medium = NodeSpeed._(
|
||||
"assets/new-ui/node_speed_badges/medium.svg", "assets/new-ui/node_speed_badges/medium.svg", 0.5);
|
||||
static const disconnected = NodeSpeed._("assets/new-ui/node_speed_badges/disconnected.svg",
|
||||
"assets/new-ui/node_speed_badges/disconnected-dark.svg", 0);
|
||||
static const slow = NodeSpeed._("assets/new-ui/node_speed_badges/slow.svg",
|
||||
"assets/new-ui/node_speed_badges/slow-dark.svg", 0);
|
||||
static const medium = NodeSpeed._("assets/new-ui/node_speed_badges/medium.svg",
|
||||
"assets/new-ui/node_speed_badges/medium.svg", 0.5);
|
||||
static const fast = NodeSpeed._(
|
||||
"assets/new-ui/node_speed_badges/fast.svg", "assets/new-ui/node_speed_badges/fast.svg", 0.8);
|
||||
|
||||
static const all = [fast, medium, slow, disconnected];
|
||||
}
|
||||
|
||||
|
||||
class NodeListViewModel = NodeListViewModelBase with _$NodeListViewModel;
|
||||
|
||||
abstract class NodeListViewModelBase with Store {
|
||||
@@ -63,7 +61,6 @@ abstract class NodeListViewModelBase with Store {
|
||||
bindNodes();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@computed
|
||||
Node get currentNode {
|
||||
@@ -103,9 +100,8 @@ abstract class NodeListViewModelBase with Store {
|
||||
final bool isPow;
|
||||
final ObservableMap<String, int> _nodeSpeeds;
|
||||
|
||||
|
||||
@computed
|
||||
List<Node> get nonCurrentNodes => nodes.where((item)=>item != currentNode).toList();
|
||||
List<Node> get nonCurrentNodes => nodes.where((item) => item != currentNode).toList();
|
||||
|
||||
@observable
|
||||
bool isTestingNodeSpeed = false;
|
||||
@@ -117,9 +113,8 @@ abstract class NodeListViewModelBase with Store {
|
||||
final nodes = this.nodes.toList();
|
||||
await Future.wait(nodes.map((node) async {
|
||||
final sw = Stopwatch()..start();
|
||||
final res = await node
|
||||
.requestNode()
|
||||
.timeout(const Duration(seconds: 10), onTimeout: () => false);
|
||||
final res =
|
||||
await node.requestNode().timeout(const Duration(seconds: 10), onTimeout: () => false);
|
||||
sw.stop();
|
||||
if (res) {
|
||||
_nodeSpeeds[node.uriRaw] = sw.elapsedMilliseconds;
|
||||
@@ -163,7 +158,6 @@ abstract class NodeListViewModelBase with Store {
|
||||
Node node;
|
||||
if (walletType == WalletType.bitcoin && wallet.isTestnet) {
|
||||
node = (await getBitcoinTestnetDefaultElectrumServer())!;
|
||||
|
||||
} else if (isEVMCompatibleChain(walletType)) {
|
||||
final chainId = evm!.getSelectedChainId(wallet);
|
||||
if (chainId != null) {
|
||||
@@ -205,12 +199,11 @@ abstract class NodeListViewModelBase with Store {
|
||||
}
|
||||
|
||||
// For non-EVM wallets, use the wallet type directly
|
||||
if(isPow) {
|
||||
if (isPow) {
|
||||
settingsStore.powNodes[walletType] = node;
|
||||
} else {
|
||||
settingsStore.nodes[walletType] = node;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@action
|
||||
@@ -235,7 +228,8 @@ abstract class NodeListViewModelBase with Store {
|
||||
}
|
||||
|
||||
// For non-EVM wallets, use the wallet type directly
|
||||
nodes.addAll(isPow ? await Node.getAllForWalletTypePow(walletType) : await Node.getAllForWalletType(walletType));
|
||||
|
||||
nodes.addAll(isPow
|
||||
? await Node.getAllForWalletTypePow(walletType)
|
||||
: await Node.getAllForWalletType(walletType));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
|
||||
|
||||
Reference in New Issue
Block a user