Class: Solace::Composers::SystemProgramTransferComposer
- Defined in:
- lib/solace/composers/system_program_transfer_composer.rb
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#build_instruction(account_context) ⇒ Solace::Instruction
Build instruction with resolved account indices.
-
#from ⇒ String
Extracts the from address from the params.
-
#lamports ⇒ Integer
Returns the lamports to transfer.
-
#setup_accounts ⇒ void
Setup accounts required for transfer instruction Called automatically during initialization.
-
#system_program ⇒ String
Returns the system program id.
-
#to ⇒ String
Extracts the to address 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
48 49 50 51 52 53 54 55 |
# File 'lib/solace/composers/system_program_transfer_composer.rb', line 48 def build_instruction(account_context) Instructions::SystemProgram::TransferInstruction.build( lamports: lamports, to_index: account_context.index_of(to), from_index: account_context.index_of(from), program_index: account_context.index_of(system_program) ) end |
#from ⇒ String
Extracts the from address from the params
16 17 18 |
# File 'lib/solace/composers/system_program_transfer_composer.rb', line 16 def from params[:from].is_a?(String) ? params[:from] : params[:from].address end |
#lamports ⇒ Integer
Returns the lamports to transfer
30 31 32 |
# File 'lib/solace/composers/system_program_transfer_composer.rb', line 30 def lamports params[:lamports] end |
#setup_accounts ⇒ void
This method returns an undefined value.
Setup accounts required for transfer instruction Called automatically during initialization
38 39 40 41 42 |
# File 'lib/solace/composers/system_program_transfer_composer.rb', line 38 def setup_accounts account_context.add_writable_signer(from) account_context.add_writable_nonsigner(to) account_context.add_readonly_nonsigner(system_program) end |
#system_program ⇒ String
Returns the system program id
23 24 25 |
# File 'lib/solace/composers/system_program_transfer_composer.rb', line 23 def system_program Solace::Constants::SYSTEM_PROGRAM_ID end |
#to ⇒ String
Extracts the to address from the params
9 10 11 |
# File 'lib/solace/composers/system_program_transfer_composer.rb', line 9 def to params[:to].is_a?(String) ? params[:to] : params[:to].address end |