Class: Solace::Composers::SquadsSmartAccountsActivateProposalComposer
- Inherits:
-
Base
- Object
- Base
- Solace::Composers::SquadsSmartAccountsActivateProposalComposer
- Defined in:
- lib/solace/squads_smart_accounts/composers/activate_proposal_composer.rb
Overview
Composes an ‘activateProposal` instruction for the Squads Smart Account program.
Moves a Draft proposal to Active. The signer must be a smart-account member with the Initiate permission. Only needed for proposals created as drafts.
Required params:
:settings [#to_s] Base58 address of the settings account.
:signer [#to_s, Keypair] The activating signer (must sign).
:proposal [#to_s] The Proposal PDA to activate.
Instance Method Summary collapse
-
#build_instruction(context) ⇒ Solace::Instruction
Builds the instruction with resolved account indices.
-
#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 activating signer address from the params.
Instance Method Details
#build_instruction(context) ⇒ Solace::Instruction
Builds the instruction with resolved account indices.
59 60 61 62 63 64 65 66 |
# File 'lib/solace/squads_smart_accounts/composers/activate_proposal_composer.rb', line 59 def build_instruction(context) SquadsSmartAccounts::Instructions::ActivateProposalInstruction.build( settings_index: context.index_of(settings), signer_index: context.index_of(signer), proposal_index: context.index_of(proposal), program_index: context.index_of(program_id) ) end |
#program_id ⇒ String
Returns the Squads Smart Account program id from the constants
39 40 41 |
# File 'lib/solace/squads_smart_accounts/composers/activate_proposal_composer.rb', line 39 def program_id SquadsSmartAccounts::PROGRAM_ID end |
#proposal ⇒ String
Extracts the proposal PDA address from the params
32 33 34 |
# File 'lib/solace/squads_smart_accounts/composers/activate_proposal_composer.rb', line 32 def proposal params[:proposal].to_s end |
#settings ⇒ String
Extracts the settings address from the params
18 19 20 |
# File 'lib/solace/squads_smart_accounts/composers/activate_proposal_composer.rb', line 18 def settings params[:settings].to_s end |
#setup_accounts ⇒ Object
Declares all accounts required by this instruction. The Squads program is registered so it appears in the message account keys (it is the invoked program), but — unlike the other proposal instructions — it is NOT included in this instruction’s account-metas list (no trailing program account).
48 49 50 51 52 53 |
# File 'lib/solace/squads_smart_accounts/composers/activate_proposal_composer.rb', line 48 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 activating signer address from the params
25 26 27 |
# File 'lib/solace/squads_smart_accounts/composers/activate_proposal_composer.rb', line 25 def signer params[:signer].to_s end |