mirror of
https://github.com/Such-Software/hash-wallet.git
synced 2026-10-17 05:41:29 +02:00
CW-672: Enhance ETH Wallet Fee Calculation - Fix ERC20 Transaction Fee (#1548)
* fix: Eth transaction fees WIP * Revert "fix: Eth transaction fees WIP" This reverts commit b9a469bc7e22134d78bf0cc4c00485e1d4515ebd. * fix: Modifying fee WIP * fix: Enhance ETH Wallet fee calculation WIP * feat: Enhance Transaction fees for ETH Transactions, Native transactions done, left with ERC20 transactions * fix: Pre PR cleanups * fix: ETH transaction fees for ERC20 transactions * fix: ETH transaction fees for ERC20 transactions * chore: Clarify comment in getEstimatedGas * fix: Switch call to estimate gas units to a more cleaner approach
This commit is contained in:
@@ -72,12 +72,12 @@ abstract class EVMChainClient {
|
||||
}
|
||||
}
|
||||
|
||||
Future<int> getGasBaseFee() async {
|
||||
Future<int?> getGasBaseFee() async {
|
||||
try {
|
||||
final blockInfo = await _client!.getBlockInformation(isContainFullObj: false);
|
||||
final baseFee = blockInfo.baseFeePerGas;
|
||||
|
||||
return baseFee!.getInWei.toInt();
|
||||
return baseFee?.getInWei.toInt();
|
||||
} catch (_) {
|
||||
return 0;
|
||||
}
|
||||
@@ -110,19 +110,19 @@ abstract class EVMChainClient {
|
||||
EthereumAddress.fromHex(contractAddress),
|
||||
);
|
||||
|
||||
final transferFunction = contract.function('transferFrom');
|
||||
final transfer = contract.function('transfer');
|
||||
|
||||
final estimatedGas = await _client!.estimateGas(
|
||||
// Estimate gas units
|
||||
final gasEstimate = await _client!.estimateGas(
|
||||
sender: senderAddress,
|
||||
to: toAddress,
|
||||
value: value,
|
||||
data: transferFunction.encodeCall([
|
||||
senderAddress,
|
||||
to: EthereumAddress.fromHex(contractAddress),
|
||||
data: transfer.encodeCall([
|
||||
toAddress,
|
||||
value.getInWei,
|
||||
]),
|
||||
);
|
||||
return estimatedGas.toInt();
|
||||
|
||||
return gasEstimate.toInt();
|
||||
}
|
||||
} catch (_) {
|
||||
return 0;
|
||||
|
||||
@@ -387,8 +387,6 @@ abstract class EVMChainWalletBase
|
||||
|
||||
estimatedFeesForTransaction = BigInt.from(estimateFees);
|
||||
|
||||
debugPrint('Estimated Fees for Transaction: $estimatedFeesForTransaction');
|
||||
|
||||
if (output.sendAll && transactionCurrency is! Erc20Token) {
|
||||
totalAmount = (erc20Balance.balance - estimatedFeesForTransaction);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user