Class: Solace::Composers::ComputeBudgetProgramSetComputeUnitPriceComposer
- Inherits:
-
Base
- Object
- Base
- Solace::Composers::ComputeBudgetProgramSetComputeUnitPriceComposer
- Defined in:
- lib/solace/composers/compute_budget_program_set_compute_unit_price_composer.rb
Overview
Composer for creating a compute budget set compute unit price instruction.
This composer resolves and orders the required accounts for a SetComputeUnitPrice
instruction, sets up their access permissions, and delegates construction to the
appropriate instruction builder (Instructions::ComputeBudget::SetComputeUnitPriceInstruction).
It is used for attaching a priority fee to a transaction.
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.
-
#micro_lamports ⇒ Integer
Extracts the price per compute unit from the params.
-
#setup_accounts ⇒ void
Setup accounts required for set compute unit price instruction Called automatically during initialization.
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_price_composer.rb', line 50 def build_instruction(account_context) Instructions::ComputeBudget::SetComputeUnitPriceInstruction.build( micro_lamports: micro_lamports, 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_price_composer.rb', line 34 def compute_budget_program Constants::COMPUTE_BUDGET_PROGRAM_ID.to_s end |
#micro_lamports ⇒ Integer
Extracts the price per compute unit from the params
27 28 29 |
# File 'lib/solace/composers/compute_budget_program_set_compute_unit_price_composer.rb', line 27 def micro_lamports params[:micro_lamports] end |
#setup_accounts ⇒ void
This method returns an undefined value.
Setup accounts required for set compute unit price instruction Called automatically during initialization
42 43 44 |
# File 'lib/solace/composers/compute_budget_program_set_compute_unit_price_composer.rb', line 42 def setup_accounts account_context.add_readonly_nonsigner(compute_budget_program) end |