Skip to content

Commit b83914a

Browse files
chore(ibc-union): expose canonical packet hashing
1 parent 80f4b3a commit b83914a

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

lib/ibc-union-spec/src/path.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,13 @@ pub const CHANNELS: U256 = U256::from_limbs([3, 0, 0, 0]);
3434
pub const PACKETS: U256 = U256::from_limbs([4, 0, 0, 0]);
3535
pub const PACKET_ACKS: U256 = U256::from_limbs([5, 0, 0, 0]);
3636

37+
#[cfg(feature = "ethabi")]
38+
#[must_use]
39+
pub fn commit_packets(packets: &[Packet]) -> H256 {
40+
use alloy_sol_types::SolValue;
41+
keccak256(packets.abi_encode())
42+
}
43+
3744
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Enumorph)]
3845
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
3946
#[cfg_attr(
@@ -193,9 +200,8 @@ impl BatchReceiptsPath {
193200
#[cfg(feature = "ethabi")]
194201
#[must_use]
195202
pub fn from_packets(packets: &[Packet]) -> Self {
196-
use alloy_sol_types::SolValue;
197203
Self {
198-
batch_hash: keccak256(packets.abi_encode()),
204+
batch_hash: commit_packets(packets),
199205
}
200206
}
201207

@@ -261,3 +267,4 @@ fn connection_key() {
261267
dbg!(ConnectionPath { connection_id: 4 }.key());
262268
dbg!(ConnectionPath { connection_id: 5 }.key());
263269
}
270+

0 commit comments

Comments
 (0)