Class: Solace::Composers::AddressLookupTableProgramCreateComposer

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

Overview

Composer for creating an address lookup table.

Resolves and orders the accounts for a CreateLookupTable instruction and delegates construction to Instructions::AddressLookupTableProgram::CreateLookupTableInstruction.

The table address is a program-derived address of [authority, recent_slot]; derive it (and its bump) with Utils::PDA and pass both in.

Required accounts:

  • Table: the uninitialized table account (writable, non-signer)
  • Authority: controls the table (readonly, signer)
  • Payer: funds the table's rent (writable, signer)
  • System program (readonly, non-signer)

Examples:

composer = AddressLookupTableProgramCreateComposer.new(
  table:       table_address,
  authority:   authority,
  payer:       payer,
  recent_slot: recent_slot,
  bump:        bump
)

See Also:

Since:

  • 0.1.8

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

#authorityString

Returns The table authority.

Returns:

  • (String)

    The table authority

Since:

  • 0.1.8



38
39
40
# File 'lib/solace/composers/address_lookup_table_program_create_composer.rb', line 38

def authority
  params[:authority].to_s
end

#build_instruction(account_context) ⇒ Solace::Instruction

Build instruction with resolved account indices

Parameters:

Returns:

Since:

  • 0.1.8



82
83
84
85
86
87
88
89
90
91
92
# File 'lib/solace/composers/address_lookup_table_program_create_composer.rb', line 82

def build_instruction()
  Solace::Instructions::AddressLookupTableProgram::CreateLookupTableInstruction.build(
    recent_slot:          recent_slot,
    bump:                 bump,
    program_index:        .index_of(lookup_table_program),
    table_index:          .index_of(table),
    authority_index:      .index_of(authority),
    payer_index:          .index_of(payer),
    system_program_index: .index_of(system_program)
  )
end

#bumpInteger

Returns The bump seed for the table's program-derived address.

Returns:

  • (Integer)

    The bump seed for the table's program-derived address

Since:

  • 0.1.8



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

def bump
  params[:bump]
end

#lookup_table_programString

Returns The address lookup table program id.

Returns:

  • (String)

    The address lookup table program id

Since:

  • 0.1.8



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

def lookup_table_program
  Solace::Constants::ADDRESS_LOOKUP_TABLE_PROGRAM_ID.to_s
end

#payerString

Returns The rent payer.

Returns:

  • (String)

    The rent payer

Since:

  • 0.1.8



43
44
45
# File 'lib/solace/composers/address_lookup_table_program_create_composer.rb', line 43

def payer
  params[:payer].to_s
end

#recent_slotInteger

Returns The slot used to derive the table address.

Returns:

  • (Integer)

    The slot used to derive the table address

Since:

  • 0.1.8



58
59
60
# File 'lib/solace/composers/address_lookup_table_program_create_composer.rb', line 58

def recent_slot
  params[:recent_slot]
end

#setup_accountsvoid

This method returns an undefined value.

Setup accounts required for the create lookup table instruction

Since:

  • 0.1.8



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

def setup_accounts
  .add_writable_nonsigner(table)
  .add_readonly_signer(authority)
  .add_writable_signer(payer)
  .add_readonly_nonsigner(system_program)
  .add_readonly_nonsigner(lookup_table_program)
end

#system_programString

Returns The system program id.

Returns:

  • (String)

    The system program id

Since:

  • 0.1.8



48
49
50
# File 'lib/solace/composers/address_lookup_table_program_create_composer.rb', line 48

def system_program
  Solace::Constants::SYSTEM_PROGRAM_ID.to_s
end

#tableString

Returns The table's on-chain address.

Returns:

  • (String)

    The table's on-chain address

Since:

  • 0.1.8



33
34
35
# File 'lib/solace/composers/address_lookup_table_program_create_composer.rb', line 33

def table
  params[:table].to_s
end