diff --git a/rust/main/chains/hyperlane-sealevel/src/mailbox.rs b/rust/main/chains/hyperlane-sealevel/src/mailbox.rs index b58f369a20..c44115579f 100644 --- a/rust/main/chains/hyperlane-sealevel/src/mailbox.rs +++ b/rust/main/chains/hyperlane-sealevel/src/mailbox.rs @@ -709,7 +709,7 @@ impl SealevelMailboxIndexer { Err(HyperlaneSealevelError::TooManyTransactions("Block contains more than one dispatch message transaction operating on the same dispatch message store PDA".to_owned()))? } - let transaction_hash = transaction_hashes + let (transaction_index, transaction_hash) = transaction_hashes .into_iter() .next() .ok_or(HyperlaneSealevelError::NoTransactions("block which should contain message dispatch transaction does not contain any after filtering".to_owned()))?; @@ -723,7 +723,7 @@ impl SealevelMailboxIndexer { // It's inconvenient to get these :| block_hash, transaction_id: transaction_hash, - transaction_index: 0, + transaction_index: transaction_index as u64, log_index: U256::zero(), }, )) diff --git a/rust/main/chains/hyperlane-sealevel/src/transaction.rs b/rust/main/chains/hyperlane-sealevel/src/transaction.rs index 274ec82eb2..0a9526a6c4 100644 --- a/rust/main/chains/hyperlane-sealevel/src/transaction.rs +++ b/rust/main/chains/hyperlane-sealevel/src/transaction.rs @@ -32,16 +32,17 @@ pub fn search_dispatched_message_transactions( mailbox_program_id: &Pubkey, message_storage_pda_pubkey: &Pubkey, transactions: Vec, -) -> Vec { +) -> Vec<(usize, H512)> { transactions .into_iter() - .filter_map(|tx| match (tx.transaction, tx.meta) { + .enumerate() + .filter_map(|(index, tx)| match (tx.transaction, tx.meta) { // We support only transactions encoded as JSON // We need none-empty metadata as well - (EncodedTransaction::Json(t), Some(m)) => Some((t, m)), + (EncodedTransaction::Json(t), Some(m)) => Some((index, t, m)), _ => None, }) - .filter_map(|(t, m)| { + .filter_map(|(index, t, m)| { let transaction_hash = match t.signatures.first() { Some(h) => h, None => return None, // if transaction is not signed, we continue the search @@ -70,9 +71,9 @@ pub fn search_dispatched_message_transactions( OptionSerializer::None | OptionSerializer::Skip => return None, }; - Some((transaction_hash, message, instructions)) + Some((index, transaction_hash, message, instructions)) }) - .filter_map(|(hash, message, instructions)| { + .filter_map(|(index, hash, message, instructions)| { let account_keys = message .account_keys .into_iter() @@ -125,9 +126,9 @@ pub fn search_dispatched_message_transactions( return None; } - Some(hash) + Some((index, hash)) }) - .collect::>() + .collect::>() } #[cfg(test)]