Class: Solace::Composers::Token2022ProgramInitializeMintComposer

Inherits:
Base
  • Object
show all
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)

Examples:

Compose and build an initialize_mint instruction

composer = Token2022ProgramInitializeMintComposer.new(
  decimals: 6,
  mint_authority: mint_authority_pubkey,
  freeze_authority: freeze_authority_pubkey,
  mint_account: mint_address,
)

See Also:

Since:

  • 0.1.5

Instance Attribute Summary

Attributes inherited from Base

#account_context, #params

Instance Method Summary collapse

Methods inherited from Base

#initialize

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

Parameters:

Returns:

Since:

  • 0.1.5



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()
  Instructions::Token2022::InitializeMintInstruction.build(
    mint_account_index: .index_of(),
    rent_sysvar_index: .index_of(rent_sysvar),
    program_index: .index_of(token_2022_program),
    decimals: decimals,
    mint_authority: mint_authority,
    freeze_authority: freeze_authority
  )
end

#decimalsInteger

Returns the decimals for the mint

Returns:

  • (Integer)

    The decimals for the mint

Since:

  • 0.1.5



63
64
65
# File 'lib/solace/composers/token_2022_program_initialize_mint_composer.rb', line 63

def decimals
  params[:decimals]
end

#freeze_authorityString

Extracts the freeze authority address from the params

Returns:

  • (String)

    The freeze authority address

Since:

  • 0.1.5



56
57
58
# File 'lib/solace/composers/token_2022_program_initialize_mint_composer.rb', line 56

def freeze_authority
  params[:freeze_authority]&.to_s
end

#mint_accountString

Extracts the mint account address from the params

Returns:

  • (String)

    The mint account address

Since:

  • 0.1.5



30
31
32
# File 'lib/solace/composers/token_2022_program_initialize_mint_composer.rb', line 30

def 
  params[:mint_account].to_s
end

#mint_authorityString

Extracts the mint authority address from the params

Returns:

  • (String)

    The mint authority address

Since:

  • 0.1.5



49
50
51
# File 'lib/solace/composers/token_2022_program_initialize_mint_composer.rb', line 49

def mint_authority
  params[:mint_authority].to_s
end

#rent_sysvarString

Returns the rent sysvar address

Returns:

  • (String)

    The rent sysvar address

Since:

  • 0.1.5



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_accountsvoid

This method returns an undefined value.

Setup accounts required for the InitializeMint instruction Called automatically during initialization

Since:

  • 0.1.5



71
72
73
74
75
# File 'lib/solace/composers/token_2022_program_initialize_mint_composer.rb', line 71

def setup_accounts
  .add_writable_nonsigner()
  .add_readonly_nonsigner(rent_sysvar)
  .add_readonly_nonsigner(token_2022_program)
end

#token_2022_programString

Returns The Token-2022 program id.

Returns:

  • (String)

    The Token-2022 program id.

Since:

  • 0.1.5



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