TridentTransaction#
The TridentTransaction
macro is used to derive required methods for Transactions
. This procedural macro automatically implements transaction-related functionality for structs that represent transactions.
Derived Traits#
The macro implements the following traits:
TransactionGetters
- Methods to retrieve transaction dataTransactionSetters
- Methods to set up transaction stateTransactionMethods
- Core transaction execution methods
Manual Implementation Note
There is no need to manually implement the getter, setter, or core methods. The macro handles these implementations automatically based on the structure of your transaction.
Transaction Methods#
build
#
Creates a new transaction instance from fuzzer data.
fn build(
fuzzer_data: &mut FuzzerData,
client: &mut impl FuzzClient,
fuzz_accounts: &mut Self::IxAccounts,
) -> arbitrary::Result<Self>
execute
#
Execute the transaction with the TransactionHooks.
execute_no_hooks
#
Execute the transaction without the TransactionHooks (simplified version).
Transaction Getters#
Internal Method
These methods are used internally by Trident and is not expected to use them manually.
get_transaction_name
#
Returns the name of the transaction. If a custom name is provided via the #[name("...")]
attribute, that name will be used; otherwise, the struct name is used.
get_instruction_discriminators
#
Returns the instruction discriminators (identifiers) for all instructions in the transaction.
get_instruction_program_ids
#
Returns the program IDs that will process the instructions.
get_instruction_data
#
Returns the instruction-specific data/parameters for all instructions in the transaction.
get_instruction_accounts
#
Returns the account metadata needed for the instructions.
Transaction Setters#
Internal Method
These methods are used internally by Trident and is not expected to use them manually.
set_snapshot_before
#
Captures the state of all accounts before transaction execution.
set_snapshot_after
#
Captures the state of all accounts after transaction execution.
set_instructions
#
Sets up all instructions for the transaction.
Instruction Setup Order
The order in which the instructions inputs are set are:
set_data
- Sets up instruction-specific dataresolve_accounts
- Resolves account addressesset_accounts
- Sets up account metadataset_remaining_accounts
- Sets up any additional accounts
fn set_instructions(
&mut self,
client: &mut impl FuzzClient,
fuzz_accounts: &mut Self::IxAccounts,
)
Struct-Level Attributes#
These attributes are applied to the struct definition itself.
name
#
The custom name of the transaction. This is optional - if not provided, the struct name will be used.