getAccountResource method
Implementation
Future<({int bandwidth, int energy})> getAccountResource({
required String address,
bool visible = true,
}) async {
final json = await postCall<JSON>(
"$baseURL/wallet/getaccountresource",
data: {
"address": address,
"visible": visible,
},
);
final freeNetUsed = json["freeNetUsed"] as int? ?? 0;
final freeNetLimit = json["freeNetLimit"] as int;
final remainingFreeBandwidth = freeNetLimit - freeNetUsed;
final energyLimit = json["EnergyLimit"] as int?;
final energyUsed = json["EnergyUsed"] as int?;
final energyBalance = (energyUsed != null && energyLimit != null)
? energyLimit - energyUsed
: 0;
return (
bandwidth: remainingFreeBandwidth,
energy: energyBalance,
);
}