mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2024-12-31 16:09:49 +00:00
Add initial flow for Now Nodes
This commit is contained in:
parent
2612c9afcf
commit
fc0a8bc16b
4 changed files with 22 additions and 4 deletions
|
@ -7,4 +7,7 @@
|
||||||
-
|
-
|
||||||
uri: eth-mainnet.public.blastapi.io
|
uri: eth-mainnet.public.blastapi.io
|
||||||
-
|
-
|
||||||
uri: ethereum.publicnode.com
|
uri: ethereum.publicnode.com
|
||||||
|
-
|
||||||
|
uri: eth.nownodes.io
|
||||||
|
usesApiKey: true
|
|
@ -20,6 +20,7 @@ class Node extends HiveObject with Keyable {
|
||||||
this.useSSL,
|
this.useSSL,
|
||||||
this.trusted = false,
|
this.trusted = false,
|
||||||
this.socksProxyAddress,
|
this.socksProxyAddress,
|
||||||
|
this.usesApiKey = false,
|
||||||
String? uri,
|
String? uri,
|
||||||
WalletType? type,
|
WalletType? type,
|
||||||
}) {
|
}) {
|
||||||
|
@ -37,7 +38,8 @@ class Node extends HiveObject with Keyable {
|
||||||
password = map['password'] as String?,
|
password = map['password'] as String?,
|
||||||
useSSL = map['useSSL'] as bool?,
|
useSSL = map['useSSL'] as bool?,
|
||||||
trusted = map['trusted'] as bool? ?? false,
|
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 typeId = NODE_TYPE_ID;
|
||||||
static const boxName = 'Nodes';
|
static const boxName = 'Nodes';
|
||||||
|
@ -63,6 +65,9 @@ class Node extends HiveObject with Keyable {
|
||||||
@HiveField(6)
|
@HiveField(6)
|
||||||
String? socksProxyAddress;
|
String? socksProxyAddress;
|
||||||
|
|
||||||
|
@HiveField(7, defaultValue: false)
|
||||||
|
bool? usesApiKey;
|
||||||
|
|
||||||
bool get isSSL => useSSL ?? false;
|
bool get isSSL => useSSL ?? false;
|
||||||
|
|
||||||
bool get useSocksProxy => socksProxyAddress == null ? false : socksProxyAddress!.isNotEmpty;
|
bool get useSocksProxy => socksProxyAddress == null ? false : socksProxyAddress!.isNotEmpty;
|
||||||
|
|
|
@ -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/evm_chain_transaction_model.dart';
|
||||||
import 'package:cw_evm/pending_evm_chain_transaction.dart';
|
import 'package:cw_evm/pending_evm_chain_transaction.dart';
|
||||||
import 'package:cw_evm/evm_chain_transaction_priority.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:flutter/services.dart';
|
||||||
|
|
||||||
import 'package:http/http.dart';
|
import 'package:http/http.dart';
|
||||||
|
@ -32,7 +33,14 @@ abstract class EVMChainClient {
|
||||||
|
|
||||||
bool connect(Node node) {
|
bool connect(Node node) {
|
||||||
try {
|
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;
|
return true;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
@ -40,6 +48,8 @@ abstract class EVMChainClient {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String getApiKey() => "/${secrets.nodesAPIKey}";
|
||||||
|
|
||||||
void setListeners(EthereumAddress userAddress, Function() onNewTransaction) async {
|
void setListeners(EthereumAddress userAddress, Function() onNewTransaction) async {
|
||||||
// _client?.pendingTransactions().listen((transactionHash) async {
|
// _client?.pendingTransactions().listen((transactionHash) async {
|
||||||
// final transaction = await _client!.getTransactionByHash(transactionHash);
|
// final transaction = await _client!.getTransactionByHash(transactionHash);
|
||||||
|
|
|
@ -25,7 +25,7 @@ const newCakeWalletMoneroUri = 'xmr-node.cakewallet.com:18081';
|
||||||
const cakeWalletBitcoinElectrumUri = 'electrum.cakewallet.com:50002';
|
const cakeWalletBitcoinElectrumUri = 'electrum.cakewallet.com:50002';
|
||||||
const cakeWalletLitecoinElectrumUri = 'ltc-electrum.cakewallet.com:50002';
|
const cakeWalletLitecoinElectrumUri = 'ltc-electrum.cakewallet.com:50002';
|
||||||
const havenDefaultNodeUri = 'nodes.havenprotocol.org:443';
|
const havenDefaultNodeUri = 'nodes.havenprotocol.org:443';
|
||||||
const ethereumDefaultNodeUri = 'ethereum.publicnode.com';
|
const ethereumDefaultNodeUri = 'eth.nownodes.io';
|
||||||
const polygonDefaultNodeUri = 'polygon-bor.publicnode.com';
|
const polygonDefaultNodeUri = 'polygon-bor.publicnode.com';
|
||||||
const cakeWalletBitcoinCashDefaultNodeUri = 'bitcoincash.stackwallet.com:50002';
|
const cakeWalletBitcoinCashDefaultNodeUri = 'bitcoincash.stackwallet.com:50002';
|
||||||
const nanoDefaultNodeUri = 'rpc.nano.to';
|
const nanoDefaultNodeUri = 'rpc.nano.to';
|
||||||
|
|
Loading…
Reference in a new issue