diff --git a/src/ethereum/write_oz/mod.rs b/src/ethereum/write_oz/mod.rs index 5f70b873..73e29d19 100644 --- a/src/ethereum/write_oz/mod.rs +++ b/src/ethereum/write_oz/mod.rs @@ -50,7 +50,7 @@ impl WriteProvider { } ParsedOptions::TxSitter(tx_sitter_options) => { tracing::info!("Initializing TxSitter"); - Arc::new(TxSitter::new(tx_sitter_options.tx_sitter_url)) + Arc::new(TxSitter::new(&tx_sitter_options)) } }; diff --git a/src/ethereum/write_oz/openzeppelin.rs b/src/ethereum/write_oz/openzeppelin.rs index f1fbf3a6..8538d903 100644 --- a/src/ethereum/write_oz/openzeppelin.rs +++ b/src/ethereum/write_oz/openzeppelin.rs @@ -132,10 +132,9 @@ impl OzRelay { /// take multiple seconds to restart. pub async fn send_transaction( &self, - tx: TypedTransaction, + mut tx: TypedTransaction, only_once: bool, ) -> Result { - let mut tx = tx.clone(); if let Some(gas_limit) = self.gas_limit { tx.set_gas(gas_limit); } diff --git a/src/ethereum/write_oz/options.rs b/src/ethereum/write_oz/options.rs index 12dc28f8..53f6ba04 100644 --- a/src/ethereum/write_oz/options.rs +++ b/src/ethereum/write_oz/options.rs @@ -46,6 +46,9 @@ pub struct Options { #[clap(long, env)] pub tx_sitter_address: Option, + + #[clap(long, env)] + pub tx_sitter_gas_limit: Option, } fn duration_from_str(value: &str) -> Result { @@ -134,8 +137,9 @@ impl<'a> TryFrom<&'a Options> for OzOptions { } pub struct TxSitterOptions { - pub tx_sitter_url: String, - pub tx_sitter_address: H160, + pub tx_sitter_url: String, + pub tx_sitter_address: H160, + pub tx_sitter_gas_limit: Option, } impl<'a> TryFrom<&'a Options> for TxSitterOptions { @@ -143,13 +147,14 @@ impl<'a> TryFrom<&'a Options> for TxSitterOptions { fn try_from(value: &'a Options) -> Result { Ok(Self { - tx_sitter_url: value + tx_sitter_url: value .tx_sitter_url .clone() .ok_or_else(|| anyhow!("Missing tx_sitter_url"))?, - tx_sitter_address: value + tx_sitter_address: value .tx_sitter_address .ok_or_else(|| anyhow!("Missing tx_sitter_address"))?, + tx_sitter_gas_limit: value.tx_sitter_gas_limit, }) } } diff --git a/src/ethereum/write_oz/tx_sitter.rs b/src/ethereum/write_oz/tx_sitter.rs index 56f7728f..a96a0433 100644 --- a/src/ethereum/write_oz/tx_sitter.rs +++ b/src/ethereum/write_oz/tx_sitter.rs @@ -8,19 +8,22 @@ use tx_sitter_client::data::{SendTxRequest, TransactionPriority, TxStatus}; use tx_sitter_client::TxSitterClient; use super::inner::{Inner, TransactionResult}; +use super::options::TxSitterOptions; use crate::ethereum::write::TransactionId; use crate::ethereum::TxError; const MINING_TIMEOUT: Duration = Duration::from_secs(60); pub struct TxSitter { - client: TxSitterClient, + client: TxSitterClient, + gas_limit: Option, } impl TxSitter { - pub fn new(url: impl ToString) -> Self { + pub fn new(options: &TxSitterOptions) -> Self { Self { - client: TxSitterClient::new(url), + client: TxSitterClient::new(&options.tx_sitter_url), + gas_limit: options.tx_sitter_gas_limit, } } @@ -51,9 +54,13 @@ impl TxSitter { impl Inner for TxSitter { async fn send_transaction( &self, - tx: TypedTransaction, + mut tx: TypedTransaction, _only_once: bool, ) -> Result { + if let Some(gas_limit) = self.gas_limit { + tx.set_gas(gas_limit); + } + // TODO: Handle only_once let tx = self .client