Skip to content

Commit

Permalink
fix: small fixeds
Browse files Browse the repository at this point in the history
  • Loading branch information
karlem committed Oct 28, 2024
1 parent acb17c5 commit 42faf3b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
17 changes: 14 additions & 3 deletions ipc/provider/src/manager/evm/gas_estimator_middleware.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright 2022-2024 Protocol Labs
// SPDX-License-Identifier: MIT

use async_trait::async_trait;
use ethers::{
core::types::{transaction::eip2718::TypedTransaction, BlockId, U256},
Expand All @@ -14,6 +17,14 @@ pub enum Eip1559GasEstimatorError<M: Middleware> {
FailedToEstimateGas(String),
}

impl<M: Middleware> Eip1559GasEstimatorError<M> {
pub fn failed_to_estimate_gas_not_supported() -> Self {
Eip1559GasEstimatorError::FailedToEstimateGas(
"Only EIP-1559 transactions are supported".to_string(),
)
}
}

impl<M: Middleware> MiddlewareError for Eip1559GasEstimatorError<M> {
type Inner = M::Error;

Expand Down Expand Up @@ -112,9 +123,7 @@ impl<M: Middleware> Middleware for Eip1559GasEstimatorMiddleware<M> {

*tx = TypedTransaction::Eip1559(tx_req);
} else {
return Err(Eip1559GasEstimatorError::FailedToEstimateGas(
"Only EIP-1559 transactions are supported".to_string(),
));
return Err(Eip1559GasEstimatorError::failed_to_estimate_gas_not_supported());
}

// Delegate to the inner middleware for filling remaining transaction fields.
Expand All @@ -138,6 +147,8 @@ impl<M: Middleware> Middleware for Eip1559GasEstimatorMiddleware<M> {
// Populate missing gas fees with `fill_transaction`.
self.fill_transaction(&mut tx, block).await?;
}
} else {
return Err(Eip1559GasEstimatorError::failed_to_estimate_gas_not_supported());
}

// Proceed to send the transaction with the inner middleware.
Expand Down
3 changes: 1 addition & 2 deletions ipc/provider/src/manager/evm/manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ use ethers::prelude::k256::ecdsa::SigningKey;
use ethers::prelude::{Signer, SignerMiddleware};
use ethers::providers::{Authorization, Http, Middleware, Provider};
use ethers::signers::{LocalWallet, Wallet};
use ethers::types::{BlockId, Eip1559TransactionRequest, ValueOrArray, I256, U256};
use ethers::types::{BlockId, Eip1559TransactionRequest, ValueOrArray, U256};

use super::gas_estimator_middleware::Eip1559GasEstimatorMiddleware;
use fvm_shared::clock::ChainEpoch;
Expand Down Expand Up @@ -1351,7 +1351,6 @@ impl TryFrom<gateway_getter_facet::Subnet> for SubnetInfo {
#[cfg(test)]
mod tests {
use crate::manager::evm::manager::contract_address_from_subnet;
use ethers::providers::Middleware;
use fvm_shared::address::Address;
use ipc_api::subnet_id::SubnetID;
use std::str::FromStr;
Expand Down

0 comments on commit 42faf3b

Please sign in to comment.