mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2025-02-02 19:26:37 +00:00
WIP: Get gas estimator
This commit is contained in:
parent
8b87c7367a
commit
734a51f5dd
1 changed files with 22 additions and 11 deletions
|
@ -71,21 +71,18 @@ class AddressTransaction {
|
||||||
}
|
}
|
||||||
|
|
||||||
class GasTracker {
|
class GasTracker {
|
||||||
final String status;
|
final int code;
|
||||||
final String message;
|
final String data;
|
||||||
final List<dynamic> result;
|
|
||||||
|
|
||||||
const GasTracker({
|
const GasTracker({
|
||||||
required this.status,
|
required this.code,
|
||||||
required this.message,
|
required this.data,
|
||||||
required this.result,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
factory GasTracker.fromJson(Map<String, dynamic> json) {
|
factory GasTracker.fromJson(Map<String, dynamic> json) {
|
||||||
return GasTracker(
|
return GasTracker(
|
||||||
status: json['status'] as String,
|
code: json['code'] as int,
|
||||||
message: json['message'] as String,
|
data: json['data'] as String,
|
||||||
result: json['result'] as List<dynamic>,
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -250,8 +247,10 @@ class EthereumWallet extends CoinServiceAPI {
|
||||||
Future<FeeObject>? _feeObject;
|
Future<FeeObject>? _feeObject;
|
||||||
|
|
||||||
Future<FeeObject> _getFees() async {
|
Future<FeeObject> _getFees() async {
|
||||||
String feesEndPoint =
|
GasTracker fees = await getGasOracle();
|
||||||
"https://api.etherscan.io/api?module=gastracker&action=gasoracle&apikey=5JJW1UH269SV6ZPC78ZZI7H4QVV1A1TQDH";
|
if (fees.code == 200) {
|
||||||
|
print("FEES IS ${fees.data}");
|
||||||
|
}
|
||||||
return FeeObject(
|
return FeeObject(
|
||||||
numberOfBlocksFast: 10,
|
numberOfBlocksFast: 10,
|
||||||
numberOfBlocksAverage: 10,
|
numberOfBlocksAverage: 10,
|
||||||
|
@ -261,6 +260,18 @@ class EthereumWallet extends CoinServiceAPI {
|
||||||
slow: 1);
|
slow: 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<GasTracker> getGasOracle() async {
|
||||||
|
final response =
|
||||||
|
await get(Uri.parse("https://beaconcha.in/api/v1/execution/gasnow"));
|
||||||
|
|
||||||
|
if (response.statusCode == 200) {
|
||||||
|
return GasTracker.fromJson(
|
||||||
|
json.decode(response.body) as Map<String, dynamic>);
|
||||||
|
} else {
|
||||||
|
throw Exception('Failed to load gas oracle');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<void> fullRescan(
|
Future<void> fullRescan(
|
||||||
int maxUnusedAddressGap, int maxNumberOfIndexesToCheck) {
|
int maxUnusedAddressGap, int maxNumberOfIndexesToCheck) {
|
||||||
|
|
Loading…
Reference in a new issue