Class: Solace::SquadsSmartAccounts::Instructions::ExecuteTransactionSyncInstruction

Inherits:
Object
  • Object
show all
Defined in:
lib/solace/squads_smart_accounts/instructions/execute_transaction_sync_instruction.rb

Overview

Encodes the ‘executeTransactionSync` instruction for the Squads Smart Account program.

Synchronously executes inner instructions signed by a smart account (vault) PDA, provided the transaction is co-signed by enough signers to reach the settings threshold. Skips the proposal/voting lifecycle entirely.

IDL accounts (in order):

0. settings — readonly, non-signer
1. program  — readonly, non-signer
Remaining accounts (in exact order):
2. The first `num_signers` accounts must be the threshold signers.
3. All accounts referenced by the inner instructions. Inner instruction
   indexes are relative to the FULL remaining-accounts list, signers
   included (0 = the first signer).

Constant Summary collapse

DISCRIMINATOR =

8-byte Anchor discriminator: SHA256(“global:execute_transaction_sync”)

[43, 102, 248, 89, 231, 97, 104, 134].freeze

Class Method Summary collapse

Class Method Details

.build(account_index:, num_signers:, instructions:, settings_index:, program_index:, signer_indices:, remaining_account_indices:) ⇒ Solace::Instruction

Builds a Instruction for executeTransactionSync.

Parameters:

  • account_index (Integer)

    Index of the vault the inner instructions spend from.

  • num_signers (Integer)

    Number of signer accounts proving threshold consensus.

  • instructions (Array<Solace::Instruction>)

    Pre-compiled inner instructions whose program_index and accounts are indexes into the full remaining-accounts list.

  • settings_index (Integer)

    Account index of the settings account.

  • program_index (Integer)

    Account index of the Squads program.

  • signer_indices (Array<Integer>)

    Account indices of the threshold signers.

  • remaining_account_indices (Array<Integer>)

    Account indices of every account referenced by the inner instructions, in compiled order.

Returns:

  • (Solace::Instruction)


36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/solace/squads_smart_accounts/instructions/execute_transaction_sync_instruction.rb', line 36

def self.build(
  account_index:,
  num_signers:,
  instructions:,
  settings_index:,
  program_index:,
  signer_indices:,
  remaining_account_indices:
)
  Solace::Instruction.new.tap do |ix|
    ix.program_index = program_index
    ix.accounts      = [
      settings_index,
      program_index,
      *signer_indices,
      *
    ]

    ix.data = data(
      account_index:,
      num_signers:,
      instructions:
    )
  end
end

.data(account_index:, num_signers:, instructions:) ⇒ Array<Integer>

Encodes the ‘SyncTransactionArgs` struct in Borsh format.

The inner instructions are double-wrapped: serialized as a SmallVec<u8, CompiledInstruction>, then embedded as a Borsh bytes field (u32 LE length prefix).

Returns:

  • (Array<Integer>)

    Byte array of the encoded instruction data.



69
70
71
72
73
74
75
76
# File 'lib/solace/squads_smart_accounts/instructions/execute_transaction_sync_instruction.rb', line 69

def self.data(account_index:, num_signers:, instructions:)
  DISCRIMINATOR +
    [] +
    [num_signers] +
    Solace::Utils::Codecs.encode_bytes(
      Solace::Utils::Codecs.encode_compiled_instructions(instructions)
    )
end