Class: Solace::Composers::AssociatedTokenAccountProgramCreateAccountComposer
- Inherits:
-
Base
- Object
- Base
- Solace::Composers::AssociatedTokenAccountProgramCreateAccountComposer
- Defined in:
- lib/solace/composers/associated_token_account_program_create_account_composer.rb
Overview
Composer for creating an associated token account program create account instruction
This composer resolves and orders the required accounts for a ‘CreateAssociatedTokenAccount` instruction, sets up their access permissions, and delegates construction to the appropriate instruction builder (`Instructions::AssociatedTokenAccount::CreateAssociatedTokenAccountInstruction`).
Required accounts:
-
Funder: the account that will pay for fees and rent.
-
Owner: the account that will own the new ATA.
-
ATA: the address of the new ATA.
-
Mint: the mint address of the token.
-
**System Program**: the system program id.
-
**Token Program**: the token program id.
-
**Associated Token Account Program**: the associated token account program id.
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#associated_token_account_program_id ⇒ String
Extracts the associated token account program id from the constants.
-
#ata_address ⇒ String
Extracts the ata_address from the params.
-
#build_instruction(account_context) ⇒ Solace::Instruction
Builds the instruction for the associated token account program create account instruction.
-
#funder ⇒ String
Extracts the funder address from the params.
-
#mint ⇒ String
Extracts the mint address from the params.
-
#owner ⇒ String
Extracts the owner address from the params.
-
#setup_accounts ⇒ void
Setup accounts required for associated token account program create account instruction Called automatically during initialization.
-
#system_program_id ⇒ String
Extracts the system program id from the constants.
-
#token_program_id ⇒ String
Extracts the token program id from the constants.
Methods inherited from Base
Constructor Details
This class inherits a constructor from Solace::Composers::Base
Instance Method Details
#associated_token_account_program_id ⇒ String
Extracts the associated token account program id from the constants
76 77 78 |
# File 'lib/solace/composers/associated_token_account_program_create_account_composer.rb', line 76 def associated_token_account_program_id Constants::ASSOCIATED_TOKEN_ACCOUNT_PROGRAM_ID.to_s end |
#ata_address ⇒ String
Extracts the ata_address from the params
48 49 50 |
# File 'lib/solace/composers/associated_token_account_program_create_account_composer.rb', line 48 def ata_address params[:ata_address].to_s end |
#build_instruction(account_context) ⇒ Solace::Instruction
Builds the instruction for the associated token account program create account instruction
98 99 100 101 102 103 104 105 106 107 108 |
# File 'lib/solace/composers/associated_token_account_program_create_account_composer.rb', line 98 def build_instruction(account_context) Instructions::AssociatedTokenAccount::CreateAssociatedTokenAccountInstruction.build( funder_index: account_context.index_of(funder), owner_index: account_context.index_of(owner), mint_index: account_context.index_of(mint), associated_token_account_index: account_context.index_of(ata_address), system_program_index: account_context.index_of(system_program_id), token_program_index: account_context.index_of(token_program_id), program_index: account_context.index_of(associated_token_account_program_id) ) end |
#funder ⇒ String
Extracts the funder address from the params
55 56 57 |
# File 'lib/solace/composers/associated_token_account_program_create_account_composer.rb', line 55 def funder params[:funder].to_s end |
#mint ⇒ String
Extracts the mint address from the params
41 42 43 |
# File 'lib/solace/composers/associated_token_account_program_create_account_composer.rb', line 41 def mint params[:mint].to_s end |
#owner ⇒ String
Extracts the owner address from the params
34 35 36 |
# File 'lib/solace/composers/associated_token_account_program_create_account_composer.rb', line 34 def owner params[:owner].to_s end |
#setup_accounts ⇒ void
This method returns an undefined value.
Setup accounts required for associated token account program create account instruction Called automatically during initialization
84 85 86 87 88 89 90 91 92 |
# File 'lib/solace/composers/associated_token_account_program_create_account_composer.rb', line 84 def setup_accounts # rubocop:disable Metrics/AbcSize account_context.add_writable_signer(funder) account_context.add_writable_nonsigner(ata_address) account_context.add_readonly_nonsigner(owner) account_context.add_readonly_nonsigner(mint) account_context.add_readonly_nonsigner(system_program_id) account_context.add_readonly_nonsigner(token_program_id) account_context.add_readonly_nonsigner(associated_token_account_program_id) end |
#system_program_id ⇒ String
Extracts the system program id from the constants
62 63 64 |
# File 'lib/solace/composers/associated_token_account_program_create_account_composer.rb', line 62 def system_program_id Constants::SYSTEM_PROGRAM_ID.to_s end |
#token_program_id ⇒ String
Extracts the token program id from the constants
69 70 71 |
# File 'lib/solace/composers/associated_token_account_program_create_account_composer.rb', line 69 def token_program_id Constants::TOKEN_PROGRAM_ID.to_s end |