diff --git a/src/contracts/mod.rs b/src/contracts/mod.rs index f4e64832..5a7ad913 100644 --- a/src/contracts/mod.rs +++ b/src/contracts/mod.rs @@ -277,7 +277,7 @@ impl IdentityManager { ) -> anyhow::Result { let proof_points_array: [U256; 8] = deletion_proof.into(); - let register_identities_transaction = self + let delete_identities_transaction = self .abi .delete_identities( proof_points_array, @@ -288,7 +288,7 @@ impl IdentityManager { .tx; self.ethereum - .send_transaction(register_identities_transaction, true) + .send_transaction(delete_identities_transaction, true) .await .map_err(|tx_err| anyhow!("{}", tx_err.to_string())) } diff --git a/src/ethereum/mod.rs b/src/ethereum/mod.rs index 65aaee3b..142a948b 100644 --- a/src/ethereum/mod.rs +++ b/src/ethereum/mod.rs @@ -1,6 +1,7 @@ use std::collections::HashMap; use std::sync::Arc; +use ethers::providers::Middleware; use ethers::types::transaction::eip2718::TypedTransaction; use ethers::types::Address; pub use read::ReadProvider; @@ -71,6 +72,11 @@ impl Ethereum { tx: TypedTransaction, only_once: bool, ) -> Result { + 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))); + } + self.write_provider.send_transaction(tx, only_once).await } diff --git a/src/ethereum/write/mod.rs b/src/ethereum/write/mod.rs index 7aeec2a7..42d2c476 100644 --- a/src/ethereum/write/mod.rs +++ b/src/ethereum/write/mod.rs @@ -35,6 +35,9 @@ pub enum TxError { #[error("Error sending transaction: {0}")] Send(anyhow::Error), + #[error("Error simulating transaction: {0}")] + Simulate(anyhow::Error), + #[error("Timeout while waiting for confirmations")] ConfirmationTimeout,