|
|
|
@ -8,6 +8,7 @@ use std::sync::Arc; |
|
|
|
|
use async_trait::async_trait; |
|
|
|
|
use ethers::abi::AbiEncode; |
|
|
|
|
use ethers::prelude::Middleware; |
|
|
|
|
use ethers::types::Eip1559TransactionRequest; |
|
|
|
|
use ethers_contract::builders::ContractCall; |
|
|
|
|
use tracing::instrument; |
|
|
|
|
|
|
|
|
@ -199,13 +200,34 @@ where |
|
|
|
|
metadata.to_vec().into(), |
|
|
|
|
RawHyperlaneMessage::from(message).to_vec().into(), |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
let gas_limit = if let Some(gas_limit) = tx_gas_limit { |
|
|
|
|
gas_limit |
|
|
|
|
} else { |
|
|
|
|
tx.estimate_gas().await?.saturating_add(U256::from(100000)) |
|
|
|
|
}; |
|
|
|
|
Ok(tx.gas(gas_limit)) |
|
|
|
|
let Ok((max_fee, max_priority_fee)) = self.provider.estimate_eip1559_fees(None).await else { |
|
|
|
|
// Is not EIP 1559 chain
|
|
|
|
|
return Ok(tx.gas(gas_limit)) |
|
|
|
|
}; |
|
|
|
|
// Is EIP 1559 chain
|
|
|
|
|
let mut request = Eip1559TransactionRequest::new(); |
|
|
|
|
if let Some(from) = tx.tx.from() { |
|
|
|
|
request = request.from(*from); |
|
|
|
|
} |
|
|
|
|
if let Some(to) = tx.tx.to() { |
|
|
|
|
request = request.to(to.clone()); |
|
|
|
|
} |
|
|
|
|
if let Some(data) = tx.tx.data() { |
|
|
|
|
request = request.data(data.clone()); |
|
|
|
|
} |
|
|
|
|
if let Some(value) = tx.tx.value() { |
|
|
|
|
request = request.value(*value); |
|
|
|
|
} |
|
|
|
|
request = request.max_fee_per_gas(max_fee); |
|
|
|
|
request = request.max_priority_fee_per_gas(max_priority_fee); |
|
|
|
|
let mut eip_1559_tx = tx.clone(); |
|
|
|
|
eip_1559_tx.tx = ethers::types::transaction::eip2718::TypedTransaction::Eip1559(request); |
|
|
|
|
Ok(eip_1559_tx.gas(gas_limit)) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|