Repository navigation
v0.13.0
This is a relatively important update of the library bringing in improved version of the utilities the exist to iterate over instructions as well as access to pre-resolved Instruction's program id and accounts. The goal of this update was to make it easier to process instruction(s), reducing the overall code needed to link inner instructions and to avoid the need to implement account resolution.
Essentially, this update adds a new InstructionView replacing the older one. This InstructionView has resolved progam id, resolved accounts and provides access to the transaction, compiled instruction and inner instructions (if viewing a CompiledInstruction).
You now get an InstructionView when iterating over all CompiledInstruction (a.k.a root instruction) of a transaction via ConfirmedTransaction::compiled_instructions (this was previously named instructions() directly).
And you can now also iterates over all instructions, root or inner(s), of a transaction via ConfirmedTransaction::walk_instructions.
The same method are available on the Block directly to easily walk over all instructions found in a block.
In this update, we also added an Address type that is a simply wrapper today around a &Vec<u8> with methods to more easily convert to base58 string (to_string) as well as testing equality against various other types. For now Address is mainly used within the new InstructionView struct, we plan on using it more where possible in the future.
In future updates, we plan to also attach the logs properly to InstructionView.
Breaking changes
-
Replaced
InstructionViewwith an updated incompatible version, the 3 public fields that you had access to before has been removed in favor of methods instead, enabling future refactoring without breaking the API. Check next point for how to update. -
The methods
Block::instructionsandConfirmedTransaction::instructionshave been both renamed tocompiled_instructions, they are still return an iterator to an InstructionView.for view in trx.instructions() { let meta = view.meta; let transaction = view.transaction; let program_id = resolve_account(view.instruction.program_id_index); let accounts = resolve_accounts(view.instruction.accounts); let data = view.instruction.data; }
Becomes
for view in trx.compiled_instructions() { let meta = view.meta(); let transaction = view.transaction(); // Program ID and accounts are already resolved now! let program_id = view.program_id(); let accounts = view.accounts(); let data = view.data(); }
-
The all_instructions method added on
0.12.0on bothBlockandConfirmedTransactionhas been renamed towalk_instructionsto better convey the fact that we iterate over compiled (root) instruction and inner instructions.for view in trx.all_instructions() { // ... }
Becomes
for view in trx.walk_instructions() { // ... }
Changes
-
Added account_at which returns the account at the given index.
-
Added ConfirmedTransaction::walk_instructions to more easily walk over compiled and inner instructions.
-
Renamed
instructionstocompiled_instructions. -
Improved InstructionView so that methods now returns resolved program ID and accounts and well as a bunch of newer helper(s).