Class: Solace::SquadsSmartAccounts::CreateSmartAccountEvent

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

Overview

Immutable value object representing the ‘CreateSmartAccountEvent` the program emits when a smart account is created. It is the `CreateSmartAccountEvent` variant of the Borsh `SmartAccountEvent` enum carried inside LogEventArgs#event, so deserialization reads the 1-byte enum variant tag before the event fields.

On windowed creation the program picks one candidate settings PDA from the offered window; this event is the only way to learn which one was chosen (see Solace::Programs::SquadsSmartAccount#created_smart_account_settings).

The on-chain event also carries ‘new_settings_content: Settings`, but only `new_settings_pubkey` is decoded here — it is all the caller needs to derive the vault, and the trailing Settings can be fetched on demand.

Examples:

event = CreateSmartAccountEvent.deserialize(StringIO.new(log_event_args.event))
event.new_settings_pubkey # => base58 settings address

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Attribute Details

#new_settings_pubkeyObject (readonly)

Returns the value of attribute new_settings_pubkey

Returns:

  • (Object)

    the current value of new_settings_pubkey



22
23
24
# File 'lib/solace/squads_smart_accounts/types/create_smart_account_event.rb', line 22

def new_settings_pubkey
  @new_settings_pubkey
end

Class Method Details

.deserialize(io) ⇒ CreateSmartAccountEvent

Deserializes a CreateSmartAccountEvent from a stream of Borsh-encoded SmartAccountEvent bytes (positioned at the enum variant tag).

Parameters:

  • io (IO, StringIO)

    Stream positioned at the start of the event.

Returns:



30
31
32
33
34
35
36
# File 'lib/solace/squads_smart_accounts/types/create_smart_account_event.rb', line 30

def self.deserialize(io)
  Solace::Utils::Codecs.decode_u8(io) # SmartAccountEvent enum variant tag

  new(
    new_settings_pubkey: Solace::Utils::Codecs.decode_pubkey(io)
  )
end