Skip to content

Commit

Permalink
Improve fee estimation logic for insufficient balance case
Browse files Browse the repository at this point in the history
  • Loading branch information
rafaelekol committed Nov 19, 2024
1 parent 6e3c83b commit 835694f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ dependencies {
// Wallet kits
implementation 'com.github.horizontalsystems:ton-kit-android:763a5c3'
implementation 'com.github.horizontalsystems:bitcoin-kit-android:ced5801'
implementation 'com.github.horizontalsystems:ethereum-kit-android:a5eff38'
implementation 'com.github.horizontalsystems:ethereum-kit-android:0c770e3'
implementation 'com.github.horizontalsystems:blockchain-fee-rate-kit-android:1d3bd49'
implementation 'com.github.horizontalsystems:binance-chain-kit-android:c1509a2'
implementation 'com.github.horizontalsystems:market-kit-android:4201f8f'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,18 @@ open class EvmCommonGasDataService(
}

return evmKit.estimateGas(stubTransactionData, gasPrice)
.map { estimatedGasLimit ->
val gasLimit = if (surchargeRequired) EvmFeeModule.surcharged(estimatedGasLimit) else estimatedGasLimit
GasData(
gasLimit = gasLimit,
estimatedGasLimit = estimatedGasLimit,
gasPrice = gasPrice
)
}
.onErrorResumeNext {
evmKit.estimateGas(stubTransactionData)
}
.map { estimatedGasLimit ->
val gasLimit =
if (surchargeRequired) EvmFeeModule.surcharged(estimatedGasLimit) else estimatedGasLimit
GasData(
gasLimit = gasLimit,
estimatedGasLimit = estimatedGasLimit,
gasPrice = gasPrice
)
}
}

companion object {
Expand Down

0 comments on commit 835694f

Please sign in to comment.