Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions apps/fortuna/src/eth_utils/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -253,7 +253,19 @@ pub async fn submit_tx<T: Middleware + NonceManaged + 'static>(
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.
Expand Down