mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2024-11-01 01:47:41 +00:00
b3d579c24a
* chore: Initial setup for polygon package * feat: Add polygon node urls * feat: Add Polygon(MATIC) wallet WIP * feat: Add Polygon(MATIC) wallet WIP * feat: Add Polygon MATIC wallet [skip ci] * fix: Issue with create/restore wallet for polygon * feat: Add erc20 tokens for polygon * feat: Adding Polygon MATIC Wallet * fix: Add build command for polygon to workflow file to fix failing action * fix: Switch evm to not display additional balance * chore: Sync with remote * fix: Revert change to inject app script * feat: Add polygon erc20 tokens * feat: Increase migration version * fix: Restore from QR address validator fix * fix: Adjust wallet connect connection flow to adapt to wallet type * fix: Make wallet fetch nfts based on the current wallet type * fix: Make wallet fetch nfts based on the current wallet type * fix: Try fetching transactions with moralis * fix: Requested review changes * fix: Error creating new wallet * fix: Revert script * fix: Exclude spam NFTs from nft listing API response * Update default_erc20_tokens.dart * replace matic with matic poly * Add polygon wallet scheme to app links * style: reformat default_settings_migration.dart * minor enhancement * fix using different wallet function for setting the transaction priorities * fix: Add chain to calls * Add USDC.e to initial coins * Add other default polygon node * Use Polygon scan some UI fixes * Add polygon scan api key to secrets generation code --------- Co-authored-by: Omar Hatem <omarh.ismail1@gmail.com>
181 lines
No EOL
5.1 KiB
Dart
181 lines
No EOL
5.1 KiB
Dart
import 'package:flutter/services.dart';
|
|
import 'package:hive/hive.dart';
|
|
import "package:yaml/yaml.dart";
|
|
import 'package:cw_core/node.dart';
|
|
import 'package:cw_core/wallet_type.dart';
|
|
|
|
Future<List<Node>> loadDefaultNodes() async {
|
|
final nodesRaw = await rootBundle.loadString('assets/node_list.yml');
|
|
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));
|
|
node.type = WalletType.monero;
|
|
nodes.add(node);
|
|
}
|
|
}
|
|
|
|
return nodes;
|
|
}
|
|
|
|
Future<List<Node>> loadBitcoinElectrumServerList() async {
|
|
final serverListRaw = await rootBundle.loadString('assets/bitcoin_electrum_server_list.yml');
|
|
final loadedServerList = loadYaml(serverListRaw) as YamlList;
|
|
final serverList = <Node>[];
|
|
|
|
for (final raw in loadedServerList) {
|
|
if (raw is Map) {
|
|
final node = Node.fromMap(Map<String, Object>.from(raw));
|
|
node.type = WalletType.bitcoin;
|
|
serverList.add(node);
|
|
}
|
|
}
|
|
|
|
return serverList;
|
|
}
|
|
|
|
Future<List<Node>> loadLitecoinElectrumServerList() async {
|
|
final serverListRaw = await rootBundle.loadString('assets/litecoin_electrum_server_list.yml');
|
|
final loadedServerList = loadYaml(serverListRaw) as YamlList;
|
|
final serverList = <Node>[];
|
|
|
|
for (final raw in loadedServerList) {
|
|
if (raw is Map) {
|
|
final node = Node.fromMap(Map<String, Object>.from(raw));
|
|
node.type = WalletType.litecoin;
|
|
serverList.add(node);
|
|
}
|
|
}
|
|
|
|
return serverList;
|
|
}
|
|
|
|
Future<List<Node>> loadDefaultHavenNodes() async {
|
|
final nodesRaw = await rootBundle.loadString('assets/haven_node_list.yml');
|
|
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));
|
|
node.type = WalletType.haven;
|
|
nodes.add(node);
|
|
}
|
|
}
|
|
|
|
return nodes;
|
|
}
|
|
|
|
Future<List<Node>> loadDefaultEthereumNodes() async {
|
|
final nodesRaw = await rootBundle.loadString('assets/ethereum_server_list.yml');
|
|
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));
|
|
node.type = WalletType.ethereum;
|
|
nodes.add(node);
|
|
}
|
|
}
|
|
|
|
return nodes;
|
|
}
|
|
|
|
Future<List<Node>> loadBitcoinCashElectrumServerList() async {
|
|
final serverListRaw =
|
|
await rootBundle.loadString('assets/bitcoin_cash_electrum_server_list.yml');
|
|
final loadedServerList = loadYaml(serverListRaw) as YamlList;
|
|
final serverList = <Node>[];
|
|
|
|
for (final raw in loadedServerList) {
|
|
if (raw is Map) {
|
|
final node = Node.fromMap(Map<String, Object>.from(raw));
|
|
node.type = WalletType.bitcoinCash;
|
|
serverList.add(node);
|
|
}
|
|
}
|
|
|
|
return serverList;
|
|
}
|
|
|
|
Future<List<Node>> loadDefaultNanoNodes() async {
|
|
final nodesRaw = await rootBundle.loadString('assets/nano_node_list.yml');
|
|
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));
|
|
node.type = WalletType.nano;
|
|
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;
|
|
}
|
|
|
|
Future<List<Node>> loadDefaultPolygonNodes() async {
|
|
final nodesRaw = await rootBundle.loadString('assets/polygon_node_list.yml');
|
|
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));
|
|
node.type = WalletType.polygon;
|
|
nodes.add(node);
|
|
}
|
|
}
|
|
|
|
return nodes;
|
|
}
|
|
|
|
Future<void> resetToDefault(Box<Node> nodeSource) async {
|
|
final moneroNodes = await loadDefaultNodes();
|
|
final bitcoinElectrumServerList = await loadBitcoinElectrumServerList();
|
|
final litecoinElectrumServerList = await loadLitecoinElectrumServerList();
|
|
final bitcoinCashElectrumServerList = await loadBitcoinCashElectrumServerList();
|
|
final havenNodes = await loadDefaultHavenNodes();
|
|
final ethereumNodes = await loadDefaultEthereumNodes();
|
|
final nanoNodes = await loadDefaultNanoNodes();
|
|
final polygonNodes = await loadDefaultPolygonNodes();
|
|
|
|
|
|
final nodes = moneroNodes +
|
|
bitcoinElectrumServerList +
|
|
litecoinElectrumServerList +
|
|
havenNodes +
|
|
ethereumNodes +
|
|
bitcoinCashElectrumServerList +
|
|
nanoNodes +
|
|
polygonNodes;
|
|
|
|
await nodeSource.clear();
|
|
await nodeSource.addAll(nodes);
|
|
}
|
|
|
|
Future<void> resetPowToDefault(Box<Node> powNodeSource) async {
|
|
final nanoPowNodes = await loadDefaultNanoPowNodes();
|
|
final nodes = nanoPowNodes;
|
|
await powNodeSource.clear();
|
|
await powNodeSource.addAll(nodes);
|
|
} |