diff --git a/packages/ciphernode/enclave_node/src/aggregator.rs b/packages/ciphernode/enclave_node/src/aggregator.rs index 9e102e95..b1a62239 100644 --- a/packages/ciphernode/enclave_node/src/aggregator.rs +++ b/packages/ciphernode/enclave_node/src/aggregator.rs @@ -48,7 +48,7 @@ pub async fn setup_aggregator( let rpc_url = &chain.rpc_url; let read_provider = create_readonly_provider(&ensure_ws_rpc(rpc_url)).await?; let write_provider = create_provider_with_signer(&ensure_http_rpc(rpc_url), &signer).await?; - EnclaveSol::attach(&bus, &read_provider, &chain.contracts.enclave, &signer).await?; + EnclaveSol::attach(&bus, &read_provider, &write_provider, &chain.contracts.enclave, &signer).await?; RegistryFilterSol::attach(&bus, &write_provider, &chain.contracts.filter_registry).await?; CiphernodeRegistrySol::attach(&bus, &read_provider, &chain.contracts.ciphernode_registry) .await?; diff --git a/packages/ciphernode/evm/src/enclave_sol.rs b/packages/ciphernode/evm/src/enclave_sol.rs index 12c67f90..b61734a3 100644 --- a/packages/ciphernode/evm/src/enclave_sol.rs +++ b/packages/ciphernode/evm/src/enclave_sol.rs @@ -1,6 +1,10 @@ use std::sync::Arc; -use crate::{enclave_sol_reader::EnclaveSolReader, enclave_sol_writer::EnclaveSolWriter}; +use crate::{ + enclave_sol_reader::EnclaveSolReader, + enclave_sol_writer::EnclaveSolWriter, + helpers::{ReadonlyProvider, SignerProvider}, +}; use actix::Addr; use alloy::signers::local::PrivateKeySigner; use anyhow::Result; @@ -10,12 +14,13 @@ pub struct EnclaveSol; impl EnclaveSol { pub async fn attach( bus: &Addr, - rpc_url: &str, + read_provider: &ReadonlyProvider, + write_provider: &SignerProvider, contract_address: &str, signer: &Arc, ) -> Result<()> { - EnclaveSolReader::attach(bus, rpc_url, contract_address).await?; - EnclaveSolWriter::attach(bus, rpc_url, contract_address, signer).await?; + EnclaveSolReader::attach(bus, read_provider, contract_address).await?; + EnclaveSolWriter::attach(bus, write_provider, contract_address, signer).await?; Ok(()) } } diff --git a/packages/ciphernode/evm/src/enclave_sol_writer.rs b/packages/ciphernode/evm/src/enclave_sol_writer.rs index ce7dfa03..78ef02c9 100644 --- a/packages/ciphernode/evm/src/enclave_sol_writer.rs +++ b/packages/ciphernode/evm/src/enclave_sol_writer.rs @@ -34,12 +34,12 @@ pub struct EnclaveSolWriter { impl EnclaveSolWriter { pub async fn new( bus: &Addr, - rpc_url: &str, + provider: &SignerProvider, contract_address: Address, signer: &Arc, ) -> Result { Ok(Self { - provider: create_provider_with_signer(&ensure_http_rpc(rpc_url), signer).await?, + provider: provider.clone(), contract_address, bus: bus.clone(), }) @@ -47,11 +47,11 @@ impl EnclaveSolWriter { pub async fn attach( bus: &Addr, - rpc_url: &str, + provider: &SignerProvider, contract_address: &str, signer: &Arc, ) -> Result> { - let addr = EnclaveSolWriter::new(bus, rpc_url, contract_address.parse()?, signer) + let addr = EnclaveSolWriter::new(bus, provider, contract_address.parse()?, signer) .await? .start(); bus.send(Subscribe::new("PlaintextAggregated", addr.clone().into()))