Class: Solace::Composers::SquadsSmartAccountsCreateProposalComposer
- Inherits:
-
Base
- Object
- Base
- Solace::Composers::SquadsSmartAccountsCreateProposalComposer
- Defined in:
- lib/solace/squads_smart_accounts/composers/create_proposal_composer.rb
Overview
Composes a ‘createProposal` instruction for the Squads Smart Account program.
Creates the Proposal account that tracks votes for a stored Transaction. The transaction must already exist (its index is referenced here).
Required params:
:settings [#to_s] Base58 address of the settings account.
:proposal [#to_s] The Proposal PDA to create.
:creator [#to_s, Keypair] A smart-account signer creating the proposal (must sign).
:rent_payer [#to_s, Keypair] Funds the new account's rent (must sign).
:transaction_index [Integer] Index of the transaction this proposal tracks.
Optional params:
:draft [Boolean] Initialize as Draft instead of Active (default: false).
Instance Method Summary collapse
-
#build_instruction(context) ⇒ Solace::Instruction
Builds the instruction with resolved account indices.
-
#creator ⇒ String
Extracts the creator address from the params.
-
#draft ⇒ Boolean
Extracts the draft flag 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.
-
#rent_payer ⇒ String
Extracts the rent payer address from the params.
-
#settings ⇒ String
Extracts the settings address from the params.
-
#setup_accounts ⇒ Object
Declares all accounts required by this instruction.
-
#system_program ⇒ String
Returns the system program id from the constants.
-
#transaction_index ⇒ Integer
Extracts the transaction index from the params.
Instance Method Details
#build_instruction(context) ⇒ Solace::Instruction
Builds the instruction with resolved account indices.
90 91 92 93 94 95 96 97 98 99 100 101 |
# File 'lib/solace/squads_smart_accounts/composers/create_proposal_composer.rb', line 90 def build_instruction(context) SquadsSmartAccounts::Instructions::CreateProposalInstruction.build( transaction_index:, draft:, settings_index: context.index_of(settings), proposal_index: context.index_of(proposal), creator_index: context.index_of(creator), rent_payer_index: context.index_of(rent_payer), system_program_index: context.index_of(system_program), program_index: context.index_of(program_id) ) end |
#creator ⇒ String
Extracts the creator address from the params
37 38 39 |
# File 'lib/solace/squads_smart_accounts/composers/create_proposal_composer.rb', line 37 def creator params[:creator].to_s end |
#draft ⇒ Boolean
Extracts the draft flag from the params
58 59 60 |
# File 'lib/solace/squads_smart_accounts/composers/create_proposal_composer.rb', line 58 def draft params[:draft] || false end |
#program_id ⇒ String
Returns the Squads Smart Account program id from the constants
65 66 67 |
# File 'lib/solace/squads_smart_accounts/composers/create_proposal_composer.rb', line 65 def program_id SquadsSmartAccounts::PROGRAM_ID end |
#proposal ⇒ String
Extracts the proposal PDA address from the params
30 31 32 |
# File 'lib/solace/squads_smart_accounts/composers/create_proposal_composer.rb', line 30 def proposal params[:proposal].to_s end |
#rent_payer ⇒ String
Extracts the rent payer address from the params
44 45 46 |
# File 'lib/solace/squads_smart_accounts/composers/create_proposal_composer.rb', line 44 def rent_payer params[:rent_payer].to_s end |
#settings ⇒ String
Extracts the settings address from the params
23 24 25 |
# File 'lib/solace/squads_smart_accounts/composers/create_proposal_composer.rb', line 23 def settings params[:settings].to_s end |
#setup_accounts ⇒ Object
Declares all accounts required by this instruction.
77 78 79 80 81 82 83 84 |
# File 'lib/solace/squads_smart_accounts/composers/create_proposal_composer.rb', line 77 def setup_accounts account_context.add_readonly_nonsigner(settings) account_context.add_writable_nonsigner(proposal) account_context.add_readonly_signer(creator) account_context.add_writable_signer(rent_payer) account_context.add_readonly_nonsigner(system_program) account_context.add_readonly_nonsigner(program_id) end |
#system_program ⇒ String
Returns the system program id from the constants
72 73 74 |
# File 'lib/solace/squads_smart_accounts/composers/create_proposal_composer.rb', line 72 def system_program Solace::Constants::SYSTEM_PROGRAM_ID end |
#transaction_index ⇒ Integer
Extracts the transaction index from the params
51 52 53 |
# File 'lib/solace/squads_smart_accounts/composers/create_proposal_composer.rb', line 51 def transaction_index params[:transaction_index] end |