Class: Solace::Composers::Token2022ProgramTransferComposer
- Defined in:
- lib/solace/composers/token_2022_program_transfer_composer.rb
Overview
Composer for creating a Token-2022 Program Transfer instruction.
This composer resolves and orders the required accounts for a ‘Transfer` instruction, sets up their access permissions, and delegates construction to the appropriate instruction builder (`Instructions::Token2022::TransferInstruction`).
Required accounts:
-
Owner: token account owner (writable, signer)
-
Source: source token account (writable, non-signer)
-
Destination: destination token account (writable, non-signer)
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#amount ⇒ Integer
Returns the lamports to transfer.
-
#build_instruction(account_context) ⇒ Solace::Instruction
Build instruction with resolved account indices.
-
#destination ⇒ String
Extracts the destination associated token address from the params.
-
#owner ⇒ String
Extracts the owner address from the params.
-
#setup_accounts ⇒ void
Setup accounts required for transfer instruction Called automatically during initialization.
-
#source ⇒ String
Extracts the source associated token address from the params.
-
#token_2022_program ⇒ String
The Token-2022 program id.
Methods inherited from Base
Constructor Details
This class inherits a constructor from Solace::Composers::Base
Instance Method Details
#amount ⇒ Integer
Returns the lamports to transfer
56 57 58 |
# File 'lib/solace/composers/token_2022_program_transfer_composer.rb', line 56 def amount params[:amount] end |
#build_instruction(account_context) ⇒ Solace::Instruction
Build instruction with resolved account indices
75 76 77 78 79 80 81 82 83 |
# File 'lib/solace/composers/token_2022_program_transfer_composer.rb', line 75 def build_instruction(account_context) Instructions::Token2022::TransferInstruction.build( amount: amount, owner_index: account_context.index_of(owner), source_index: account_context.index_of(source), destination_index: account_context.index_of(destination), program_index: account_context.index_of(token_2022_program) ) end |
#destination ⇒ String
Extracts the destination associated token address from the params
44 45 46 |
# File 'lib/solace/composers/token_2022_program_transfer_composer.rb', line 44 def destination params[:destination].to_s end |
#owner ⇒ String
Extracts the owner address from the params
30 31 32 |
# File 'lib/solace/composers/token_2022_program_transfer_composer.rb', line 30 def owner params[:owner].to_s end |
#setup_accounts ⇒ void
This method returns an undefined value.
Setup accounts required for transfer instruction Called automatically during initialization
64 65 66 67 68 69 |
# File 'lib/solace/composers/token_2022_program_transfer_composer.rb', line 64 def setup_accounts account_context.add_writable_signer(owner) account_context.add_writable_nonsigner(source) account_context.add_writable_nonsigner(destination) account_context.add_readonly_nonsigner(token_2022_program) end |
#source ⇒ String
Extracts the source associated token address from the params
37 38 39 |
# File 'lib/solace/composers/token_2022_program_transfer_composer.rb', line 37 def source params[:source].to_s end |
#token_2022_program ⇒ String
Returns The Token-2022 program id.
49 50 51 |
# File 'lib/solace/composers/token_2022_program_transfer_composer.rb', line 49 def token_2022_program Constants::TOKEN_2022_PROGRAM_ID.to_s end |