Class: Solace::Composers::SquadsSmartAccountsSetTimeLockAsAuthorityComposer

Inherits:
Base
  • Object
show all
Defined in:
lib/solace/squads_smart_accounts/composers/set_time_lock_as_authority_composer.rb

Overview

Composes a ‘setTimeLockAsAuthority` instruction for the Squads Smart Account program.

Sets the time lock of a controlled smart account. Only the account’s settings authority may do this — single signature, no consensus.

Required params:

:settings           [String]         Base58 address of the settings account.
:settings_authority [#to_s, Keypair] The account's settings authority (must sign).
:rent_payer         [#to_s, Keypair] Pays for settings account reallocation (must sign).
:time_lock          [Integer]        Seconds between approval and execution.

Optional params:

:memo [String] Indexing memo (default: nil).

Instance Method Summary collapse

Instance Method Details

#build_instruction(context) ⇒ Solace::Instruction

Builds the instruction with resolved account indices.

Parameters:

  • context (Solace::Utils::AccountContext)

    Merged context from TransactionComposer.

Returns:

  • (Solace::Instruction)


81
82
83
84
85
86
87
88
89
90
91
# File 'lib/solace/squads_smart_accounts/composers/set_time_lock_as_authority_composer.rb', line 81

def build_instruction(context)
  SquadsSmartAccounts::Instructions::SetTimeLockAsAuthorityInstruction.build(
    time_lock:,
    memo:,
    settings_index:           context.index_of(settings),
    settings_authority_index: context.index_of(settings_authority),
    rent_payer_index:         context.index_of(rent_payer),
    system_program_index:     context.index_of(system_program),
    program_index:            context.index_of(program_id)
  )
end

#memoString?

Extracts the memo from the params

Returns:

  • (String, nil)

    The memo



50
51
52
# File 'lib/solace/squads_smart_accounts/composers/set_time_lock_as_authority_composer.rb', line 50

def memo
  params[:memo]
end

#program_idString

Returns the Squads Smart Account program id from the constants

Returns:

  • (String)

    The Squads Smart Account program id



57
58
59
# File 'lib/solace/squads_smart_accounts/composers/set_time_lock_as_authority_composer.rb', line 57

def program_id
  SquadsSmartAccounts::PROGRAM_ID
end

#rent_payerString

Extracts the rent payer address from the params

Returns:

  • (String)

    The rent payer address



36
37
38
# File 'lib/solace/squads_smart_accounts/composers/set_time_lock_as_authority_composer.rb', line 36

def rent_payer
  params[:rent_payer].to_s
end

#settingsString

Extracts the settings address from the params

Returns:

  • (String)

    The settings address



22
23
24
# File 'lib/solace/squads_smart_accounts/composers/set_time_lock_as_authority_composer.rb', line 22

def settings
  params[:settings].to_s
end

#settings_authorityString

Extracts the settings authority address from the params

Returns:

  • (String)

    The settings authority address



29
30
31
# File 'lib/solace/squads_smart_accounts/composers/set_time_lock_as_authority_composer.rb', line 29

def settings_authority
  params[:settings_authority].to_s
end

#setup_accountsObject

Declares all accounts required by this instruction.



69
70
71
72
73
74
75
# File 'lib/solace/squads_smart_accounts/composers/set_time_lock_as_authority_composer.rb', line 69

def setup_accounts
  .add_writable_nonsigner(settings)
  .add_readonly_signer(settings_authority)
  .add_writable_signer(rent_payer)
  .add_readonly_nonsigner(system_program)
  .add_readonly_nonsigner(program_id)
end

#system_programString

Returns the system program id from the constants

Returns:

  • (String)

    The system program id



64
65
66
# File 'lib/solace/squads_smart_accounts/composers/set_time_lock_as_authority_composer.rb', line 64

def system_program
  Solace::Constants::SYSTEM_PROGRAM_ID
end

#time_lockInteger

Extracts the time lock from the params

Returns:

  • (Integer)

    Seconds between approval and execution



43
44
45
# File 'lib/solace/squads_smart_accounts/composers/set_time_lock_as_authority_composer.rb', line 43

def time_lock
  params[:time_lock]
end