diff --git a/assets/ethereum_server_list.yml b/assets/ethereum_server_list.yml index 125085d88..185b9e56f 100644 --- a/assets/ethereum_server_list.yml +++ b/assets/ethereum_server_list.yml @@ -7,4 +7,7 @@ - uri: eth-mainnet.public.blastapi.io - - uri: ethereum.publicnode.com \ No newline at end of file + uri: ethereum.publicnode.com +- + uri: eth.nownodes.io + usesApiKey: true \ No newline at end of file diff --git a/cw_core/lib/node.dart b/cw_core/lib/node.dart index 2c43dd21a..a7d6e1b4a 100644 --- a/cw_core/lib/node.dart +++ b/cw_core/lib/node.dart @@ -20,6 +20,7 @@ class Node extends HiveObject with Keyable { this.useSSL, this.trusted = false, this.socksProxyAddress, + this.usesApiKey = false, String? uri, WalletType? type, }) { @@ -37,7 +38,8 @@ class Node extends HiveObject with Keyable { password = map['password'] as String?, useSSL = map['useSSL'] as bool?, trusted = map['trusted'] as bool? ?? false, - socksProxyAddress = map['socksProxyPort'] as String?; + socksProxyAddress = map['socksProxyPort'] as String?, + usesApiKey = map['usesApiKey'] as bool? ?? false; static const typeId = NODE_TYPE_ID; static const boxName = 'Nodes'; @@ -63,6 +65,9 @@ class Node extends HiveObject with Keyable { @HiveField(6) String? socksProxyAddress; + @HiveField(7, defaultValue: false) + bool? usesApiKey; + bool get isSSL => useSSL ?? false; bool get useSocksProxy => socksProxyAddress == null ? false : socksProxyAddress!.isNotEmpty; diff --git a/cw_evm/lib/evm_chain_client.dart b/cw_evm/lib/evm_chain_client.dart index de5b3874a..9ce522c18 100644 --- a/cw_evm/lib/evm_chain_client.dart +++ b/cw_evm/lib/evm_chain_client.dart @@ -9,6 +9,7 @@ import 'package:cw_evm/evm_erc20_balance.dart'; import 'package:cw_evm/evm_chain_transaction_model.dart'; import 'package:cw_evm/pending_evm_chain_transaction.dart'; import 'package:cw_evm/evm_chain_transaction_priority.dart'; +import 'package:cw_evm/.secrets.g.dart' as secrets; import 'package:flutter/services.dart'; import 'package:http/http.dart'; @@ -32,7 +33,14 @@ abstract class EVMChainClient { bool connect(Node node) { try { - _client = Web3Client(node.uri.toString(), httpClient); + String url = node.uri.toString(); + if (node.usesApiKey == true) { + url += getApiKey(); + } + print("@@@@@@@@@@@@"); + print(node.usesApiKey); + print(url); + _client = Web3Client(url, httpClient); return true; } catch (e) { @@ -40,6 +48,8 @@ abstract class EVMChainClient { } } + String getApiKey() => "/${secrets.nodesAPIKey}"; + void setListeners(EthereumAddress userAddress, Function() onNewTransaction) async { // _client?.pendingTransactions().listen((transactionHash) async { // final transaction = await _client!.getTransactionByHash(transactionHash); diff --git a/lib/entities/default_settings_migration.dart b/lib/entities/default_settings_migration.dart index 68e76d423..13671d922 100644 --- a/lib/entities/default_settings_migration.dart +++ b/lib/entities/default_settings_migration.dart @@ -25,7 +25,7 @@ const newCakeWalletMoneroUri = 'xmr-node.cakewallet.com:18081'; const cakeWalletBitcoinElectrumUri = 'electrum.cakewallet.com:50002'; const cakeWalletLitecoinElectrumUri = 'ltc-electrum.cakewallet.com:50002'; const havenDefaultNodeUri = 'nodes.havenprotocol.org:443'; -const ethereumDefaultNodeUri = 'ethereum.publicnode.com'; +const ethereumDefaultNodeUri = 'eth.nownodes.io'; const polygonDefaultNodeUri = 'polygon-bor.publicnode.com'; const cakeWalletBitcoinCashDefaultNodeUri = 'bitcoincash.stackwallet.com:50002'; const nanoDefaultNodeUri = 'rpc.nano.to';