Class: Solace::Composers::SquadsSmartAccountsCancelProposalComposer
- Inherits:
-
Base
- Object
- Base
- Solace::Composers::SquadsSmartAccountsCancelProposalComposer
- 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
-
#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.
-
#system_program ⇒ String
Returns the system program id from the constants.
Instance Method Details
#build_instruction(context) ⇒ Solace::Instruction
Builds the instruction with resolved account indices.
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 |
#memo ⇒ String?
Extracts the memo from the params
43 44 45 |
# File 'lib/solace/squads_smart_accounts/composers/cancel_proposal_composer.rb', line 43 def memo params[:memo] end |
#program_id ⇒ String
Returns the Squads Smart Account program id from the constants
50 51 52 |
# File 'lib/solace/squads_smart_accounts/composers/cancel_proposal_composer.rb', line 50 def program_id SquadsSmartAccounts::PROGRAM_ID end |
#proposal ⇒ String
Extracts the proposal PDA address from the params
36 37 38 |
# File 'lib/solace/squads_smart_accounts/composers/cancel_proposal_composer.rb', line 36 def proposal params[:proposal].to_s end |
#settings ⇒ String
Extracts the settings address from the params
22 23 24 |
# File 'lib/solace/squads_smart_accounts/composers/cancel_proposal_composer.rb', line 22 def settings params[:settings].to_s end |
#setup_accounts ⇒ Object
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 account_context.add_readonly_nonsigner(settings) account_context.add_writable_signer(signer) account_context.add_writable_nonsigner(proposal) account_context.add_readonly_nonsigner(system_program) account_context.add_readonly_nonsigner(program_id) end |
#signer ⇒ String
Extracts the voting signer address from the params
29 30 31 |
# File 'lib/solace/squads_smart_accounts/composers/cancel_proposal_composer.rb', line 29 def signer params[:signer].to_s end |
#system_program ⇒ String
Returns the system program id from the constants
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 |