2020-01-04 21:31:52 +02:00
|
|
|
import 'package:flutter/services.dart';
|
|
|
|
import 'package:hive/hive.dart';
|
|
|
|
import "package:yaml/yaml.dart";
|
2021-12-24 14:37:24 +02:00
|
|
|
import 'package:cw_core/node.dart';
|
|
|
|
import 'package:cw_core/wallet_type.dart';
|
2020-01-04 21:31:52 +02:00
|
|
|
|
2025-03-21 04:18:47 +02:00
|
|
|
Future<List<Node>> loadDefaultNodes(WalletType type) async {
|
|
|
|
String path;
|
|
|
|
switch (type) {
|
|
|
|
case WalletType.monero:
|
|
|
|
path = 'assets/node_list.yml';
|
|
|
|
break;
|
|
|
|
case WalletType.bitcoin:
|
|
|
|
path = 'assets/bitcoin_electrum_server_list.yml';
|
|
|
|
break;
|
|
|
|
case WalletType.litecoin:
|
|
|
|
path = 'assets/litecoin_electrum_server_list.yml';
|
|
|
|
break;
|
|
|
|
case WalletType.haven:
|
|
|
|
path = 'assets/haven_node_list.yml';
|
|
|
|
break;
|
|
|
|
case WalletType.ethereum:
|
|
|
|
path = 'assets/ethereum_server_list.yml';
|
|
|
|
break;
|
|
|
|
case WalletType.nano:
|
|
|
|
path = 'assets/nano_node_list.yml';
|
|
|
|
break;
|
|
|
|
case WalletType.bitcoinCash:
|
|
|
|
path = 'assets/bitcoin_cash_electrum_server_list.yml';
|
|
|
|
break;
|
|
|
|
case WalletType.polygon:
|
|
|
|
path = 'assets/polygon_node_list.yml';
|
|
|
|
break;
|
|
|
|
case WalletType.solana:
|
|
|
|
path = 'assets/solana_node_list.yml';
|
|
|
|
break;
|
|
|
|
case WalletType.tron:
|
|
|
|
path = 'assets/tron_node_list.yml';
|
|
|
|
break;
|
|
|
|
case WalletType.wownero:
|
|
|
|
path = 'assets/wownero_node_list.yml';
|
|
|
|
break;
|
|
|
|
case WalletType.zano:
|
|
|
|
path = 'assets/zano_node_list.yml';
|
|
|
|
break;
|
|
|
|
case WalletType.decred:
|
|
|
|
path = 'assets/decred_node_list.yml';
|
|
|
|
break;
|
|
|
|
case WalletType.banano:
|
|
|
|
case WalletType.none:
|
|
|
|
path = '';
|
|
|
|
break;
|
2022-10-12 13:09:57 -04:00
|
|
|
}
|
2023-10-04 21:09:07 -04:00
|
|
|
|
2025-03-21 04:18:47 +02:00
|
|
|
final nodesRaw = await rootBundle.loadString(path);
|
2023-08-04 20:01:49 +03:00
|
|
|
final loadedNodes = loadYaml(nodesRaw) as YamlList;
|
|
|
|
final nodes = <Node>[];
|
|
|
|
|
|
|
|
for (final raw in loadedNodes) {
|
|
|
|
if (raw is Map) {
|
|
|
|
final node = Node.fromMap(Map<String, Object>.from(raw));
|
2025-03-21 04:18:47 +02:00
|
|
|
node.type = type;
|
2023-10-04 21:09:07 -04:00
|
|
|
nodes.add(node);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return nodes;
|
|
|
|
}
|
|
|
|
|
|
|
|
Future<List<Node>> loadDefaultNanoPowNodes() async {
|
|
|
|
final powNodesRaw = await rootBundle.loadString('assets/nano_pow_node_list.yml');
|
|
|
|
final loadedPowNodes = loadYaml(powNodesRaw) as YamlList;
|
|
|
|
final nodes = <Node>[];
|
|
|
|
|
|
|
|
for (final raw in loadedPowNodes) {
|
|
|
|
if (raw is Map) {
|
|
|
|
final node = Node.fromMap(Map<String, Object>.from(raw));
|
|
|
|
node.type = WalletType.nano;
|
|
|
|
nodes.add(node);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return nodes;
|
|
|
|
}
|
|
|
|
|
2023-10-13 01:50:16 +03:00
|
|
|
Future<void> resetToDefault(Box<Node> nodeSource) async {
|
2025-03-21 04:18:47 +02:00
|
|
|
final moneroNodes = await loadDefaultNodes(WalletType.monero);
|
|
|
|
final bitcoinElectrumServerList = await loadDefaultNodes(WalletType.bitcoin);
|
|
|
|
final litecoinElectrumServerList = await loadDefaultNodes(WalletType.litecoin);
|
|
|
|
final bitcoinCashElectrumServerList = await loadDefaultNodes(WalletType.bitcoinCash);
|
|
|
|
final havenNodes = await loadDefaultNodes(WalletType.haven);
|
|
|
|
final ethereumNodes = await loadDefaultNodes(WalletType.ethereum);
|
|
|
|
final nanoNodes = await loadDefaultNodes(WalletType.nano);
|
|
|
|
final polygonNodes = await loadDefaultNodes(WalletType.polygon);
|
|
|
|
final solanaNodes = await loadDefaultNodes(WalletType.solana);
|
|
|
|
final tronNodes = await loadDefaultNodes(WalletType.tron);
|
|
|
|
final decredNodes = await loadDefaultNodes(WalletType.decred);
|
|
|
|
final zanoNodes = await loadDefaultNodes(WalletType.zano);
|
2023-12-02 03:26:43 +01:00
|
|
|
|
2023-10-04 21:09:07 -04:00
|
|
|
final nodes = moneroNodes +
|
2022-03-30 17:57:04 +02:00
|
|
|
bitcoinElectrumServerList +
|
|
|
|
litecoinElectrumServerList +
|
2023-10-04 21:09:07 -04:00
|
|
|
havenNodes +
|
|
|
|
ethereumNodes +
|
2023-10-13 01:50:16 +03:00
|
|
|
bitcoinCashElectrumServerList +
|
2023-12-02 03:26:43 +01:00
|
|
|
nanoNodes +
|
CW-555-Add-Solana-Wallet (#1272)
* chore: Create cw_solana package and clean up files
* feat: Add Solana Wallet - Create, Restore form seed, restore from Key, Restore from QR, Send, Receive, transaction history, spl tokens
* fix: Make transactions file specific to solana only for solana transactions
* chore: Revert inject app details script
* fix: Fix issue with node and switch current node to main beta instead of testnet
* fix: Fix merge conflicts and adjust migration version
* fix: Fetch spl token error
Signed-off-by: Blazebrain <davidadegoke16@gmail.com>
* fix: Diplay and activate spl tokens bug
* fix: Review and fixes
* fix: reverted formatting for cryptocurrency class
* fix: Review comments, split sending flow into signing and sending separately, fix issues
* fix: Revert throwing unimplenented error
* chore: Fix comment
* chore: Fix comment
* fix: Errors in flow
* Update provider_types.dart [skip ci]
* fix: Issues with solana wallet
* Update solana_wallet.dart [skip ci]
* fix: Review comments
* fix: Date time config
* fix: Revert bash script for app details
* fix: Error with balance, displaying fees, fixing sent or received identifier bug, displaying token symbol with token transaction item in transactions list
* fix: Issues with address validation when sending spl tokens and walletconnect initial setup
* fix: Issues with sending, fetching transactions history, almost wrapping up walletconnect
* fix: Adjust imports that would affect monerocom building successfully
* fix: Refine transaction direction and continue work on walletconnect
* feat: Display SPL token transfers in the transaction history and finally settle the transaction direction
* fix: Delay in transactions history dispaly, show native token transactions first, then process spl token transactions
* feat: Switch node and revert solana chain id to previous id
* fix: Remove print statement
* fix: Remove await for transactions, fetch all transaction histories instantly and adjust solana send success message
* chore: Code refactoring and streamlined wallet type check for solana send success message
* fix: Make timeout error for node silent and add spl token images
---------
Signed-off-by: Blazebrain <davidadegoke16@gmail.com>
Co-authored-by: Omar Hatem <omarh.ismail1@gmail.com>
2024-02-23 14:39:19 +01:00
|
|
|
polygonNodes +
|
2025-03-21 04:18:47 +02:00
|
|
|
solanaNodes +
|
|
|
|
tronNodes +
|
|
|
|
zanoNodes +
|
|
|
|
decredNodes;
|
2020-01-04 21:31:52 +02:00
|
|
|
|
2020-01-08 14:26:34 +02:00
|
|
|
await nodeSource.clear();
|
2020-12-15 18:29:10 +02:00
|
|
|
await nodeSource.addAll(nodes);
|
2020-01-08 14:26:34 +02:00
|
|
|
}
|
2023-10-04 21:09:07 -04:00
|
|
|
|
2023-10-13 01:50:16 +03:00
|
|
|
Future<void> resetPowToDefault(Box<Node> powNodeSource) async {
|
2023-10-04 21:09:07 -04:00
|
|
|
final nanoPowNodes = await loadDefaultNanoPowNodes();
|
|
|
|
final nodes = nanoPowNodes;
|
|
|
|
await powNodeSource.clear();
|
|
|
|
await powNodeSource.addAll(nodes);
|
2023-12-13 15:03:07 +01:00
|
|
|
}
|