Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions crates/ibc-types-core-commitment/src/prefix.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use crate::prelude::*;
use crate::MerklePath;

use crate::Error;

Expand All @@ -10,6 +11,18 @@ pub struct MerklePrefix {
pub key_prefix: Vec<u8>,
}

impl MerklePrefix {
/// apply the prefix to the supplied paths
pub fn apply(&self, paths: Vec<String>) -> MerklePath {
let commitment_str =
core::str::from_utf8(&self.key_prefix).expect("commitment prefix is not valid utf-8");
let mut key_path: Vec<String> = vec![format!("{commitment_str:?}")];
key_path.append(paths.clone().as_mut());

MerklePath { key_path }
}
}

impl TypeUrl for MerklePrefix {
const TYPE_URL: &'static str = "/ibc.core.commitment.v1.MerklePrefix";
}
Expand Down