Class: Solace::Composers::SplTokenProgramTransferCheckedComposer
- Defined in:
- lib/solace/composers/spl_token_program_transfer_checked_composer.rb
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#amount ⇒ Integer
Returns the lamports 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.
-
#spl_token_program ⇒ String
Returns the spl token 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
#amount ⇒ Integer
Returns the lamports to transfer
46 47 48 |
# File 'lib/solace/composers/spl_token_program_transfer_checked_composer.rb', line 46 def amount params[:amount] end |
#authority ⇒ String
Extracts the authority address from the params
The authority is the owner of the token account
25 26 27 |
# File 'lib/solace/composers/spl_token_program_transfer_checked_composer.rb', line 25 def params[:authority].is_a?(String) ? params[:authority] : params[:authority].address end |
#build_instruction(account_context) ⇒ Solace::Instruction
Build instruction with resolved account indices
73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/solace/composers/spl_token_program_transfer_checked_composer.rb', line 73 def build_instruction(account_context) Instructions::SplToken::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(spl_token_program) ) end |
#decimals ⇒ Integer
Returns the decimals for the mint of the token
53 54 55 |
# File 'lib/solace/composers/spl_token_program_transfer_checked_composer.rb', line 53 def decimals params[:decimals] end |
#from ⇒ String
Extracts the from address from the params
16 17 18 |
# File 'lib/solace/composers/spl_token_program_transfer_checked_composer.rb', line 16 def from params[:from].is_a?(String) ? params[:from] : params[:from].address end |
#mint ⇒ String
Extracts the mint address from the params
32 33 34 |
# File 'lib/solace/composers/spl_token_program_transfer_checked_composer.rb', line 32 def mint params[:mint].is_a?(String) ? params[:mint] : params[:mint].address end |
#setup_accounts ⇒ void
This method returns an undefined value.
Setup accounts required for transfer instruction Called automatically during initialization
61 62 63 64 65 66 67 |
# File 'lib/solace/composers/spl_token_program_transfer_checked_composer.rb', line 61 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(spl_token_program) end |
#spl_token_program ⇒ String
Returns the spl token program id
39 40 41 |
# File 'lib/solace/composers/spl_token_program_transfer_checked_composer.rb', line 39 def spl_token_program Constants::TOKEN_PROGRAM_ID end |
#to ⇒ String
Extracts the to address from the params
9 10 11 |
# File 'lib/solace/composers/spl_token_program_transfer_checked_composer.rb', line 9 def to params[:to].is_a?(String) ? params[:to] : params[:to].address end |