Class: Solace::Composers::Token2022ProgramTransferCheckedComposer
- Defined in:
- lib/solace/composers/token_2022_program_transfer_checked_composer.rb
Overview
Composer for creating a Token-2022 Program ‘TransferChecked` instruction.
This composer resolves and orders the required accounts for a ‘TransferChecked` instruction, sets up their access permissions, and delegates construction to the appropriate instruction builder (`Instructions::Token2022::TransferCheckedInstruction`).
Required accounts:
-
From: source token account (writable, non-signer)
-
To: destination token account (writable, non-signer)
-
Mint: mint address (readonly, non-signer)
-
Authority: token owner (writable, signer)
-
Program: Token-2022 program (readonly, non-signer)
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#amount ⇒ Integer
Returns the amount to transfer.
-
#authority ⇒ String
Extracts the authority address from the params.
-
#build_instruction(account_context) ⇒ Solace::Instruction
Build instruction with resolved account indices.
-
#decimals ⇒ Integer
Returns the decimals for the mint of the token.
-
#from ⇒ String
Extracts the from address from the params.
-
#mint ⇒ String
Extracts the mint address from the params.
-
#setup_accounts ⇒ void
Setup accounts required for transfer instruction Called automatically during initialization.
-
#to ⇒ String
Extracts the to 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 amount to transfer
69 70 71 |
# File 'lib/solace/composers/token_2022_program_transfer_checked_composer.rb', line 69 def amount params[:amount] end |
#authority ⇒ String
Extracts the authority address from the params
The authority is the owner of the token account
50 51 52 |
# File 'lib/solace/composers/token_2022_program_transfer_checked_composer.rb', line 50 def params[:authority].to_s end |
#build_instruction(account_context) ⇒ Solace::Instruction
Build instruction with resolved account indices
96 97 98 99 100 101 102 103 104 105 106 |
# File 'lib/solace/composers/token_2022_program_transfer_checked_composer.rb', line 96 def build_instruction(account_context) Instructions::Token2022::TransferCheckedInstruction.build( amount: amount, decimals: decimals, to_index: account_context.index_of(to), from_index: account_context.index_of(from), mint_index: account_context.index_of(mint), authority_index: account_context.index_of(), program_index: account_context.index_of(token_2022_program) ) end |
#decimals ⇒ Integer
Returns the decimals for the mint of the token
76 77 78 |
# File 'lib/solace/composers/token_2022_program_transfer_checked_composer.rb', line 76 def decimals params[:decimals] end |
#from ⇒ String
Extracts the from address from the params
41 42 43 |
# File 'lib/solace/composers/token_2022_program_transfer_checked_composer.rb', line 41 def from params[:from].to_s end |
#mint ⇒ String
Extracts the mint address from the params
57 58 59 |
# File 'lib/solace/composers/token_2022_program_transfer_checked_composer.rb', line 57 def mint params[:mint].to_s end |
#setup_accounts ⇒ void
This method returns an undefined value.
Setup accounts required for transfer instruction Called automatically during initialization
84 85 86 87 88 89 90 |
# File 'lib/solace/composers/token_2022_program_transfer_checked_composer.rb', line 84 def setup_accounts account_context.add_writable_signer() account_context.add_writable_nonsigner(to) account_context.add_writable_nonsigner(from) account_context.add_readonly_nonsigner(mint) account_context.add_readonly_nonsigner(token_2022_program) end |
#to ⇒ String
Extracts the to address from the params
34 35 36 |
# File 'lib/solace/composers/token_2022_program_transfer_checked_composer.rb', line 34 def to params[:to].to_s end |
#token_2022_program ⇒ String
Returns The Token-2022 program id.
62 63 64 |
# File 'lib/solace/composers/token_2022_program_transfer_checked_composer.rb', line 62 def token_2022_program Constants::TOKEN_2022_PROGRAM_ID.to_s end |