Skip to content

Commit

Permalink
fix naming (#168)
Browse files Browse the repository at this point in the history
  • Loading branch information
NikVolf committed Jul 16, 2024
1 parent 187a138 commit 9a73a9e
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 30 deletions.
38 changes: 19 additions & 19 deletions ethexe/ethereum/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ use anyhow::{anyhow, bail, Result};
use async_trait::async_trait;
use ethexe_common::{events::CodeApproved, BlockCommitment, CodeCommitment};
use ethexe_signer::{
Address as ethexeAddress, PublicKey, Signature as ethexeSignature, Signer as ethexeSigner,
Address as LocalAddress, PublicKey, Signature as LocalSignature, Signer as LocalSigner,
};
use futures::StreamExt;
use gear_core::code::{Code, CodeAndId};
Expand Down Expand Up @@ -53,13 +53,13 @@ type QueryRouterInstance =

#[derive(Debug, Clone)]
struct Sender {
signer: ethexeSigner,
signer: LocalSigner,
sender: PublicKey,
chain_id: Option<ChainId>,
}

impl Sender {
pub fn new(signer: ethexeSigner, sender_address: ethexeAddress) -> Result<Self> {
pub fn new(signer: LocalSigner, sender_address: LocalAddress) -> Result<Self> {
let sender = signer
.get_key_by_addr(sender_address)?
.ok_or_else(|| anyhow!("no key found for {sender_address}"))?;
Expand Down Expand Up @@ -125,8 +125,8 @@ impl Router {
Self(AlloyRouterInstance::new(address, provider))
}

pub fn address(&self) -> ethexeAddress {
ethexeAddress(*self.0.address().0)
pub fn address(&self) -> LocalAddress {
LocalAddress(*self.0.address().0)
}

pub async fn add_validators(&self, validators: Vec<ActorId>) -> Result<H256> {
Expand Down Expand Up @@ -247,7 +247,7 @@ impl Router {
pub async fn commit_codes(
&self,
commitments: Vec<CodeCommitment>,
signatures: Vec<ethexeSignature>,
signatures: Vec<LocalSignature>,
) -> Result<H256> {
let builder = self.0.commitCodes(
commitments.into_iter().map(Into::into).collect(),
Expand All @@ -264,7 +264,7 @@ impl Router {
pub async fn commit_blocks(
&self,
commitments: Vec<BlockCommitment>,
signatures: Vec<ethexeSignature>,
signatures: Vec<LocalSignature>,
) -> Result<H256> {
let builder = self
.0
Expand All @@ -285,7 +285,7 @@ impl Router {
pub struct RouterQuery(QueryRouterInstance);

impl RouterQuery {
pub async fn new(rpc_url: &str, router_address: ethexeAddress) -> Result<Self> {
pub async fn new(rpc_url: &str, router_address: LocalAddress) -> Result<Self> {
let provider = Arc::new(ProviderBuilder::new().on_builtin(rpc_url).await?);
Ok(Self(QueryRouterInstance::new(
Address::new(router_address.0),
Expand Down Expand Up @@ -319,8 +319,8 @@ impl Program {
Self(AlloyProgramInstance::new(address, provider))
}

pub fn address(&self) -> ethexeAddress {
ethexeAddress(*self.0.address().0)
pub fn address(&self) -> LocalAddress {
LocalAddress(*self.0.address().0)
}

pub async fn send_message(
Expand Down Expand Up @@ -368,8 +368,8 @@ impl Program {

async fn create_provider(
rpc_url: &str,
signer: ethexeSigner,
sender_address: ethexeAddress,
signer: LocalSigner,
sender_address: LocalAddress,
) -> Result<Arc<AlloyProvider>> {
Ok(Arc::new(
ProviderBuilder::new()
Expand All @@ -388,9 +388,9 @@ pub struct Ethereum {
impl Ethereum {
pub async fn new(
rpc_url: &str,
router_address: ethexeAddress,
signer: ethexeSigner,
sender_address: ethexeAddress,
router_address: LocalAddress,
signer: LocalSigner,
sender_address: LocalAddress,
) -> Result<Self> {
Ok(Self {
router_address: Address::new(router_address.0),
Expand All @@ -400,9 +400,9 @@ impl Ethereum {

pub async fn deploy(
rpc_url: &str,
validators: Vec<ethexeAddress>,
signer: ethexeSigner,
sender_address: ethexeAddress,
validators: Vec<LocalAddress>,
signer: LocalSigner,
sender_address: LocalAddress,
) -> Result<Self> {
const VALUE_PER_GAS: u128 = 6;

Expand Down Expand Up @@ -488,7 +488,7 @@ impl Ethereum {
Router::new(self.router_address, self.provider.clone())
}

pub fn program(&self, program_address: ethexeAddress) -> Program {
pub fn program(&self, program_address: LocalAddress) -> Program {
Program::new(Address::new(program_address.0), self.provider.clone())
}
}
12 changes: 6 additions & 6 deletions ethexe/observer/src/observer.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
use crate::{BlobReader, BlockData, CodeLoadedData, Event};
use alloy::{
primitives::{Address, B256},
primitives::{Address as AlloyAddress, B256},
providers::{Provider, ProviderBuilder, RootProvider},
rpc::types::eth::{Filter, Topic},
transports::BoxTransport,
};
use anyhow::{anyhow, Result};
use ethexe_common::events::BlockEvent;
use ethexe_ethereum::event::*;
use ethexe_signer::Address as ethexeAddress;
use ethexe_signer::Address;
use futures::{stream::FuturesUnordered, Stream, StreamExt};
use gear_core::ids::prelude::*;
use gprimitives::{ActorId, CodeId, H256};
Expand All @@ -19,7 +19,7 @@ pub(crate) type ObserverProvider = RootProvider<BoxTransport>;

pub struct Observer {
provider: ObserverProvider,
router_address: Address,
router_address: AlloyAddress,
blob_reader: Arc<dyn BlobReader>,
status_sender: watch::Sender<ObserverStatus>,
status: ObserverStatus,
Expand All @@ -35,13 +35,13 @@ pub struct ObserverStatus {
impl Observer {
pub async fn new(
ethereum_rpc: &str,
router_address: ethexeAddress,
router_address: Address,
blob_reader: Arc<dyn BlobReader>,
) -> Result<Self> {
let (status_sender, _status_receiver) = watch::channel(ObserverStatus::default());
Ok(Self {
provider: ProviderBuilder::new().on_builtin(ethereum_rpc).await?,
router_address: Address::new(router_address.0),
router_address: AlloyAddress::new(router_address.0),
blob_reader,
status: Default::default(),
status_sender,
Expand Down Expand Up @@ -180,7 +180,7 @@ pub(crate) async fn read_code_from_tx_hash(
pub(crate) async fn read_block_events(
block_hash: H256,
provider: &ObserverProvider,
router_address: Address,
router_address: AlloyAddress,
) -> Result<Vec<BlockEvent>> {
let router_events_filter = Filter::new()
.at_block_hash(block_hash.0)
Expand Down
10 changes: 5 additions & 5 deletions ethexe/observer/src/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use crate::{
BlobReader,
};
use alloy::{
primitives::Address,
primitives::Address as AlloyAddress,
providers::{Provider, ProviderBuilder},
rpc::types::eth::BlockTransactionsKind,
};
Expand All @@ -17,13 +17,13 @@ use ethexe_common::{
db::{BlockHeader, BlockMetaStorage},
events::BlockEvent,
};
use ethexe_signer::Address as ethexeAddress;
use ethexe_signer::Address;
use gprimitives::{ActorId, CodeId, H256};

pub struct Query {
database: Box<dyn BlockMetaStorage>,
provider: ObserverProvider,
router_address: Address,
router_address: AlloyAddress,
genesis_block_hash: H256,
blob_reader: Arc<dyn BlobReader>,
max_commitment_depth: u32,
Expand All @@ -33,7 +33,7 @@ impl Query {
pub async fn new(
database: Box<dyn BlockMetaStorage>,
ethereum_rpc: &str,
router_address: ethexeAddress,
router_address: Address,
genesis_block_hash: H256,
blob_reader: Arc<dyn BlobReader>,
max_commitment_depth: u32,
Expand All @@ -48,7 +48,7 @@ impl Query {
Ok(Self {
database,
provider: ProviderBuilder::new().on_builtin(ethereum_rpc).await?,
router_address: Address::new(router_address.0),
router_address: AlloyAddress::new(router_address.0),
genesis_block_hash,
blob_reader,
max_commitment_depth,
Expand Down

0 comments on commit 9a73a9e

Please sign in to comment.