Class: Solace::Composers::SplTokenProgramInitializeMintComposer
- Defined in:
- lib/solace/composers/spl_token_program_initialize_mint_composer.rb
Overview
Composer for initializing a mint via the SPL Token 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::SplToken::InitializeMintInstruction`).
It is used for initializing a new SPL Token mint.
Required accounts:
-
**Mint Account**: the mint account to initialize (writable, 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 transfer instruction Called automatically during initialization.
-
#spl_token_program ⇒ String
Returns the spl token 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
83 84 85 86 87 88 89 90 91 92 |
# File 'lib/solace/composers/spl_token_program_initialize_mint_composer.rb', line 83 def build_instruction(account_context) Instructions::SplToken::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(spl_token_program), decimals: decimals, mint_authority: , freeze_authority: ) end |
#decimals ⇒ Integer
Returns the decimals for the mint
65 66 67 |
# File 'lib/solace/composers/spl_token_program_initialize_mint_composer.rb', line 65 def decimals params[:decimals] end |
#freeze_authority ⇒ String
Extracts the freeze authority address from the params
58 59 60 |
# File 'lib/solace/composers/spl_token_program_initialize_mint_composer.rb', line 58 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/spl_token_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
51 52 53 |
# File 'lib/solace/composers/spl_token_program_initialize_mint_composer.rb', line 51 def params[:mint_authority].to_s end |
#rent_sysvar ⇒ String
Returns the rent sysvar address
37 38 39 |
# File 'lib/solace/composers/spl_token_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 transfer instruction Called automatically during initialization
73 74 75 76 77 |
# File 'lib/solace/composers/spl_token_program_initialize_mint_composer.rb', line 73 def setup_accounts account_context.add_writable_nonsigner(mint_account) account_context.add_readonly_nonsigner(rent_sysvar) account_context.add_readonly_nonsigner(spl_token_program) end |
#spl_token_program ⇒ String
Returns the spl token program id
44 45 46 |
# File 'lib/solace/composers/spl_token_program_initialize_mint_composer.rb', line 44 def spl_token_program Constants::TOKEN_PROGRAM_ID.to_s end |