Class: Solace::Message

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

Overview

Solace::Message represents the message portion of a Solana transaction (legacy or versioned). It handles serialization and deserialization of message fields.

Examples:

message = Solace::Message.new(
  version: 0,
  header: [0, 0, 0],
  accounts: ['11111111111111111111111111111111'],
  recent_blockhash: '11111111111111111111111111111111',
  instructions: [],
  address_lookup_tables: []
)

Since:

  • 0.0.1

Constant Summary collapse

SERIALIZER =

Since:

  • 0.0.1

Solace::Serializers::MessageSerializer
DESERIALIZER =

Since:

  • 0.0.1

Solace::Serializers::MessageDeserializer

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Concerns::BinarySerializable

included, #serialize, #to_binary, #to_bytes, #to_io

Constructor Details

#initialize(version: nil, accounts: [], instructions: [], recent_blockhash: nil, header: [0, 0, 0], address_lookup_tables: []) ⇒ Message

Initialize a new Message

Since:

  • 0.0.1



61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'lib/solace/message.rb', line 61

def initialize(
  version: nil,
  accounts: [],
  instructions: [],
  recent_blockhash: nil,
  header: [0, 0, 0],
  address_lookup_tables: []
)
  super()

  @version = version
  @header = header
  @accounts = accounts
  @recent_blockhash = recent_blockhash
  @instructions = instructions
  @address_lookup_tables = address_lookup_tables
end

Instance Attribute Details

#accountsArray<String>



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

def accounts
  @accounts
end

#address_lookup_tablesArray<Solace::AddressLookupTable>



51
52
53
# File 'lib/solace/message.rb', line 51

def address_lookup_tables
  @address_lookup_tables
end

#DESERIALIZERSolace::Serializers::MessageDeserializer



27
# File 'lib/solace/message.rb', line 27

DESERIALIZER = Solace::Serializers::MessageDeserializer

#headerArray<Integer>



35
36
37
# File 'lib/solace/message.rb', line 35

def header
  @header
end

#instructionsArray<Solace::Instruction>



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

def instructions
  @instructions
end

#recent_blockhashString



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

def recent_blockhash
  @recent_blockhash
end

#SERIALIZERSolace::Serializers::MessageSerializer



23
# File 'lib/solace/message.rb', line 23

SERIALIZER = Solace::Serializers::MessageSerializer

#versionInteger?



31
32
33
# File 'lib/solace/message.rb', line 31

def version
  @version
end

Instance Method Details

#num_readonly_signed_accountsInteger

Returns the number of readonly signed accounts

Since:

  • 0.0.1



96
97
98
# File 'lib/solace/message.rb', line 96

def num_readonly_signed_accounts
  header[1]
end

#num_readonly_unsigned_accountsInteger

Returns the number of readonly unsigned accounts

Since:

  • 0.0.1



103
104
105
# File 'lib/solace/message.rb', line 103

def num_readonly_unsigned_accounts
  header[2]
end

#num_required_signaturesInteger

Returns the number of required signatures

Since:

  • 0.0.1



89
90
91
# File 'lib/solace/message.rb', line 89

def num_required_signatures
  header[0]
end

#versioned?Boolean

Check if the message is versioned

Since:

  • 0.0.1



82
83
84
# File 'lib/solace/message.rb', line 82

def versioned?
  !version.nil?
end