Class: Solace::SquadsSmartAccounts::Transaction
- Inherits:
-
Data
- Object
- Data
- Solace::SquadsSmartAccounts::Transaction
- Defined in:
- lib/solace/squads_smart_accounts/types/transaction.rb
Overview
Immutable value object for a deserialized Transaction account — a pending vault transaction stored by ‘createTransaction` and replayed by `executeTransaction`.
Layout follows the deployed (newer) program, which the bundled IDL does not describe: the account holds a ‘Payload` enum after `index`, whose TransactionPayload variant carries account_index, ephemeral_signer_bumps, and the message. The stored message (SmartAccountTransactionMessage) uses standard Borsh Vec (u32 counts) — distinct from the SmallVec format used to submit the message. Only the message header counts and account_keys are decoded (enough to verify a round-trip); compiled instructions and address-table lookups are skipped.
Instance Attribute Summary collapse
-
#account_index ⇒ Object
readonly
Returns the value of attribute account_index.
-
#account_keys ⇒ Object
readonly
Returns the value of attribute account_keys.
-
#creator ⇒ Object
readonly
Returns the value of attribute creator.
-
#index ⇒ Object
readonly
Returns the value of attribute index.
-
#num_signers ⇒ Object
readonly
Returns the value of attribute num_signers.
-
#num_writable_non_signers ⇒ Object
readonly
Returns the value of attribute num_writable_non_signers.
-
#num_writable_signers ⇒ Object
readonly
Returns the value of attribute num_writable_signers.
-
#rent_collector ⇒ Object
readonly
Returns the value of attribute rent_collector.
-
#settings ⇒ Object
readonly
Returns the value of attribute settings.
Class Method Summary collapse
-
.deserialize(io) ⇒ Transaction
Deserializes a Transaction account from a stream of Borsh-encoded account data.
Instance Method Summary collapse
-
#account_metas ⇒ Array<Hash>
The stored message’s account_keys as ordered account metas — the inverse of how AccountContext#compile lays them out.
Instance Attribute Details
#account_index ⇒ Object (readonly)
Returns the value of attribute account_index
17 18 19 |
# File 'lib/solace/squads_smart_accounts/types/transaction.rb', line 17 def account_index @account_index end |
#account_keys ⇒ Object (readonly)
Returns the value of attribute account_keys
17 18 19 |
# File 'lib/solace/squads_smart_accounts/types/transaction.rb', line 17 def account_keys @account_keys end |
#creator ⇒ Object (readonly)
Returns the value of attribute creator
17 18 19 |
# File 'lib/solace/squads_smart_accounts/types/transaction.rb', line 17 def creator @creator end |
#index ⇒ Object (readonly)
Returns the value of attribute index
17 18 19 |
# File 'lib/solace/squads_smart_accounts/types/transaction.rb', line 17 def index @index end |
#num_signers ⇒ Object (readonly)
Returns the value of attribute num_signers
17 18 19 |
# File 'lib/solace/squads_smart_accounts/types/transaction.rb', line 17 def num_signers @num_signers end |
#num_writable_non_signers ⇒ Object (readonly)
Returns the value of attribute num_writable_non_signers
17 18 19 |
# File 'lib/solace/squads_smart_accounts/types/transaction.rb', line 17 def num_writable_non_signers @num_writable_non_signers end |
#num_writable_signers ⇒ Object (readonly)
Returns the value of attribute num_writable_signers
17 18 19 |
# File 'lib/solace/squads_smart_accounts/types/transaction.rb', line 17 def num_writable_signers @num_writable_signers end |
#rent_collector ⇒ Object (readonly)
Returns the value of attribute rent_collector
17 18 19 |
# File 'lib/solace/squads_smart_accounts/types/transaction.rb', line 17 def rent_collector @rent_collector end |
#settings ⇒ Object (readonly)
Returns the value of attribute settings
17 18 19 |
# File 'lib/solace/squads_smart_accounts/types/transaction.rb', line 17 def settings @settings end |
Class Method Details
.deserialize(io) ⇒ Transaction
Deserializes a Transaction account from a stream of Borsh-encoded account data.
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 |
# File 'lib/solace/squads_smart_accounts/types/transaction.rb', line 65 def deserialize(io) io.read(8) # skip 8-byte Anchor discriminator settings = Solace::Utils::Codecs.decode_pubkey(io) creator = Solace::Utils::Codecs.decode_pubkey(io) rent_collector = Solace::Utils::Codecs.decode_pubkey(io) index = Solace::Utils::Codecs.decode_le_u64(io) enforce_known_variant!(io) account_index = Solace::Utils::Codecs.decode_u8(io) # ephemeral_signer_bumps: Borsh Vec<u8> (u32 length + raw bytes). Skipped. io.read(Solace::Utils::Codecs.decode_le_u32(io)) # Embedded SmartAccountTransactionMessage header + account_keys (Vec, u32 count). num_signers = Solace::Utils::Codecs.decode_u8(io) num_writable_signers = Solace::Utils::Codecs.decode_u8(io) num_writable_non_signers = Solace::Utils::Codecs.decode_u8(io) account_keys = Solace::Utils::Codecs.decode_vec_pubkeys(io) new( settings:, creator:, rent_collector:, index:, account_index:, num_signers:, num_writable_signers:, num_writable_non_signers:, account_keys: ) end |
Instance Method Details
#account_metas ⇒ Array<Hash>
The stored message’s account_keys as ordered account metas — the inverse of how AccountContext#compile lays them out. Each meta carries the same writable: flags vocabulary AccountContext uses, derived from the canonical ordering [writable signers, readonly signers, writable non-signers, readonly non-signers]. This is the input executeTransaction replays as its remaining accounts (the lone signer being the vault PDA).
36 37 38 39 40 41 42 43 44 |
# File 'lib/solace/squads_smart_accounts/types/transaction.rb', line 36 def account_keys.each_index.map do |index| { pubkey: account_keys[index], signer: index < num_signers, writable: writable_index?(index) } end end |