Class: Solace::SquadsSmartAccounts::TransactionMessage

Inherits:
Data
  • Object
show all
Defined in:
lib/solace/squads_smart_accounts/types/transaction_message.rb

Overview

Immutable value object for the program’s TransactionMessage — a compiled inner transaction stored by ‘createTransaction` and replayed by `executeTransaction`. It mirrors a Solana v0 message: account keys ordered [writable signers, readonly signers, writable non-signers, readonly non-signers] with the three header counts, plus compiled instructions.

Address-table lookups are not supported yet and are always serialized as an empty SmallVec.

Examples:

message = TransactionMessage.new(
  num_signers:              1,
  num_writable_signers:     1,
  num_writable_non_signers: 1,
  account_keys:             [vault, recipient, system_program],
  instructions:             [compiled_transfer]
)
message.serialize # => [Integer, ...]

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#account_keysObject (readonly)

Returns the value of attribute account_keys

Returns:

  • (Object)

    the current value of account_keys



23
24
25
# File 'lib/solace/squads_smart_accounts/types/transaction_message.rb', line 23

def 
  @account_keys
end

#instructionsObject (readonly)

Returns the value of attribute instructions

Returns:

  • (Object)

    the current value of instructions



23
24
25
# File 'lib/solace/squads_smart_accounts/types/transaction_message.rb', line 23

def instructions
  @instructions
end

#num_signersObject (readonly)

Returns the value of attribute num_signers

Returns:

  • (Object)

    the current value of num_signers



23
24
25
# File 'lib/solace/squads_smart_accounts/types/transaction_message.rb', line 23

def num_signers
  @num_signers
end

#num_writable_non_signersObject (readonly)

Returns the value of attribute num_writable_non_signers

Returns:

  • (Object)

    the current value of num_writable_non_signers



23
24
25
# File 'lib/solace/squads_smart_accounts/types/transaction_message.rb', line 23

def num_writable_non_signers
  @num_writable_non_signers
end

#num_writable_signersObject (readonly)

Returns the value of attribute num_writable_signers

Returns:

  • (Object)

    the current value of num_writable_signers



23
24
25
# File 'lib/solace/squads_smart_accounts/types/transaction_message.rb', line 23

def num_writable_signers
  @num_writable_signers
end

Instance Method Details

#serializeArray<Integer>

Serializes the message in the Squads SmallVec format.

Returns:

  • (Array<Integer>)

    The serialized message bytes.



33
34
35
36
37
38
# File 'lib/solace/squads_smart_accounts/types/transaction_message.rb', line 33

def serialize
  [num_signers, num_writable_signers, num_writable_non_signers] +
    Solace::Utils::Codecs.encode_smallvec_u8_pubkeys() +
    Solace::Utils::Codecs.encode_compiled_instructions(instructions) +
    [0] # address_table_lookups: empty SmallVec<u8, _>
end