Class: Solace::Instructions::AddressLookupTableProgram::CreateLookupTableInstruction

Inherits:
Object
  • Object
show all
Defined in:
lib/solace/instructions/address_lookup_table_program/create_lookup_table_instruction.rb

Overview

Instruction for creating a new (uninitialized) address lookup table.

The table's address is a program-derived address of [authority, recent_slot]; the caller supplies the derived address and its bump seed.

Examples:

Build a CreateLookupTable instruction

instruction = Solace::Instructions::AddressLookupTableProgram::CreateLookupTableInstruction.build(
  recent_slot:          123,
  bump:                 254,
  program_index:        4,
  table_index:          1,
  authority_index:      0,
  payer_index:          0,
  system_program_index: 3
)

Since:

  • 0.1.8

Constant Summary collapse

INSTRUCTION_ID =

Instruction discriminator for CreateLookupTable (u32 LE)

Since:

  • 0.1.8

[0, 0, 0, 0].freeze

Class Method Summary collapse

Class Method Details

.build(recent_slot:, bump:, program_index:, table_index:, authority_index:, payer_index:, system_program_index:) ⇒ Solace::Instruction

Builds a Solace::Instruction for creating a lookup table

Parameters:

  • recent_slot (Integer)

    The slot used to derive the table address

  • bump (Integer)

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

  • program_index (Integer)

    Index of the lookup table program

  • table_index (Integer)

    Index of the (uninitialized) table account

  • authority_index (Integer)

    Index of the table authority (signer)

  • payer_index (Integer)

    Index of the rent payer (writable signer)

  • system_program_index (Integer)

    Index of the system program

Returns:

Since:

  • 0.1.8



46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/solace/instructions/address_lookup_table_program/create_lookup_table_instruction.rb', line 46

def self.build(
  recent_slot:,
  bump:,
  program_index:,
  table_index:,
  authority_index:,
  payer_index:,
  system_program_index:
)
  Instruction.new.tap do |ix|
    ix.program_index = program_index
    ix.accounts      = [table_index, authority_index, payer_index, system_program_index]
    ix.data          = data(recent_slot, bump)
  end
end

.data(recent_slot, bump) ⇒ Array<Integer>

Instruction data for a create lookup table instruction

The BufferLayout is:

- [Instruction discriminator (4 bytes, u32 LE)]
- [Recent slot (8 bytes, u64 LE)]
- [Bump seed (1 byte)]

Parameters:

  • recent_slot (Integer)

    The slot used to derive the table address

  • bump (Integer)

    The bump seed

Returns:

  • (Array<Integer>)

Since:

  • 0.1.8



72
73
74
75
76
# File 'lib/solace/instructions/address_lookup_table_program/create_lookup_table_instruction.rb', line 72

def self.data(recent_slot, bump)
  INSTRUCTION_ID +
    Utils::Codecs.encode_le_u64(recent_slot).bytes +
    [bump]
end