Skip to content

Commit

Permalink
feat(cosmos): ism dry-run
Browse files Browse the repository at this point in the history
  • Loading branch information
daniel-savu committed Dec 19, 2023
1 parent d18f7ae commit 52f572f
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 3 deletions.
22 changes: 19 additions & 3 deletions rust/chains/hyperlane-cosmos/src/interchain_security_module.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
use async_trait::async_trait;
use hyperlane_core::{
ChainResult, ContractLocator, HyperlaneChain, HyperlaneContract, HyperlaneDomain,
HyperlaneMessage, HyperlaneProvider, InterchainSecurityModule, ModuleType, H256, U256,
HyperlaneMessage, HyperlaneProvider, InterchainSecurityModule, ModuleType, RawHyperlaneMessage,
H256, U256,
};

use crate::{
grpc::WasmProvider,
payloads::{
general::EmptyStruct,
ism_routes::{QueryIsmGeneralRequest, QueryIsmModuleTypeRequest},
ism_routes::{
QueryIsmGeneralRequest, QueryIsmModuleTypeRequest, VerifyRequest, VerifyRequestInner,
},
},
types::IsmType,
ConnectionConf, CosmosProvider, Signer,
Expand Down Expand Up @@ -91,6 +94,19 @@ impl InterchainSecurityModule for CosmosInterchainSecurityModule {
message: &HyperlaneMessage,
metadata: &[u8],
) -> ChainResult<Option<U256>> {
Ok(Some(U256::from(1000))) // TODO
let process_message = VerifyRequest {
verify: VerifyRequestInner {
message: hex::encode(RawHyperlaneMessage::from(message)),
metadata: hex::encode(metadata),
},
};

let gas_estimate = self
.provider
.grpc()
.wasm_estimate_gas(process_message)
.await?;

Ok(Some(gas_estimate.into()))
}
}
16 changes: 16 additions & 0 deletions rust/chains/hyperlane-cosmos/src/payloads/ism_routes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,22 @@ pub struct QueryIsmGeneralRequest<T> {
pub ism: T,
}

#[derive(Serialize, Deserialize, Debug)]
pub struct VerifyRequest {
pub verify: VerifyRequestInner,
}

#[derive(Serialize, Deserialize, Debug)]
pub struct VerifyRequestInner {
pub metadata: String,
pub message: String,
}

#[derive(Serialize, Deserialize, Debug)]
pub struct VerifyResponse {
pub verified: bool,
}

#[derive(Serialize, Deserialize, Debug)]
pub struct QueryIsmModuleTypeRequest {
pub module_type: EmptyStruct,
Expand Down

0 comments on commit 52f572f

Please sign in to comment.