Class: Solace::Composers::SplTokenProgramTransferCheckedComposer

Inherits:
Base
  • Object
show all
Defined in:
lib/solace/composers/spl_token_program_transfer_checked_composer.rb

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

#amountInteger

Returns the lamports to transfer

Returns:

  • (Integer)

    The lamports to transfer



46
47
48
# File 'lib/solace/composers/spl_token_program_transfer_checked_composer.rb', line 46

def amount
  params[:amount]
end

#authorityString

Extracts the authority address from the params

The authority is the owner of the token account

Returns:

  • (String)

    The authority address



25
26
27
# File 'lib/solace/composers/spl_token_program_transfer_checked_composer.rb', line 25

def authority
  params[:authority].is_a?(String) ? params[:authority] : params[:authority].address
end

#build_instruction(account_context) ⇒ Solace::Instruction

Build instruction with resolved account indices

Parameters:

Returns:



73
74
75
76
77
78
79
80
81
82
83
# File 'lib/solace/composers/spl_token_program_transfer_checked_composer.rb', line 73

def build_instruction()
  Instructions::SplToken::TransferCheckedInstruction.build(
    amount: amount,
    decimals: decimals,
    to_index: .index_of(to),
    from_index: .index_of(from),
    mint_index: .index_of(mint),
    authority_index: .index_of(authority),
    program_index: .index_of(spl_token_program)
  )
end

#decimalsInteger

Returns the decimals for the mint of the token

Returns:

  • (Integer)

    The decimals for the mint



53
54
55
# File 'lib/solace/composers/spl_token_program_transfer_checked_composer.rb', line 53

def decimals
  params[:decimals]
end

#fromString

Extracts the from address from the params

Returns:

  • (String)

    The from address



16
17
18
# File 'lib/solace/composers/spl_token_program_transfer_checked_composer.rb', line 16

def from
  params[:from].is_a?(String) ? params[:from] : params[:from].address
end

#mintString

Extracts the mint address from the params

Returns:

  • (String)

    The mint address



32
33
34
# File 'lib/solace/composers/spl_token_program_transfer_checked_composer.rb', line 32

def mint
  params[:mint].is_a?(String) ? params[:mint] : params[:mint].address
end

#setup_accountsvoid

This method returns an undefined value.

Setup accounts required for transfer instruction Called automatically during initialization



61
62
63
64
65
66
67
# File 'lib/solace/composers/spl_token_program_transfer_checked_composer.rb', line 61

def setup_accounts
  .add_writable_signer(authority)
  .add_writable_nonsigner(to)
  .add_writable_nonsigner(from)
  .add_readonly_nonsigner(mint)
  .add_readonly_nonsigner(spl_token_program)
end

#spl_token_programString

Returns the spl token program id

Returns:

  • (String)

    The spl token program id



39
40
41
# File 'lib/solace/composers/spl_token_program_transfer_checked_composer.rb', line 39

def spl_token_program
  Constants::TOKEN_PROGRAM_ID
end

#toString

Extracts the to address from the params

Returns:

  • (String)

    The to address



9
10
11
# File 'lib/solace/composers/spl_token_program_transfer_checked_composer.rb', line 9

def to
  params[:to].is_a?(String) ? params[:to] : params[:to].address
end