Skip to content

Commit

Permalink
fix: handle parsing compiled inner and inner instructions
Browse files Browse the repository at this point in the history
  • Loading branch information
kespinola committed Feb 28, 2024
1 parent 8f184d1 commit 416a448
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 15 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 12 additions & 7 deletions integration_tests/tests/integration_tests/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ use nft_ingester::config;
use once_cell::sync::Lazy;
use plerkle_serialization::{
deserializer::{
parse_account_keys, parse_message_instructions, parse_meta_inner_instructions,
parse_pubkey, parse_signature, parse_slice,
parse_account_keys, parse_compiled_inner_instructions, parse_compiled_instructions,
parse_inner_instructions, parse_pubkey, parse_signature, parse_slice,
},
root_as_account_info, root_as_transaction_info,
serializer::{seralize_encoded_transaction_with_status, serialize_account},
Expand Down Expand Up @@ -427,19 +427,24 @@ async fn cached_fetch_transaction(setup: &TestSetup, sig: Signature) -> Vec<u8>
pub async fn index_transaction(setup: &TestSetup, sig: Signature) {
let txn_bytes: Vec<u8> = cached_fetch_transaction(setup, sig).await;
let txn = root_as_transaction_info(&txn_bytes).unwrap();
let meta_inner_instructions =
parse_compiled_inner_instructions(txn.compiled_inner_instructions())
.and_then(|compiled| {
parse_inner_instructions(txn.inner_instructions())
.map(|inner| [compiled, inner].concat())
})
.expect("meta inner instructions failed to parse");

setup
.transformer
.handle_transaction(&TransactionInfo {
slot: txn.slot(),
signature: &parse_signature(txn.signature()).expect("failed to parse transaction"),
account_keys: &parse_account_keys(txn.account_keys())
.expect("failed to parse transaction"),
message_instructions: &parse_message_instructions(txn.outer_instructions())
message_instructions: &parse_compiled_instructions(txn.outer_instructions())
.expect("failed to parse transaction"),
meta_inner_instructions: &parse_meta_inner_instructions(
txn.compiled_inner_instructions(),
)
.expect("failed to parse transaction"),
meta_inner_instructions: &meta_inner_instructions,
})
.await
.unwrap();
Expand Down
19 changes: 12 additions & 7 deletions nft_ingester/src/transaction_notifications.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ use {
plerkle_messenger::{ConsumptionType, Messenger, MessengerConfig, RecvData},
plerkle_serialization::{
deserializer::{
parse_account_keys, parse_message_instructions, parse_meta_inner_instructions,
parse_signature,
parse_account_keys, parse_compiled_inner_instructions, parse_compiled_instructions,
parse_inner_instructions, parse_signature,
},
root_as_transaction_info,
},
Expand Down Expand Up @@ -130,18 +130,23 @@ async fn handle_transaction_update<'a>(
manager: Arc<ProgramTransformer>,
tx: plerkle_serialization::TransactionInfo<'_>,
) -> ProgramTransformerResult<()> {
let meta_inner_instructions =
parse_compiled_inner_instructions(tx.compiled_inner_instructions())
.and_then(|compiled| {
parse_inner_instructions(tx.inner_instructions())
.map(|inner| [compiled, inner].concat())
})
.map_err(into_program_transformer_err)?;

manager
.handle_transaction(&TransactionInfo {
slot: tx.slot(),
signature: &parse_signature(tx.signature()).map_err(into_program_transformer_err)?,
account_keys: &parse_account_keys(tx.account_keys())
.map_err(into_program_transformer_err)?,
message_instructions: &parse_message_instructions(tx.outer_instructions())
message_instructions: &parse_compiled_instructions(tx.outer_instructions())
.map_err(into_program_transformer_err)?,
meta_inner_instructions: &parse_meta_inner_instructions(
tx.compiled_inner_instructions(),
)
.map_err(into_program_transformer_err)?,
meta_inner_instructions: &meta_inner_instructions,
})
.await
}

0 comments on commit 416a448

Please sign in to comment.