Class: Solace::Composers::SquadsSmartAccountsCancelProposalComposer

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

Overview

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

Casts a cancellation vote on an Approved proposal. The signer must be a smart account member with the Vote permission. Unlike approve/reject, the System program is a required account (it funds the proposal realloc).

Required params:

:settings [#to_s]          Base58 address of the settings account.
:signer   [#to_s, Keypair] The voting signer (must sign).
:proposal [#to_s]          The Proposal PDA to cancel (must be Approved).

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)


74
75
76
77
78
79
80
81
82
83
# File 'lib/solace/squads_smart_accounts/composers/cancel_proposal_composer.rb', line 74

def build_instruction(context)
  SquadsSmartAccounts::Instructions::CancelProposalInstruction.build(
    memo:,
    settings_index:       context.index_of(settings),
    signer_index:         context.index_of(signer),
    proposal_index:       context.index_of(proposal),
    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



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

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



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

def program_id
  SquadsSmartAccounts::PROGRAM_ID
end

#proposalString

Extracts the proposal PDA address from the params

Returns:

  • (String)

    The proposal address



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

def proposal
  params[:proposal].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/cancel_proposal_composer.rb', line 22

def settings
  params[:settings].to_s
end

#setup_accountsObject

Declares all accounts required by this instruction.



62
63
64
65
66
67
68
# File 'lib/solace/squads_smart_accounts/composers/cancel_proposal_composer.rb', line 62

def setup_accounts
  .add_readonly_nonsigner(settings)
  .add_writable_signer(signer)
  .add_writable_nonsigner(proposal)
  .add_readonly_nonsigner(system_program)
  .add_readonly_nonsigner(program_id)
end

#signerString

Extracts the voting signer address from the params

Returns:

  • (String)

    The signer address



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

def signer
  params[:signer].to_s
end

#system_programString

Returns the system program id from the constants

Returns:

  • (String)

    The system program id



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

def system_program
  Solace::Constants::SYSTEM_PROGRAM_ID
end