Class: Solace::Composers::SquadsSmartAccountsRejectProposalComposer

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

Overview

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

Casts a rejection vote on an active proposal. The signer must be a smart account member with the Vote permission.

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 vote on.

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. The absent systemProgram slot resolves to the Squads program id index.

Parameters:

  • context (Solace::Utils::AccountContext)

    Merged context from TransactionComposer.

Returns:

  • (Solace::Instruction)


68
69
70
71
72
73
74
75
76
77
# File 'lib/solace/squads_smart_accounts/composers/reject_proposal_composer.rb', line 68

def build_instruction(context)
  SquadsSmartAccounts::Instructions::RejectProposalInstruction.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(program_id),
    program_index:        context.index_of(program_id)
  )
end

#memoString?

Extracts the memo from the params

Returns:

  • (String, nil)

    The memo



42
43
44
# File 'lib/solace/squads_smart_accounts/composers/reject_proposal_composer.rb', line 42

def memo
  params[:memo]
end

#program_idString

Returns the Squads Smart Account program id from the constants. The systemProgram account is optional and absent for a vote, so this id also fills that slot.

Returns:

  • (String)

    The Squads Smart Account program id



51
52
53
# File 'lib/solace/squads_smart_accounts/composers/reject_proposal_composer.rb', line 51

def program_id
  SquadsSmartAccounts::PROGRAM_ID
end

#proposalString

Extracts the proposal PDA address from the params

Returns:

  • (String)

    The proposal address



35
36
37
# File 'lib/solace/squads_smart_accounts/composers/reject_proposal_composer.rb', line 35

def proposal
  params[:proposal].to_s
end

#settingsString

Extracts the settings address from the params

Returns:

  • (String)

    The settings address



21
22
23
# File 'lib/solace/squads_smart_accounts/composers/reject_proposal_composer.rb', line 21

def settings
  params[:settings].to_s
end

#setup_accountsObject

Declares all accounts required by this instruction.



56
57
58
59
60
61
# File 'lib/solace/squads_smart_accounts/composers/reject_proposal_composer.rb', line 56

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

#signerString

Extracts the voting signer address from the params

Returns:

  • (String)

    The signer address



28
29
30
# File 'lib/solace/squads_smart_accounts/composers/reject_proposal_composer.rb', line 28

def signer
  params[:signer].to_s
end