Class: Solace::SquadsSmartAccounts::Instructions::ExecuteSettingsTransactionSyncInstruction

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

Overview

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

Synchronously applies a batch of SettingsActions to an autonomous smart account, provided the transaction is co-signed by enough signers to reach the settings threshold. The program rejects controlled accounts (NotSupportedForControlled) — those use the *AsAuthority instructions.

IDL accounts (in order):

0. settings      — writable, non-signer
1. rentPayer     — writable, signer (pays for settings realloc)
2. systemProgram — readonly, non-signer
3. program       — readonly, non-signer
Remaining accounts (in exact order):
4. The first `num_signers` accounts must be the threshold co-signers.
5. SpendingLimit PDAs initialized/closed by AddSpendingLimit and
   RemoveSpendingLimit actions follow, in action order.

Constant Summary collapse

DISCRIMINATOR =
[138, 209, 64, 163, 79, 67, 233, 76].freeze

Class Method Summary collapse

Class Method Details

.build(num_signers:, actions:, memo:, settings_index:, rent_payer_index:, system_program_index:, program_index:, signer_indices:, spending_limit_indices: []) ⇒ Solace::Instruction

Builds a Instruction for executeSettingsTransactionSync.

Parameters:

  • num_signers (Integer)

    Number of co-signers proving threshold consensus.

  • actions (Array<SettingsAction>)

    The settings actions to apply atomically.

  • memo (String, nil)

    Optional indexing memo.

  • settings_index (Integer)

    Account index of the settings account.

  • rent_payer_index (Integer)

    Account index of the rent payer.

  • system_program_index (Integer)

    Account index of systemProgram.

  • program_index (Integer)

    Account index of the Squads program.

  • signer_indices (Array<Integer>)

    Account indices of the threshold co-signers.

  • spending_limit_indices (Array<Integer>) (defaults to: [])

    Account indices of SpendingLimit PDAs touched by the actions (default: []).

Returns:

  • (Solace::Instruction)


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

def self.build(
  num_signers:,
  actions:,
  memo:,
  settings_index:,
  rent_payer_index:,
  system_program_index:,
  program_index:,
  signer_indices:,
  spending_limit_indices: []
)
  Solace::Instruction.new.tap do |ix|
    ix.program_index = program_index
    ix.accounts      = [
      settings_index,
      rent_payer_index,
      system_program_index,
      program_index,
      *signer_indices,
      *spending_limit_indices
    ]

    ix.data = data(num_signers:, actions:, memo:)
  end
end

.data(num_signers:, actions:, memo:) ⇒ Array<Integer>

Encodes the ‘SyncSettingsTransactionArgs` struct in Borsh format.

Returns:

  • (Array<Integer>)

    Byte array of the encoded instruction data.



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

def self.data(num_signers:, actions:, memo:)
  DISCRIMINATOR +
    [num_signers] +
    Solace::Utils::Codecs.encode_settings_actions(actions) +
    Solace::Utils::Codecs.encode_option_string(memo)
end