Skip to content

Commit

Permalink
Merge pull request #7 from horizonx-tech/topic/send-tx
Browse files Browse the repository at this point in the history
Split tx sending and receipt acquisition
  • Loading branch information
darroze-ar authored Oct 12, 2024
2 parents 0da42fa + 70d8b44 commit b39c590
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 3 deletions.
8 changes: 8 additions & 0 deletions src/confirm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,14 @@ where
send_transaction_with_confirmation_(hash, transport, poll_interval, confirmations, options).await
}

pub async fn get_transaction_receipt<T: Transport>(
transport: T,
hash: H256,
options: CallOptions,
) -> error::Result<Option<TransactionReceipt>> {
Eth::new(&transport).transaction_receipt(hash, options).await
}

#[cfg(test)]
mod tests {
use super::send_transaction_with_confirmation;
Expand Down
27 changes: 24 additions & 3 deletions src/contract/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -439,11 +439,22 @@ mod contract_signing {
chain_id: u64,
) -> crate::Result<H256> {
let signed = self
.sign(func, params, options.clone(), from, key_info, chain_id)
.sign(
func,
params,
Options {
call_options: None,
..options.clone()
},
from,
key_info,
chain_id,
)
.await?;
self.eth
.send_raw_transaction(signed.raw_transaction, options.call_options.unwrap_or_default())
.await
.await?;
Ok(signed.transaction_hash)
}

// Submit contract call transaction to the transaction pool and wait for the transaction to be included in a block.
Expand All @@ -462,7 +473,17 @@ mod contract_signing {
) -> crate::Result<TransactionReceipt> {
let poll_interval = time::Duration::from_secs(1);
let signed = self
.sign(func, params, options.clone(), from, key_info, chain_id)
.sign(
func,
params,
Options {
call_options: None,
..options.clone()
},
from,
key_info,
chain_id,
)
.await?;

confirm::send_raw_transaction_with_confirmation(
Expand Down

0 comments on commit b39c590

Please sign in to comment.