Class: Solace::SquadsSmartAccounts::Instructions::SetTimeLockAsAuthorityInstruction

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

Overview

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

Sets the time lock (seconds between proposal approval and execution) of a controlled smart account. Only callable by the account’s settings authority — no consensus involved.

IDL accounts (in order):

0. settings          — writable, non-signer
1. settingsAuthority — readonly, signer
2. rentPayer         — writable, signer (pays for settings realloc)
3. systemProgram     — readonly, non-signer
4. program           — readonly, non-signer

Constant Summary collapse

DISCRIMINATOR =
[2, 234, 93, 93, 40, 92, 31, 234].freeze

Class Method Summary collapse

Class Method Details

.build(time_lock:, memo:, settings_index:, settings_authority_index:, rent_payer_index:, system_program_index:, program_index:) ⇒ Solace::Instruction

Builds a Instruction for setTimeLockAsAuthority.

Parameters:

  • time_lock (Integer)

    Seconds between approval and execution (u32).

  • memo (String, nil)

    Optional indexing memo.

  • settings_index (Integer)

    Account index of the settings account.

  • settings_authority_index (Integer)

    Account index of the settings authority.

  • 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.

Returns:

  • (Solace::Instruction)


32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/solace/squads_smart_accounts/instructions/set_time_lock_as_authority_instruction.rb', line 32

def self.build(
  time_lock:,
  memo:,
  settings_index:,
  settings_authority_index:,
  rent_payer_index:,
  system_program_index:,
  program_index:
)
  Solace::Instruction.new.tap do |ix|
    ix.program_index = program_index
    ix.accounts      = [
      settings_index,
      settings_authority_index,
      rent_payer_index,
      system_program_index,
      program_index
    ]

    ix.data = data(time_lock:, memo:)
  end
end

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

Encodes the ‘SetTimeLockArgs` struct in Borsh format.

Returns:

  • (Array<Integer>)

    Byte array of the encoded instruction data.



58
59
60
61
62
# File 'lib/solace/squads_smart_accounts/instructions/set_time_lock_as_authority_instruction.rb', line 58

def self.data(time_lock:, memo:)
  DISCRIMINATOR +
    Solace::Utils::Codecs.encode_le_u32(time_lock).bytes +
    Solace::Utils::Codecs.encode_option_string(memo)
end