route missed post call through custom http wrapper

This commit is contained in:
julian 2024-06-24 13:01:49 -06:00
parent 3dfc1df0ba
commit 2a10301a59

View file

@ -10,7 +10,6 @@
import 'dart:convert'; import 'dart:convert';
import 'package:http/http.dart';
import 'package:tuple/tuple.dart'; import 'package:tuple/tuple.dart';
import '../../dto/ethereum/eth_token_tx_dto.dart'; import '../../dto/ethereum/eth_token_tx_dto.dart';
@ -120,8 +119,8 @@ abstract class EthereumAPI {
String txid, String txid,
) async { ) async {
try { try {
final response = await post( final response = await client.post(
Uri.parse( url: Uri.parse(
"$stackBaseServer/v1/mainnet", "$stackBaseServer/v1/mainnet",
), ),
headers: {'Content-Type': 'application/json'}, headers: {'Content-Type': 'application/json'},
@ -133,9 +132,12 @@ abstract class EthereumAPI {
], ],
"id": DateTime.now().millisecondsSinceEpoch, "id": DateTime.now().millisecondsSinceEpoch,
}), }),
proxyInfo: Prefs.instance.useTor
? TorService.sharedInstance.getProxyInfo()
: null,
); );
if (response.statusCode == 200) { if (response.code == 200) {
if (response.body.isNotEmpty) { if (response.body.isNotEmpty) {
try { try {
final json = jsonDecode(response.body) as Map; final json = jsonDecode(response.body) as Map;
@ -153,13 +155,13 @@ abstract class EthereumAPI {
} else { } else {
throw EthApiException( throw EthApiException(
"getEthTransactionByHash($txid) response is empty but status code is " "getEthTransactionByHash($txid) response is empty but status code is "
"${response.statusCode}", "${response.code}",
); );
} }
} else { } else {
throw EthApiException( throw EthApiException(
"getEthTransactionByHash($txid) failed with status code: " "getEthTransactionByHash($txid) failed with status code: "
"${response.statusCode}", "${response.code}",
); );
} }
} on EthApiException catch (e) { } on EthApiException catch (e) {