mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2025-06-28 20:39:51 +00:00
Enable proxy for http.Client [run tests]
This commit is contained in:
parent
3bc3b03a37
commit
1fec0df962
4 changed files with 29 additions and 28 deletions
|
@ -5,6 +5,7 @@ import 'dart:math' as math;
|
|||
import 'package:cw_core/crypto_currency.dart';
|
||||
import 'package:cw_core/node.dart';
|
||||
import 'package:cw_core/solana_rpc_http_service.dart';
|
||||
import 'package:cw_core/utils/http_client.dart';
|
||||
import 'package:cw_core/utils/print_verbose.dart';
|
||||
import 'package:cw_solana/pending_solana_transaction.dart';
|
||||
import 'package:cw_solana/solana_balance.dart';
|
||||
|
@ -18,6 +19,8 @@ import 'package:on_chain/solana/src/models/pda/pda.dart';
|
|||
import 'package:blockchain_utils/blockchain_utils.dart';
|
||||
import 'package:on_chain/solana/src/rpc/models/models/confirmed_transaction_meta.dart';
|
||||
import '.secrets.g.dart' as secrets;
|
||||
import 'package:http/io_client.dart' as ioc;
|
||||
|
||||
|
||||
class SolanaWalletClient {
|
||||
final httpClient = http.Client();
|
||||
|
@ -992,7 +995,9 @@ class SolanaWalletClient {
|
|||
if (uri.isEmpty || uri == '…') return null;
|
||||
|
||||
try {
|
||||
final response = await httpClient.get(Uri.parse(uri));
|
||||
final httpClient = getHttpClient();
|
||||
final http.Client client = ioc.IOClient(httpClient);
|
||||
final response = await client.get(Uri.parse(uri));
|
||||
|
||||
final jsonResponse = json.decode(response.body) as Map<String, dynamic>;
|
||||
|
||||
|
|
|
@ -1,22 +1,25 @@
|
|||
import 'dart:convert';
|
||||
|
||||
import 'package:cw_core/utils/http_client.dart';
|
||||
import 'package:http/http.dart' as http;
|
||||
import 'package:http/io_client.dart' as ioc;
|
||||
import 'package:on_chain/tron/tron.dart';
|
||||
import '.secrets.g.dart' as secrets;
|
||||
|
||||
class TronHTTPProvider implements TronServiceProvider {
|
||||
TronHTTPProvider(
|
||||
{required this.url,
|
||||
http.Client? client,
|
||||
this.defaultRequestTimeout = const Duration(seconds: 30)})
|
||||
: client = client ?? http.Client();
|
||||
this.defaultRequestTimeout = const Duration(seconds: 30)});
|
||||
|
||||
@override
|
||||
final String url;
|
||||
final http.Client client;
|
||||
final httpClient = getHttpClient();
|
||||
late final http.Client client = ioc.IOClient(httpClient);
|
||||
final Duration defaultRequestTimeout;
|
||||
|
||||
@override
|
||||
Future<Map<String, dynamic>> get(TronRequestDetails params, [Duration? timeout]) async {
|
||||
Future<Map<String, dynamic>> get(TronRequestDetails params,
|
||||
[Duration? timeout]) async {
|
||||
final response = await client.get(Uri.parse(params.url(url)), headers: {
|
||||
'Content-Type': 'application/json',
|
||||
if (url.contains("trongrid")) 'TRON-PRO-API-KEY': secrets.tronGridApiKey,
|
||||
|
@ -27,13 +30,16 @@ class TronHTTPProvider implements TronServiceProvider {
|
|||
}
|
||||
|
||||
@override
|
||||
Future<Map<String, dynamic>> post(TronRequestDetails params, [Duration? timeout]) async {
|
||||
Future<Map<String, dynamic>> post(TronRequestDetails params,
|
||||
[Duration? timeout]) async {
|
||||
final response = await client
|
||||
.post(Uri.parse(params.url(url)),
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
if (url.contains("trongrid")) 'TRON-PRO-API-KEY': secrets.tronGridApiKey,
|
||||
if (url.contains("nownodes")) 'api-key': secrets.tronNowNodesApiKey,
|
||||
if (url.contains("trongrid"))
|
||||
'TRON-PRO-API-KEY': secrets.tronGridApiKey,
|
||||
if (url.contains("nownodes"))
|
||||
'api-key': secrets.tronNowNodesApiKey,
|
||||
},
|
||||
body: params.toRequestBody())
|
||||
.timeout(timeout ?? defaultRequestTimeout);
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import 'package:cw_core/wallet_credentials.dart';
|
||||
import 'package:cw_core/address_info.dart';
|
||||
import 'package:cw_core/wallet_info.dart';
|
||||
import 'package:cw_core/transaction_priority.dart';
|
||||
import 'package:cw_core/output_info.dart';
|
||||
|
@ -25,29 +26,22 @@ abstract class Decred {
|
|||
WalletCredentials createDecredNewWalletCredentials(
|
||||
{required String name, WalletInfo? walletInfo});
|
||||
WalletCredentials createDecredRestoreWalletFromSeedCredentials(
|
||||
{required String name,
|
||||
required String mnemonic,
|
||||
required String password});
|
||||
{required String name, required String mnemonic, required String password});
|
||||
WalletCredentials createDecredRestoreWalletFromPubkeyCredentials(
|
||||
{required String name,
|
||||
required String pubkey,
|
||||
required String password});
|
||||
WalletService createDecredWalletService(Box<WalletInfo> walletInfoSource,
|
||||
Box<UnspentCoinsInfo> unspentCoinSource);
|
||||
{required String name, required String pubkey, required String password});
|
||||
WalletService createDecredWalletService(
|
||||
Box<WalletInfo> walletInfoSource, Box<UnspentCoinsInfo> unspentCoinSource);
|
||||
|
||||
List<TransactionPriority> getTransactionPriorities();
|
||||
TransactionPriority getMediumTransactionPriority();
|
||||
TransactionPriority getDecredTransactionPriorityMedium();
|
||||
TransactionPriority getDecredTransactionPrioritySlow();
|
||||
TransactionPriority deserializeDecredTransactionPriority(int raw);
|
||||
|
||||
int getFeeRate(Object wallet, TransactionPriority priority);
|
||||
Object createDecredTransactionCredentials(
|
||||
List<Output> outputs, TransactionPriority priority);
|
||||
Object createDecredTransactionCredentials(List<Output> outputs, TransactionPriority priority);
|
||||
|
||||
List<String> getAddresses(Object wallet);
|
||||
String getAddress(Object wallet);
|
||||
Future<void> generateNewAddress(Object wallet);
|
||||
List<AddressInfo> getAddressInfos(Object wallet);
|
||||
Future<void> updateAddress(Object wallet, String address, String label);
|
||||
Future<void> generateNewAddress(Object wallet, String label);
|
||||
|
||||
String formatterDecredAmountToString({required int amount});
|
||||
double formatterDecredAmountToDouble({required int amount});
|
||||
|
|
|
@ -167,10 +167,6 @@ dependency_overrides:
|
|||
url: https://github.com/cake-tech/bitcoin_base
|
||||
ref: cake-update-v9
|
||||
ffi: 2.1.0
|
||||
ledger_flutter_plus:
|
||||
git:
|
||||
url: https://github.com/vespr-wallet/ledger-flutter-plus
|
||||
ref: c2e341d8038f1108690ad6f80f7b4b7156aacc76
|
||||
web_socket_channel: ^3.0.2
|
||||
freezed_annotation: 2.4.4
|
||||
tor:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue