Class: Solace::Composers::Token2022ProgramInitializeMintComposer
- Defined in:
- lib/solace/composers/token_2022_program_initialize_mint_composer.rb
Overview
Composer for initializing a mint via the Token-2022 Program.
This composer resolves and orders the required accounts for an ‘InitializeMint` instruction, sets up their access permissions, and delegates construction to the appropriate instruction builder (`Instructions::Token2022::InitializeMintInstruction`).
Required accounts:
-
**Mint Account**: the mint account to initialize (writable, non-signer)
-
**Rent Sysvar**: the rent sysvar (readonly, non-signer)
-
Program: Token-2022 program (readonly, non-signer)
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#build_instruction(account_context) ⇒ Solace::Instruction
Build instruction with resolved account indices.
-
#decimals ⇒ Integer
Returns the decimals for the mint.
-
#freeze_authority ⇒ String
Extracts the freeze authority address from the params.
-
#mint_account ⇒ String
Extracts the mint account address from the params.
-
#mint_authority ⇒ String
Extracts the mint authority address from the params.
-
#rent_sysvar ⇒ String
Returns the rent sysvar address.
-
#setup_accounts ⇒ void
Setup accounts required for the InitializeMint 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
#build_instruction(account_context) ⇒ Solace::Instruction
Build instruction with resolved account indices
81 82 83 84 85 86 87 88 89 90 |
# File 'lib/solace/composers/token_2022_program_initialize_mint_composer.rb', line 81 def build_instruction(account_context) Instructions::Token2022::InitializeMintInstruction.build( mint_account_index: account_context.index_of(mint_account), rent_sysvar_index: account_context.index_of(rent_sysvar), program_index: account_context.index_of(token_2022_program), decimals: decimals, mint_authority: , freeze_authority: ) end |
#decimals ⇒ Integer
Returns the decimals for the mint
63 64 65 |
# File 'lib/solace/composers/token_2022_program_initialize_mint_composer.rb', line 63 def decimals params[:decimals] end |
#freeze_authority ⇒ String
Extracts the freeze authority address from the params
56 57 58 |
# File 'lib/solace/composers/token_2022_program_initialize_mint_composer.rb', line 56 def params[:freeze_authority]&.to_s end |
#mint_account ⇒ String
Extracts the mint account address from the params
30 31 32 |
# File 'lib/solace/composers/token_2022_program_initialize_mint_composer.rb', line 30 def mint_account params[:mint_account].to_s end |
#mint_authority ⇒ String
Extracts the mint authority address from the params
49 50 51 |
# File 'lib/solace/composers/token_2022_program_initialize_mint_composer.rb', line 49 def params[:mint_authority].to_s end |
#rent_sysvar ⇒ String
Returns the rent sysvar address
37 38 39 |
# File 'lib/solace/composers/token_2022_program_initialize_mint_composer.rb', line 37 def rent_sysvar Constants::SYSVAR_RENT_PROGRAM_ID.to_s end |
#setup_accounts ⇒ void
This method returns an undefined value.
Setup accounts required for the InitializeMint instruction Called automatically during initialization
71 72 73 74 75 |
# File 'lib/solace/composers/token_2022_program_initialize_mint_composer.rb', line 71 def setup_accounts account_context.add_writable_nonsigner(mint_account) account_context.add_readonly_nonsigner(rent_sysvar) account_context.add_readonly_nonsigner(token_2022_program) end |
#token_2022_program ⇒ String
Returns The Token-2022 program id.
42 43 44 |
# File 'lib/solace/composers/token_2022_program_initialize_mint_composer.rb', line 42 def token_2022_program Constants::TOKEN_2022_PROGRAM_ID.to_s end |