Class: Solace::SquadsSmartAccounts::Instructions::RemoveSpendingLimitAsAuthorityInstruction

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

Overview

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

Closes a SpendingLimit PDA, refunding its rent to the rent collector. Only callable by the account’s settings authority — no consensus involved.

IDL accounts (in order):

0. settings          — readonly, non-signer
1. settingsAuthority — readonly, signer
2. spendingLimit     — writable, non-signer (closed by the instruction)
3. rentCollector     — writable, non-signer (receives the rent refund)
4. program           — readonly, non-signer

Constant Summary collapse

DISCRIMINATOR =
[94, 32, 68, 127, 251, 44, 145, 7].freeze

Class Method Summary collapse

Class Method Details

.build(memo:, settings_index:, settings_authority_index:, spending_limit_index:, rent_collector_index:, program_index:) ⇒ Solace::Instruction

Builds a Instruction for removeSpendingLimitAsAuthority.

Parameters:

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

  • spending_limit_index (Integer)

    Account index of the SpendingLimit PDA.

  • rent_collector_index (Integer)

    Account index of the rent collector.

  • program_index (Integer)

    Account index of the Squads program.

Returns:

  • (Solace::Instruction)


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

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

    ix.data = data(memo:)
  end
end

.data(memo:) ⇒ Array<Integer>

Encodes the ‘RemoveSpendingLimitArgs` struct in Borsh format.

Returns:

  • (Array<Integer>)

    Byte array of the encoded instruction data.



56
57
58
# File 'lib/solace/squads_smart_accounts/instructions/remove_spending_limit_as_authority_instruction.rb', line 56

def self.data(memo:)
  DISCRIMINATOR + Solace::Utils::Codecs.encode_option_string(memo)
end