Skip to content

Commit

Permalink
Enable proxy for http.Client [run tests]
Browse files Browse the repository at this point in the history
  • Loading branch information
MrCyjaneK committed Jan 17, 2025
1 parent 74ab7d9 commit 7c8f648
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 7 deletions.
7 changes: 5 additions & 2 deletions cw_solana/lib/solana_client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,20 @@ import 'dart:math' as math;

import 'package:cw_core/crypto_currency.dart';
import 'package:cw_core/node.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';
import 'package:cw_solana/solana_exceptions.dart';
import 'package:cw_solana/solana_transaction_model.dart';
import 'package:http/http.dart' as http;
import 'package:http/io_client.dart' as ioc;
import 'package:solana/dto.dart';
import 'package:solana/encoder.dart';
import 'package:solana/solana.dart';
import '.secrets.g.dart' as secrets;

class SolanaWalletClient {
final httpClient = http.Client();
SolanaClient? _client;

bool connect(Node node) {
Expand Down Expand Up @@ -636,7 +637,9 @@ class SolanaWalletClient {

Future<String?> getIconImageFromTokenUri(String uri) async {
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>;

Expand Down
10 changes: 6 additions & 4 deletions cw_tron/lib/tron_http_provider.dart
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
import 'dart:convert';
import 'dart:io';

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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,11 @@ import 'package:cake_wallet/src/screens/wallet_connect/widgets/connection_widget
import 'package:cake_wallet/src/screens/wallet_connect/widgets/modals/web3_request_modal.dart';
import 'package:cake_wallet/src/screens/wallet_connect/utils/string_parsing.dart';
import 'package:convert/convert.dart';
import 'package:cw_core/utils/http_client.dart';
import 'package:eth_sig_util/eth_sig_util.dart';
import 'package:eth_sig_util/util/utils.dart';
import 'package:http/http.dart' as http;
import 'package:http/io_client.dart' as ioc;
import 'package:walletconnect_flutter_v2/walletconnect_flutter_v2.dart';
import 'package:web3dart/web3dart.dart';
import '../chain_service.dart';
Expand Down Expand Up @@ -50,7 +52,7 @@ class EvmChainServiceImpl implements ChainService {
}) : ethClient = web3Client ??
Web3Client(
appStore.settingsStore.getCurrentNode(appStore.wallet!.type).uri.toString(),
http.Client(),
ioc.IOClient(getHttpClient()),
) {
for (final String event in getEvents()) {
wallet.registerEventEmitter(chainId: getChainId(), event: event);
Expand Down

0 comments on commit 7c8f648

Please sign in to comment.