Add initial flow for Now Nodes

This commit is contained in:
OmarHatem 2024-02-04 02:27:29 +02:00
parent 2612c9afcf
commit fc0a8bc16b
4 changed files with 22 additions and 4 deletions

View file

@ -8,3 +8,6 @@
uri: eth-mainnet.public.blastapi.io
-
uri: ethereum.publicnode.com
-
uri: eth.nownodes.io
usesApiKey: true

View file

@ -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;

View file

@ -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);

View file

@ -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';