Class: Solace::Composers::SquadsSmartAccountsActivateProposalComposer

Inherits:
Base
  • Object
show all
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

Instance Method Details

#build_instruction(context) ⇒ Solace::Instruction

Builds the instruction with resolved account indices.

Parameters:

  • context (Solace::Utils::AccountContext)

    Merged context from TransactionComposer.

Returns:

  • (Solace::Instruction)


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_idString

Returns the Squads Smart Account program id from the constants

Returns:

  • (String)

    The Squads Smart Account program id



39
40
41
# File 'lib/solace/squads_smart_accounts/composers/activate_proposal_composer.rb', line 39

def program_id
  SquadsSmartAccounts::PROGRAM_ID
end

#proposalString

Extracts the proposal PDA address from the params

Returns:

  • (String)

    The proposal address



32
33
34
# File 'lib/solace/squads_smart_accounts/composers/activate_proposal_composer.rb', line 32

def proposal
  params[:proposal].to_s
end

#settingsString

Extracts the settings address from the params

Returns:

  • (String)

    The settings address



18
19
20
# File 'lib/solace/squads_smart_accounts/composers/activate_proposal_composer.rb', line 18

def settings
  params[:settings].to_s
end

#setup_accountsObject

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
  .add_readonly_nonsigner(settings)
  .add_writable_signer(signer)
  .add_writable_nonsigner(proposal)
  .add_readonly_nonsigner(program_id)
end

#signerString

Extracts the activating signer address from the params

Returns:

  • (String)

    The signer address



25
26
27
# File 'lib/solace/squads_smart_accounts/composers/activate_proposal_composer.rb', line 25

def signer
  params[:signer].to_s
end