Class: Solace::SquadsSmartAccounts::Instructions::CancelProposalInstruction

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

Overview

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

Registers a cancellation vote on an Approved proposal on behalf of a signer with the Vote permission. Once cancellations reach the threshold the proposal becomes Cancelled and its transaction can no longer execute.

Accounts (in order):

0. settings      — readonly, non-signer (consensus account)
1. signer        — writable, signer (must have the Vote permission; pays any realloc)
2. proposal      — writable, non-signer
3. systemProgram — required here (funds the proposal realloc) — unlike
   approve/reject, where this optional account is absent
4. program       — readonly, non-signer (the Squads program itself)

Shares the VoteOnProposal account context and args with approve/reject; the discriminator differs and systemProgram is present rather than absent.

Constant Summary collapse

DISCRIMINATOR =

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

[106, 74, 128, 146, 19, 65, 39, 23].freeze

Class Method Summary collapse

Class Method Details

.build(memo:, settings_index:, signer_index:, proposal_index:, system_program_index:, program_index:) ⇒ Solace::Instruction

Builds a Instruction for cancelProposal.

Parameters:

  • memo (String, nil)

    Optional indexing memo.

  • settings_index (Integer)

    Account index of the settings account.

  • signer_index (Integer)

    Account index of the voting signer.

  • proposal_index (Integer)

    Account index of the proposal.

  • system_program_index (Integer)

    Account index of systemProgram.

  • program_index (Integer)

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

Returns:

  • (Solace::Instruction)


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

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

    ix.data = data(memo:)
  end
end

.data(memo:) ⇒ Array<Integer>

Encodes the ‘VoteOnProposalArgs { memo: Option<String> }` in Borsh.

Parameters:

  • memo (String, nil)

    Optional indexing memo.

Returns:

  • (Array<Integer>)

    Byte array of the encoded instruction data.



61
62
63
# File 'lib/solace/squads_smart_accounts/instructions/cancel_proposal_instruction.rb', line 61

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