Skip to content

Commit

Permalink
Fix bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
ryardley committed Oct 31, 2024
1 parent 14cfe86 commit 9977a69
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 9 deletions.
2 changes: 1 addition & 1 deletion packages/ciphernode/enclave_node/src/aggregator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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?;
Expand Down
13 changes: 9 additions & 4 deletions packages/ciphernode/evm/src/enclave_sol.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -10,12 +14,13 @@ pub struct EnclaveSol;
impl EnclaveSol {
pub async fn attach(
bus: &Addr<EventBus>,
rpc_url: &str,
read_provider: &ReadonlyProvider,
write_provider: &SignerProvider,
contract_address: &str,
signer: &Arc<PrivateKeySigner>,
) -> 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(())
}
}
8 changes: 4 additions & 4 deletions packages/ciphernode/evm/src/enclave_sol_writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,24 +34,24 @@ pub struct EnclaveSolWriter {
impl EnclaveSolWriter {
pub async fn new(
bus: &Addr<EventBus>,
rpc_url: &str,
provider: &SignerProvider,
contract_address: Address,
signer: &Arc<PrivateKeySigner>,
) -> Result<Self> {
Ok(Self {
provider: create_provider_with_signer(&ensure_http_rpc(rpc_url), signer).await?,
provider: provider.clone(),
contract_address,
bus: bus.clone(),
})
}

pub async fn attach(
bus: &Addr<EventBus>,
rpc_url: &str,
provider: &SignerProvider,
contract_address: &str,
signer: &Arc<PrivateKeySigner>,
) -> Result<Addr<EnclaveSolWriter>> {
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()))
Expand Down

0 comments on commit 9977a69

Please sign in to comment.