Class: Solace::AddressLookupTable

Inherits:
Object
  • Object
show all
Includes:
Concerns::BinarySerializable
Defined in:
lib/solace/address_lookup_table.rb

Overview

Represents a Solana Address Lookup Table account.

This class models the internal structure of a deserialized address lookup table and provides access to the account key, writable indexes, and readonly indexes.

It includes serialization and deserialization logic for encoding and decoding the table according to Solana???s buffer layout.

Buffer Layout (in bytes):

  • [account (32 bytes)]
  • [num_writable (compact-u16)]
  • [writable indexes]
  • [num_readonly (compact-u16)]
  • [readonly indexes]

Includes BinarySerializable, enabling methods like #to_binary, #to_io, and #to_bytes.

Examples:

Deserialize from base64

io = StringIO.new(base64)
table = Solace::AddressLookupTable.deserialize(io)

Serialize to base64

table = Solace::AddressLookupTable.new
table. = pubkey
table.writable_indexes = [1, 2]
table.readonly_indexes = [3, 4]
base64 = table.serialize

Since:

  • 0.0.1

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Concerns::BinarySerializable

included, #to_binary, #to_bytes, #to_io

Instance Attribute Details

#accountString

Returns The account key of the address lookup table.

Returns:

  • (String)

    The account key of the address lookup table



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

def 
  @account
end

#readonly_indexesArray<Integer>

Returns The readonly indexes in the address lookup table.

Returns:

  • (Array<Integer>)

    The readonly indexes in the address lookup table



47
48
49
# File 'lib/solace/address_lookup_table.rb', line 47

def readonly_indexes
  @readonly_indexes
end

#writable_indexesArray<Integer>

Returns The writable indexes in the address lookup table.

Returns:

  • (Array<Integer>)

    The writable indexes in the address lookup table



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

def writable_indexes
  @writable_indexes
end

Class Method Details

.deserialize(io) ⇒ Solace::AddressLookupTable

Deserializes an address lookup table from io stream

Parameters:

  • io (IO, StringIO)

    The input to read bytes from.

Returns:

Since:

  • 0.0.1



54
55
56
# File 'lib/solace/address_lookup_table.rb', line 54

def deserialize(io)
  Solace::Serializers::AddressLookupTableDeserializer.new(io).call
end

Instance Method Details

#serializeString

Serializes the address lookup table

Returns:

  • (String)

    The serialized address lookup table (base64)

Since:

  • 0.0.1



62
63
64
# File 'lib/solace/address_lookup_table.rb', line 62

def serialize
  Solace::Serializers::AddressLookupTableSerializer.new(self).call
end