fetchNetworkFees method
Implementation
Future<(int gasLimit, EvmGasPrice gasPrice)> fetchNetworkFees({
EvmFeeInformation? existing,
required String recipient,
required String sender,
required Uint8List? data,
required BigInt? value,
}) async {
var gasLimit = existing?.gasLimit;
try {
gasLimit ??= await estimateGasLimit(
recipient: recipient,
sender: sender,
data: data,
value: value,
);
} catch (e) {
Logger.logError(e, hint: "Gas estimation failed");
// Only Debug
assert(true, "Gas estimation failed");
gasLimit = 1E6.toInt();
}
final EvmGasPrice gasPrice = switch (existing?.gasPrice) {
EvmLegacyGasPrice feeInfo => feeInfo,
EvmType2GasPrice feeInfo => feeInfo,
null when type.useEIP1559 => await getType2GasPrice(),
null => EvmLegacyGasPrice(
gasPrice: await getGasPriceAmount(),
),
};
return (gasLimit, gasPrice);
}