Class: Solace::Composers::SystemProgramTransferComposer

Inherits:
Base
  • Object
show all
Defined in:
lib/solace/composers/system_program_transfer_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

#build_instruction(account_context) ⇒ Solace::Instruction

Build instruction with resolved account indices

Parameters:

Returns:



48
49
50
51
52
53
54
55
# File 'lib/solace/composers/system_program_transfer_composer.rb', line 48

def build_instruction()
  Instructions::SystemProgram::TransferInstruction.build(
    lamports: lamports,
    to_index: .index_of(to),
    from_index: .index_of(from),
    program_index: .index_of(system_program)
  )
end

#fromString

Extracts the from address from the params

Returns:

  • (String)

    The from address



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

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

#lamportsInteger

Returns the lamports to transfer

Returns:

  • (Integer)

    The lamports to transfer



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

def lamports
  params[:lamports]
end

#setup_accountsvoid

This method returns an undefined value.

Setup accounts required for transfer instruction Called automatically during initialization



38
39
40
41
42
# File 'lib/solace/composers/system_program_transfer_composer.rb', line 38

def setup_accounts
  .add_writable_signer(from)
  .add_writable_nonsigner(to)
  .add_readonly_nonsigner(system_program)
end

#system_programString

Returns the system program id

Returns:

  • (String)

    The system program id



23
24
25
# File 'lib/solace/composers/system_program_transfer_composer.rb', line 23

def system_program
  Solace::Constants::SYSTEM_PROGRAM_ID
end

#toString

Extracts the to address from the params

Returns:

  • (String)

    The to address



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

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