Skip to content

Commit

Permalink
simulate before broadcasting
Browse files Browse the repository at this point in the history
  • Loading branch information
0xKitsune committed May 2, 2024
1 parent 43142e8 commit c1e660e
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 13 deletions.
8 changes: 0 additions & 8 deletions src/contracts/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -260,10 +260,6 @@ impl IdentityManager {
)
.tx;

self.ethereum
.simulate_transaction(&register_identities_transaction)
.await?;

self.ethereum
.send_transaction(register_identities_transaction, true)
.await
Expand Down Expand Up @@ -291,10 +287,6 @@ impl IdentityManager {
)
.tx;

self.ethereum
.simulate_transaction(&delete_identities_transaction)
.await?;

self.ethereum
.send_transaction(delete_identities_transaction, true)
.await
Expand Down
6 changes: 1 addition & 5 deletions src/ethereum/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,16 +72,12 @@ impl Ethereum {
tx: TypedTransaction,
only_once: bool,
) -> Result<TransactionId, TxError> {
self.write_provider.send_transaction(tx, only_once).await
}

pub async fn simulate_transaction(&self, tx: &TypedTransaction) -> Result<(), TxError> {
if let Err(err) = self.read_provider.call(&tx, None).await {
tracing::error!("Error simulating transaction: {:?}", err);
return Err(TxError::Simulate(anyhow::Error::new(err)));
}

Ok(())
self.write_provider.send_transaction(tx, only_once).await
}

pub async fn fetch_pending_transactions(&self) -> Result<Vec<TransactionId>, TxError> {
Expand Down

0 comments on commit c1e660e

Please sign in to comment.