4

I'm using the solana-transaction-status crate and want to inspect the inner instructions of a given transaction in rust.

I can fetch the transaction data using the RPC and I get a EncodedConfirmedTransactionWithStatusMeta object. I try to access the inner instructions using:

let inner_instructions = encoded_tx
                                .transaction
                                .meta
                                .to_owned()
                                .unwrap()
                                .inner_instructions;

This gives me an object of type OptionSerializer<Vec<UiInnerInstructions>>. The issue is that I have no idea how to access and traverse the inner Vec<UiInnerInstructions>. The API reference for the type doesn't seem to have an answer either: https://docs.rs/solana-transaction-status/1.14.7/solana_transaction_status/option_serializer/enum.OptionSerializer.html#method.skip

Any help would be appreciated

1 Answer 1

3

You were very close! OptionSerializer implements From on Option: https://docs.rs/solana-transaction-status/1.14.7/solana_transaction_status/option_serializer/enum.OptionSerializer.html#impl-From%3COptionSerializer%3CT%3E%3E-for-Option%3CT%3E

So you can do something like:

let inner_instructions: Option<Vec<UiInnerInstructions>> = encoded_tx
                                .transaction
                                .meta
                                .to_owned()
                                .unwrap()
                                .inner_instructions
                                .into();

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.