Skip to content

Commit

Permalink
to_padded_bytes
Browse files Browse the repository at this point in the history
  • Loading branch information
aroralanuk committed Jan 23, 2025
1 parent 7e47cda commit ff3a8b6
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ use crate::contracts::interchain_security_module::{
use crate::error::HyperlaneStarknetError;
use crate::types::HyH256;
use crate::{
build_single_owner_account, to_hpl_module_type, ConnectionConf, Signer, StarknetProvider,
build_single_owner_account, to_hpl_module_type, to_packed_bytes, ConnectionConf, Signer,
StarknetProvider,
};

impl<A> std::fmt::Display for StarknetInterchainSecurityModuleInternal<A>
Expand Down Expand Up @@ -140,7 +141,7 @@ impl InterchainSecurityModule for StarknetInterchainSecurityModule {
let tx = self.contract.verify(
&StarknetBytes {
size: metadata.len() as u32,
data: metadata.iter().map(|b| *b as u128).collect(),
data: to_packed_bytes(metadata),
},
message,
);
Expand Down
3 changes: 2 additions & 1 deletion rust/main/chains/hyperlane-starknet/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,8 @@ pub fn to_mailbox_bytes(bytes: &[u8]) -> MailboxBytes {
}
}

fn to_packed_bytes(bytes: &[u8]) -> Vec<u128> {
/// Convert a byte slice to a starknet bytes by padding the bytes to 16 bytes chunks
pub fn to_packed_bytes(bytes: &[u8]) -> Vec<u128> {
// Calculate the required padding
let padding = (16 - (bytes.len() % 16)) % 16;
let total_len = bytes.len() + padding;
Expand Down

0 comments on commit ff3a8b6

Please sign in to comment.