Class: Solace::Composers::SquadsSmartAccountsRejectProposalComposer
- Inherits:
-
Base
- Object
- Base
- Solace::Composers::SquadsSmartAccountsRejectProposalComposer
- 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
-
#build_instruction(context) ⇒ Solace::Instruction
Builds the instruction with resolved account indices.
-
#memo ⇒ String?
Extracts the memo from the params.
-
#program_id ⇒ String
Returns the Squads Smart Account program id from the constants.
-
#proposal ⇒ String
Extracts the proposal PDA address from the params.
-
#settings ⇒ String
Extracts the settings address from the params.
-
#setup_accounts ⇒ Object
Declares all accounts required by this instruction.
-
#signer ⇒ String
Extracts the voting signer address from the params.
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.
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 |
#memo ⇒ String?
Extracts the memo from the params
42 43 44 |
# File 'lib/solace/squads_smart_accounts/composers/reject_proposal_composer.rb', line 42 def memo params[:memo] end |
#program_id ⇒ String
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.
51 52 53 |
# File 'lib/solace/squads_smart_accounts/composers/reject_proposal_composer.rb', line 51 def program_id SquadsSmartAccounts::PROGRAM_ID end |
#proposal ⇒ String
Extracts the proposal PDA address from the params
35 36 37 |
# File 'lib/solace/squads_smart_accounts/composers/reject_proposal_composer.rb', line 35 def proposal params[:proposal].to_s end |
#settings ⇒ String
Extracts the settings address from the params
21 22 23 |
# File 'lib/solace/squads_smart_accounts/composers/reject_proposal_composer.rb', line 21 def settings params[:settings].to_s end |
#setup_accounts ⇒ Object
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 account_context.add_readonly_nonsigner(settings) account_context.add_writable_signer(signer) account_context.add_writable_nonsigner(proposal) account_context.add_readonly_nonsigner(program_id) end |
#signer ⇒ String
Extracts the voting signer address from the params
28 29 30 |
# File 'lib/solace/squads_smart_accounts/composers/reject_proposal_composer.rb', line 28 def signer params[:signer].to_s end |