Class: Solace::Composers::ComputeBudgetProgramSetComputeUnitLimitComposer
- Inherits:
-
Base
- Object
- Base
- Solace::Composers::ComputeBudgetProgramSetComputeUnitLimitComposer
- Defined in:
- lib/solace/composers/compute_budget_program_set_compute_unit_limit_composer.rb
Overview
Composer for creating a compute budget set compute unit limit instruction.
This composer resolves and orders the required accounts for a SetComputeUnitLimit
instruction, sets up their access permissions, and delegates construction to the
appropriate instruction builder (Instructions::ComputeBudget::SetComputeUnitLimitInstruction).
It is used for capping the compute units a transaction may consume.
Required accounts:
- Program: Compute Budget program (readonly, non-signer)
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#build_instruction(account_context) ⇒ Solace::Instruction
Build instruction with resolved account indices.
-
#compute_budget_program ⇒ String
Returns the compute budget program id.
-
#setup_accounts ⇒ void
Setup accounts required for set compute unit limit instruction Called automatically during initialization.
-
#units ⇒ Integer
Extracts the compute unit limit from the params.
Methods inherited from Base
Constructor Details
This class inherits a constructor from Solace::Composers::Base
Instance Method Details
#build_instruction(account_context) ⇒ Solace::Instruction
Build instruction with resolved account indices
50 51 52 53 54 55 |
# File 'lib/solace/composers/compute_budget_program_set_compute_unit_limit_composer.rb', line 50 def build_instruction(account_context) Instructions::ComputeBudget::SetComputeUnitLimitInstruction.build( units: units, program_index: account_context.index_of(compute_budget_program) ) end |
#compute_budget_program ⇒ String
Returns the compute budget program id
34 35 36 |
# File 'lib/solace/composers/compute_budget_program_set_compute_unit_limit_composer.rb', line 34 def compute_budget_program Constants::COMPUTE_BUDGET_PROGRAM_ID.to_s end |
#setup_accounts ⇒ void
This method returns an undefined value.
Setup accounts required for set compute unit limit instruction Called automatically during initialization
42 43 44 |
# File 'lib/solace/composers/compute_budget_program_set_compute_unit_limit_composer.rb', line 42 def setup_accounts account_context.add_readonly_nonsigner(compute_budget_program) end |
#units ⇒ Integer
Extracts the compute unit limit from the params
27 28 29 |
# File 'lib/solace/composers/compute_budget_program_set_compute_unit_limit_composer.rb', line 27 def units params[:units] end |