Class: Solace::Composers::Token2022ProgramCloseAccountComposer
- Defined in:
- lib/solace/composers/token_2022_program_close_account_composer.rb
Overview
Composer for creating a Token-2022 Program CloseAccount instruction.
The CloseAccount instruction closes a token account and transfers remaining lamports to a destination account. The account must have a balance of zero tokens.
Required accounts:
-
Account: token account to close (writable, non-signer)
-
Destination: account to receive lamports (writable, non-signer)
-
Authority: account authority (non-writable, signer)
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#account ⇒ String
Extracts the token account address from the params.
-
#authority ⇒ String
Extracts the authority address from the params.
-
#build_instruction(account_context) ⇒ Solace::Instruction
Build instruction with resolved account indices.
-
#destination ⇒ String
Extracts the destination address from the params.
-
#setup_accounts ⇒ void
Setup accounts required for close account instruction Called automatically during initialization.
-
#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
#account ⇒ String
Extracts the token account address from the params
27 28 29 |
# File 'lib/solace/composers/token_2022_program_close_account_composer.rb', line 27 def account params[:account].to_s end |
#authority ⇒ String
Extracts the authority address from the params
41 42 43 |
# File 'lib/solace/composers/token_2022_program_close_account_composer.rb', line 41 def params[:authority].to_s end |
#build_instruction(account_context) ⇒ Solace::Instruction
Build instruction with resolved account indices
65 66 67 68 69 70 71 72 |
# File 'lib/solace/composers/token_2022_program_close_account_composer.rb', line 65 def build_instruction(account_context) Instructions::Token2022::CloseAccountInstruction.build( account_index: account_context.index_of(account), authority_index: account_context.index_of(), destination_index: account_context.index_of(destination), program_index: account_context.index_of(token_2022_program) ) end |
#destination ⇒ String
Extracts the destination address from the params
34 35 36 |
# File 'lib/solace/composers/token_2022_program_close_account_composer.rb', line 34 def destination params[:destination].to_s end |
#setup_accounts ⇒ void
This method returns an undefined value.
Setup accounts required for close account instruction Called automatically during initialization
54 55 56 57 58 59 |
# File 'lib/solace/composers/token_2022_program_close_account_composer.rb', line 54 def setup_accounts account_context.add_writable_nonsigner(account) account_context.add_writable_nonsigner(destination) account_context.add_readonly_signer() account_context.add_readonly_nonsigner(token_2022_program) end |
#token_2022_program ⇒ String
Returns The Token-2022 program id.
46 47 48 |
# File 'lib/solace/composers/token_2022_program_close_account_composer.rb', line 46 def token_2022_program Constants::TOKEN_2022_PROGRAM_ID.to_s end |