mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2025-05-18 10:04:40 +00:00
add tor proxy support to cw_evm, cw_tron and cw_polygon [run tests]
This commit is contained in:
parent
884b5c3f56
commit
9b55b8b179
6 changed files with 27 additions and 13 deletions
cw_ethereum/lib
cw_evm/lib
cw_polygon/lib
cw_tron/lib
cw_zano
lib/entities
|
@ -19,7 +19,7 @@ class EthereumClient extends EVMChainClient {
|
|||
Future<List<EVMChainTransactionModel>> fetchTransactions(String address,
|
||||
{String? contractAddress}) async {
|
||||
try {
|
||||
final response = await httpClient.get(Uri.https("api.etherscan.io", "/api", {
|
||||
final response = await client.get(Uri.https("api.etherscan.io", "/api", {
|
||||
"module": "account",
|
||||
"action": contractAddress != null ? "tokentx" : "txlist",
|
||||
if (contractAddress != null) "contractaddress": contractAddress,
|
||||
|
@ -50,7 +50,7 @@ class EthereumClient extends EVMChainClient {
|
|||
@override
|
||||
Future<List<EVMChainTransactionModel>> fetchInternalTransactions(String address) async {
|
||||
try {
|
||||
final response = await httpClient.get(Uri.https("api.etherscan.io", "/api", {
|
||||
final response = await client.get(Uri.https("api.etherscan.io", "/api", {
|
||||
"module": "account",
|
||||
"action": "txlistinternal",
|
||||
"address": address,
|
||||
|
|
|
@ -5,6 +5,7 @@ import 'dart:developer';
|
|||
import 'package:cw_core/crypto_currency.dart';
|
||||
import 'package:cw_core/erc20_token.dart';
|
||||
import 'package:cw_core/node.dart';
|
||||
import 'package:cw_core/utils/http_client.dart';
|
||||
import 'package:cw_evm/evm_chain_transaction_model.dart';
|
||||
import 'package:cw_evm/evm_chain_transaction_priority.dart';
|
||||
import 'package:cw_evm/evm_erc20_balance.dart';
|
||||
|
@ -12,13 +13,15 @@ import 'package:cw_evm/pending_evm_chain_transaction.dart';
|
|||
import 'package:cw_evm/.secrets.g.dart' as secrets;
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:hex/hex.dart' as hex;
|
||||
import 'package:http/http.dart';
|
||||
import 'package:http/http.dart' as http;
|
||||
import 'package:web3dart/web3dart.dart';
|
||||
import 'package:http/io_client.dart' as ioc;
|
||||
|
||||
import 'contract/erc20.dart';
|
||||
|
||||
abstract class EVMChainClient {
|
||||
final httpClient = Client();
|
||||
final httpClient = getHttpClient();
|
||||
late final http.Client client = ioc.IOClient(httpClient);
|
||||
Web3Client? _client;
|
||||
|
||||
//! To be overridden by all child classes
|
||||
|
@ -47,7 +50,7 @@ abstract class EVMChainClient {
|
|||
}
|
||||
|
||||
_client =
|
||||
Web3Client(isModifiedNodeUri ? rpcUri!.toString() : node.uri.toString(), httpClient);
|
||||
Web3Client(isModifiedNodeUri ? rpcUri!.toString() : node.uri.toString(), client);
|
||||
|
||||
return true;
|
||||
} catch (e) {
|
||||
|
@ -293,7 +296,7 @@ abstract class EVMChainClient {
|
|||
},
|
||||
);
|
||||
|
||||
final response = await httpClient.get(
|
||||
final response = await client.get(
|
||||
uri,
|
||||
headers: {
|
||||
"Accept": "application/json",
|
||||
|
|
|
@ -40,7 +40,7 @@ class PolygonClient extends EVMChainClient {
|
|||
Future<List<EVMChainTransactionModel>> fetchTransactions(String address,
|
||||
{String? contractAddress}) async {
|
||||
try {
|
||||
final response = await httpClient.get(Uri.https("api.polygonscan.com", "/api", {
|
||||
final response = await client.get(Uri.https("api.polygonscan.com", "/api", {
|
||||
"module": "account",
|
||||
"action": contractAddress != null ? "tokentx" : "txlist",
|
||||
if (contractAddress != null) "contractaddress": contractAddress,
|
||||
|
@ -67,7 +67,7 @@ class PolygonClient extends EVMChainClient {
|
|||
@override
|
||||
Future<List<EVMChainTransactionModel>> fetchInternalTransactions(String address) async {
|
||||
try {
|
||||
final response = await httpClient.get(Uri.https("api.polygonscan.io", "/api", {
|
||||
final response = await client.get(Uri.https("api.polygonscan.io", "/api", {
|
||||
"module": "account",
|
||||
"action": "txlistinternal",
|
||||
"address": address,
|
||||
|
|
|
@ -5,6 +5,7 @@ import 'dart:developer';
|
|||
import 'package:blockchain_utils/blockchain_utils.dart';
|
||||
import 'package:cw_core/crypto_currency.dart';
|
||||
import 'package:cw_core/node.dart';
|
||||
import 'package:cw_core/utils/http_client.dart';
|
||||
import 'package:cw_tron/pending_tron_transaction.dart';
|
||||
import 'package:cw_tron/tron_abi.dart';
|
||||
import 'package:cw_tron/tron_balance.dart';
|
||||
|
@ -16,9 +17,12 @@ import 'package:flutter/services.dart';
|
|||
import 'package:http/http.dart';
|
||||
import '.secrets.g.dart' as secrets;
|
||||
import 'package:on_chain/on_chain.dart';
|
||||
import 'package:http/io_client.dart' as ioc;
|
||||
|
||||
class TronClient {
|
||||
final httpClient = Client();
|
||||
final httpClient = getHttpClient();
|
||||
late final Client client = ioc.IOClient(httpClient);
|
||||
|
||||
TronProvider? _provider;
|
||||
// This is an internal tracker, so we don't have to "refetch".
|
||||
int _nativeTxEstimatedFee = 0;
|
||||
|
@ -28,7 +32,7 @@ class TronClient {
|
|||
Future<List<TronTransactionModel>> fetchTransactions(String address,
|
||||
{String? contractAddress}) async {
|
||||
try {
|
||||
final response = await httpClient.get(
|
||||
final response = await client.get(
|
||||
Uri.https(
|
||||
"api.trongrid.io",
|
||||
"/v1/accounts/$address/transactions",
|
||||
|
@ -61,7 +65,7 @@ class TronClient {
|
|||
|
||||
Future<List<TronTRC20TransactionModel>> fetchTrc20ExcludedTransactions(String address) async {
|
||||
try {
|
||||
final response = await httpClient.get(
|
||||
final response = await client.get(
|
||||
Uri.https(
|
||||
"api.trongrid.io",
|
||||
"/v1/accounts/$address/transactions/trc20",
|
||||
|
|
|
@ -751,7 +751,7 @@ packages:
|
|||
sha256: "62ee18aca144e4a9f29d212f5a4c6a053be252b895ab14b5821996cff4ed90fe"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.0.1"
|
||||
version: "1.0.2"
|
||||
tor:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
|
|
@ -1,14 +1,18 @@
|
|||
import 'package:cake_wallet/ethereum/ethereum.dart';
|
||||
import 'package:cake_wallet/polygon/polygon.dart';
|
||||
import 'package:cw_core/utils/http_client.dart';
|
||||
import 'package:cw_core/utils/print_verbose.dart';
|
||||
import 'package:cw_core/wallet_base.dart';
|
||||
import 'package:cw_core/wallet_type.dart';
|
||||
import 'package:ens_dart/ens_dart.dart';
|
||||
import 'package:http/http.dart';
|
||||
import 'package:web3dart/web3dart.dart';
|
||||
import 'package:http/io_client.dart' as ioc;
|
||||
|
||||
class EnsRecord {
|
||||
|
||||
static Future<String> fetchEnsAddress(String name, {WalletBase? wallet}) async {
|
||||
|
||||
Web3Client? _client;
|
||||
|
||||
if (wallet != null && wallet.type == WalletType.ethereum) {
|
||||
|
@ -20,7 +24,10 @@ class EnsRecord {
|
|||
}
|
||||
|
||||
if (_client == null) {
|
||||
_client = Web3Client("https://ethereum-rpc.publicnode.com", Client());
|
||||
final httpClient = getHttpClient();
|
||||
late final Client client = ioc.IOClient(httpClient);
|
||||
|
||||
_client = Web3Client("https://ethereum-rpc.publicnode.com", client);
|
||||
}
|
||||
|
||||
try {
|
||||
|
|
Loading…
Reference in a new issue