diff --git a/ethexe/ethereum/src/mirror/mod.rs b/ethexe/ethereum/src/mirror/mod.rs index 41d78d95334..80a2a86b05b 100644 --- a/ethexe/ethereum/src/mirror/mod.rs +++ b/ethexe/ethereum/src/mirror/mod.rs @@ -18,7 +18,7 @@ use crate::{abi::IMirror, AlloyProvider, AlloyTransport, TryGetReceipt}; use alloy::{ - primitives::Address, + primitives::{Address, U256}, providers::{Provider, ProviderBuilder, RootProvider}, transports::BoxTransport, }; @@ -131,4 +131,40 @@ impl MirrorQuery { .map(|res| H256(*res._0)) .map_err(Into::into) } + + pub async fn inheritor(&self) -> Result { + self.0 + .inheritor() + .call() + .await + .map(|res| LocalAddress(res._0.into())) + .map_err(Into::into) + } + + pub async fn nonce(&self) -> Result { + self.0 + .nonce() + .call() + .await + .map(|res| U256::from(res._0)) + .map_err(Into::into) + } + + pub async fn router(&self) -> Result { + self.0 + .router() + .call() + .await + .map(|res| LocalAddress(res._0.into())) + .map_err(Into::into) + } + + pub async fn decoder(&self) -> Result { + self.0 + .decoder() + .call() + .await + .map(|res| LocalAddress(res._0.into())) + .map_err(Into::into) + } } diff --git a/ethexe/ethereum/src/router/mod.rs b/ethexe/ethereum/src/router/mod.rs index 4df12862d86..37ab2d3f837 100644 --- a/ethexe/ethereum/src/router/mod.rs +++ b/ethexe/ethereum/src/router/mod.rs @@ -16,7 +16,11 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see . -use crate::{abi::IRouter, wvara::WVara, AlloyProvider, AlloyTransport, TryGetReceipt}; +use crate::{ + abi::{Gear::CodeState, IRouter}, + wvara::WVara, + AlloyProvider, AlloyTransport, TryGetReceipt, +}; use alloy::{ consensus::{SidecarBuilder, SimpleCoder}, primitives::{Address, Bytes, B256, U256}, @@ -210,12 +214,12 @@ impl RouterQuery { } } - pub async fn wvara_address(&self) -> Result
{ + pub async fn genesis_block_hash(&self) -> Result { self.instance - .wrappedVara() + .genesisBlockHash() .call() .await - .map(|res| res._0) + .map(|res| H256(*res._0)) .map_err(Into::into) } @@ -228,12 +232,30 @@ impl RouterQuery { .map_err(Into::into) } - pub async fn genesis_block_hash(&self) -> Result { + pub async fn mirror_impl(&self) -> Result { self.instance - .genesisBlockHash() + .mirrorImpl() .call() .await - .map(|res| H256(*res._0)) + .map(|res| LocalAddress(res._0.into())) + .map_err(Into::into) + } + + pub async fn mirror_proxy_impl(&self) -> Result { + self.instance + .mirrorProxyImpl() + .call() + .await + .map(|res| LocalAddress(res._0.into())) + .map_err(Into::into) + } + + pub async fn wvara_address(&self) -> Result
{ + self.instance + .wrappedVara() + .call() + .await + .map(|res| res._0) .map_err(Into::into) } @@ -255,9 +277,36 @@ impl RouterQuery { .map_err(Into::into) } - pub async fn programs_count(&self) -> Result { - let count = self.instance.programsCount().call().await?; - Ok(count._0) + pub async fn signing_threshold_percentage(&self) -> Result { + self.instance + .signingThresholdPercentage() + .call() + .await + .map(|res| res._0) + .map_err(Into::into) + } + + pub async fn code_state(&self, code_id: CodeId) -> Result { + self.instance + .codeState(code_id.into_bytes().into()) + .call() + .await + .map(|res| CodeState::from(res._0)) + .map_err(Into::into) + } + + pub async fn codes_states(&self, code_ids: Vec) -> Result> { + self.instance + .codesStates( + code_ids + .into_iter() + .map(|c| c.into_bytes().into()) + .collect(), + ) + .call() + .await + .map(|res| res._0.into_iter().map(CodeState::from).collect()) + .map_err(Into::into) } pub async fn program_code_id(&self, program_id: ProgramId) -> Result> { @@ -267,4 +316,31 @@ impl RouterQuery { let code_id = Some(CodeId::new(code_id._0.0)).filter(|&code_id| code_id != CodeId::zero()); Ok(code_id) } + + pub async fn programs_code_ids(&self, program_ids: Vec) -> Result> { + self.instance + .programsCodeIds( + program_ids + .into_iter() + .map(|p| { + let program_id = LocalAddress::try_from(p).expect("infallible"); + Address::new(program_id.0) + }) + .collect(), + ) + .call() + .await + .map(|res| res._0.into_iter().map(|c| CodeId::new(c.0)).collect()) + .map_err(Into::into) + } + + pub async fn programs_count(&self) -> Result { + let count = self.instance.programsCount().call().await?; + Ok(count._0) + } + + pub async fn validated_codes_count(&self) -> Result { + let count = self.instance.validatedCodesCount().call().await?; + Ok(count._0) + } } diff --git a/ethexe/ethereum/src/wvara/mod.rs b/ethexe/ethereum/src/wvara/mod.rs index ac7072f4d9a..0cdc6c43c6f 100644 --- a/ethexe/ethereum/src/wvara/mod.rs +++ b/ethexe/ethereum/src/wvara/mod.rs @@ -139,4 +139,22 @@ impl WVaraQuery { .map(|res| U256(res._0.into_limbs())) .map_err(Into::into) } + + pub async fn name(&self) -> Result { + self.0 + .name() + .call() + .await + .map(|res| res._0.to_string()) + .map_err(Into::into) + } + + pub async fn symbol(&self) -> Result { + self.0 + .symbol() + .call() + .await + .map(|res| res._0.to_string()) + .map_err(Into::into) + } }