Class: Solace::Instructions::AddressLookupTableProgram::ExtendLookupTableInstruction

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

Overview

Instruction for appending addresses to an existing address lookup table.

Newly added addresses become usable one slot after the extend lands.

Examples:

Build an ExtendLookupTable instruction

instruction = Solace::Instructions::AddressLookupTableProgram::ExtendLookupTableInstruction.build(
  addresses:            [recipient1, recipient2],
  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 ExtendLookupTable (u32 LE)

Since:

  • 0.1.8

[2, 0, 0, 0].freeze

Class Method Summary collapse

Class Method Details

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

Builds a Solace::Instruction for extending a lookup table

Parameters:

  • addresses (Array<#to_s>)

    The addresses to append to the table

  • program_index (Integer)

    Index of the lookup table program

  • table_index (Integer)

    Index of the table account (writable)

  • 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



34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/solace/instructions/address_lookup_table_program/extend_lookup_table_instruction.rb', line 34

def self.build(
  addresses:,
  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(addresses)
  end
end

.data(addresses) ⇒ Array<Integer>

Instruction data for an extend lookup table instruction

The BufferLayout is:

- [Instruction discriminator (4 bytes, u32 LE)]
- [Number of addresses (8 bytes, u64 LE)]
- [Addresses (32 bytes each)]

The address vector uses a u64 length prefix (bincode), not the u32 Borsh prefix of Utils::Codecs.encode_vec_pubkeys.

Parameters:

  • addresses (Array<#to_s>)

    The addresses to append

Returns:

  • (Array<Integer>)

Since:

  • 0.1.8



61
62
63
64
65
# File 'lib/solace/instructions/address_lookup_table_program/extend_lookup_table_instruction.rb', line 61

def self.data(addresses)
  INSTRUCTION_ID +
    Utils::Codecs.encode_le_u64(addresses.length).bytes +
    addresses.flat_map { |address| Utils::Codecs.encode_pubkey(address) }
end