diff --git a/apps/fortuna/src/eth_utils/utils.rs b/apps/fortuna/src/eth_utils/utils.rs index fae8fbde4f..7fe5d7ac22 100644 --- a/apps/fortuna/src/eth_utils/utils.rs +++ b/apps/fortuna/src/eth_utils/utils.rs @@ -8,7 +8,7 @@ use { ethers::{ contract::{ContractCall, ContractError}, middleware::Middleware, - providers::ProviderError, + providers::{MiddlewareError, ProviderError}, signers::Signer, types::{ transaction::eip2718::TypedTransaction, TransactionReceipt, TransactionRequest, U256, @@ -253,7 +253,19 @@ pub async fn submit_tx( client .fill_transaction(&mut transaction, None) .await - .map_err(|e| backoff::Error::transient(SubmitTxError::GasPriceEstimateError(e)))?; + .map_err(|e| { + // If there is revert data, the contract reverted during gas usage estimation. + if let Some(e) = e.as_error_response() { + if let Some(e) = e.as_revert_data() { + return backoff::Error::transient(SubmitTxError::GasUsageEstimateError( + ContractError::Revert(e.clone()), + )); + } + } + + // If there is no revert data, there was likely an error during gas price polling. + backoff::Error::transient(SubmitTxError::GasPriceEstimateError(e)) + })?; // Apply the fee escalation policy. Note: the unwrap_or_default should never default as we have a gas oracle // in the client that sets the gas price.