Class: Solace::SquadsSmartAccounts::Instructions::ExecuteTransactionInstruction

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

Overview

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

Executes the inner instructions of an Approved proposal’s stored Transaction. The vault (smart account) PDA signs the inner instructions via CPI — the program patches its signer bit at runtime — so it is passed among the remaining accounts as a non-signer.

Fixed accounts (in order):

0. settings    — writable, non-signer (consensus account)
1. proposal    — writable, non-signer
2. transaction — readonly, non-signer
3. signer      — readonly, signer (must have the Execute permission)
4. program     — readonly, non-signer (the Squads program itself)

Followed by the remaining accounts: the stored message’s account_keys in order, each writable per the message header and all as non-signers (the lone message signer is the vault PDA, which the program signs via CPI).

executeTransaction takes no arguments — its data is the discriminator only.

Constant Summary collapse

DISCRIMINATOR =

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

[231, 173, 49, 91, 235, 24, 68, 19].freeze

Class Method Summary collapse

Class Method Details

.build(settings_index:, proposal_index:, transaction_index:, signer_index:, program_index:, remaining_account_indices:) ⇒ Solace::Instruction

Builds a Instruction for executeTransaction.

Parameters:

  • settings_index (Integer)

    Account index of the settings account.

  • proposal_index (Integer)

    Account index of the proposal.

  • transaction_index (Integer)

    Account index of the transaction PDA.

  • signer_index (Integer)

    Account index of the executing signer.

  • program_index (Integer)

    Account index of the Squads program (the invoked program).

  • remaining_account_indices (Array<Integer>)

    Account indices of the message’s account_keys, in stored order.

Returns:

  • (Solace::Instruction)


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

def self.build(
  settings_index:,
  proposal_index:,
  transaction_index:,
  signer_index:,
  program_index:,
  remaining_account_indices:
)
  Solace::Instruction.new.tap do |ix|
    ix.program_index = program_index
    ix.accounts      = [
      settings_index,
      proposal_index,
      transaction_index,
      signer_index,
      program_index
    ] + 

    ix.data = data
  end
end

.dataArray<Integer>

Encodes the instruction data — the discriminator only; executeTransaction takes no arguments.

Returns:

  • (Array<Integer>)

    Byte array of the encoded instruction data.



65
66
67
# File 'lib/solace/squads_smart_accounts/instructions/execute_transaction_instruction.rb', line 65

def self.data
  DISCRIMINATOR
end