From 367a1761fe8745c61661947e07e4887fbc827ea9 Mon Sep 17 00:00:00 2001 From: Ranadeep Biswas Date: Thu, 6 Jun 2024 10:33:17 +0200 Subject: [PATCH 1/3] add hex dep --- Cargo.lock | 1 + modules/sov-ibc/Cargo.toml | 1 + 2 files changed, 2 insertions(+) diff --git a/Cargo.lock b/Cargo.lock index 7ae21c2e..a78057e4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -6150,6 +6150,7 @@ dependencies = [ "base64 0.21.7", "borsh", "derive_more", + "hex", "ibc-app-transfer", "ibc-client-tendermint", "ibc-core", diff --git a/modules/sov-ibc/Cargo.toml b/modules/sov-ibc/Cargo.toml index 098d2f01..8710ab19 100644 --- a/modules/sov-ibc/Cargo.toml +++ b/modules/sov-ibc/Cargo.toml @@ -26,6 +26,7 @@ serde = { workspace = true } serde_json = { workspace = true, optional = true } thiserror = { workspace = true } tracing = { workspace = true } +hex = { workspace = true } # internal dependencies sov-ibc-transfer = { path = "../sov-ibc-transfer" } From 48f5c7ddb46ff33dd9a7b59de753559a0af8c374 Mon Sep 17 00:00:00 2001 From: Ranadeep Biswas Date: Thu, 6 Jun 2024 10:33:30 +0200 Subject: [PATCH 2/3] rpc method for commitmentPrefix --- modules/sov-ibc/src/rpc/methods.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/modules/sov-ibc/src/rpc/methods.rs b/modules/sov-ibc/src/rpc/methods.rs index f2249836..92dfac6e 100644 --- a/modules/sov-ibc/src/rpc/methods.rs +++ b/modules/sov-ibc/src/rpc/methods.rs @@ -711,4 +711,15 @@ impl Ibc { proof_height, )) } + + #[rpc_method(name = "commitmentPrefix")] + pub fn commitment_prefix(&self, working_set: &mut WorkingSet) -> RpcResult { + let ibc_ctx = IbcContext::new(self, Rc::new(RefCell::new(working_set))); + + let commitment_prefix = ibc_ctx.commitment_prefix(); + + let base64_commitment_prefix = hex::encode(commitment_prefix.as_bytes()); + + Ok(base64_commitment_prefix) + } } From 165066a2509dba85a7bd5f7c2af6d37073c0f903 Mon Sep 17 00:00:00 2001 From: Ranadeep Biswas Date: Thu, 6 Jun 2024 11:06:34 +0200 Subject: [PATCH 3/3] rm hex dep --- Cargo.lock | 1 - modules/sov-ibc/Cargo.toml | 1 - modules/sov-ibc/src/rpc/methods.rs | 8 ++------ 3 files changed, 2 insertions(+), 8 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a78057e4..7ae21c2e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -6150,7 +6150,6 @@ dependencies = [ "base64 0.21.7", "borsh", "derive_more", - "hex", "ibc-app-transfer", "ibc-client-tendermint", "ibc-core", diff --git a/modules/sov-ibc/Cargo.toml b/modules/sov-ibc/Cargo.toml index 8710ab19..098d2f01 100644 --- a/modules/sov-ibc/Cargo.toml +++ b/modules/sov-ibc/Cargo.toml @@ -26,7 +26,6 @@ serde = { workspace = true } serde_json = { workspace = true, optional = true } thiserror = { workspace = true } tracing = { workspace = true } -hex = { workspace = true } # internal dependencies sov-ibc-transfer = { path = "../sov-ibc-transfer" } diff --git a/modules/sov-ibc/src/rpc/methods.rs b/modules/sov-ibc/src/rpc/methods.rs index 92dfac6e..00a86f4c 100644 --- a/modules/sov-ibc/src/rpc/methods.rs +++ b/modules/sov-ibc/src/rpc/methods.rs @@ -713,13 +713,9 @@ impl Ibc { } #[rpc_method(name = "commitmentPrefix")] - pub fn commitment_prefix(&self, working_set: &mut WorkingSet) -> RpcResult { + pub fn commitment_prefix(&self, working_set: &mut WorkingSet) -> RpcResult> { let ibc_ctx = IbcContext::new(self, Rc::new(RefCell::new(working_set))); - let commitment_prefix = ibc_ctx.commitment_prefix(); - - let base64_commitment_prefix = hex::encode(commitment_prefix.as_bytes()); - - Ok(base64_commitment_prefix) + Ok(ibc_ctx.commitment_prefix().into_vec()) } }