Class: Solace::Composers::SquadsSmartAccountsExecuteSettingsTransactionComposer
- Inherits:
-
Base
- Object
- Base
- Solace::Composers::SquadsSmartAccountsExecuteSettingsTransactionComposer
- Defined in:
- lib/solace/squads_smart_accounts/composers/execute_settings_transaction_composer.rb
Overview
Composes an ‘executeSettingsTransaction` instruction for the Squads Smart Account program.
Applies the stored SettingsActions of an Approved proposal’s SettingsTransaction to the settings account. SpendingLimit PDAs touched by AddSpendingLimit / RemoveSpendingLimit actions are appended as remaining accounts in action order.
Required params:
:settings [#to_s] Base58 address of the settings account.
:signer [#to_s, Keypair] The executing signer (must sign; needs Execute permission).
:proposal [#to_s] The Proposal PDA (must be Approved).
:transaction [#to_s] The SettingsTransaction PDA to apply.
:rent_payer [#to_s, Keypair] Pays for any settings realloc (must sign).
Optional params:
:spending_limit_accounts [Array<#to_s>] SpendingLimit PDAs initialized or
closed by the actions, in action order (default: []).
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.
-
#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.
-
#signer ⇒ String
Extracts the executing signer address from the params.
-
#spending_limit_accounts ⇒ Array<String>
Extracts the spending limit PDAs touched by the actions from the params.
-
#system_program ⇒ String
Returns the system program id from the constants.
-
#transaction ⇒ String
Extracts the settings transaction PDA address from the params.
Instance Method Details
#build_instruction(context) ⇒ Solace::Instruction
Builds the instruction with resolved account indices.
98 99 100 101 102 103 104 105 106 107 108 109 |
# File 'lib/solace/squads_smart_accounts/composers/execute_settings_transaction_composer.rb', line 98 def build_instruction(context) SquadsSmartAccounts::Instructions::ExecuteSettingsTransactionInstruction.build( settings_index: context.index_of(settings), signer_index: context.index_of(signer), proposal_index: context.index_of(proposal), transaction_index: context.index_of(transaction), rent_payer_index: context.index_of(rent_payer), system_program_index: context.index_of(system_program), program_index: context.index_of(program_id), spending_limit_indices: spending_limit_accounts.map { |account| context.index_of(account) } ) end |
#program_id ⇒ String
Returns the Squads Smart Account program id from the constants
69 70 71 |
# File 'lib/solace/squads_smart_accounts/composers/execute_settings_transaction_composer.rb', line 69 def program_id SquadsSmartAccounts::PROGRAM_ID end |
#proposal ⇒ String
Extracts the proposal PDA address from the params
41 42 43 |
# File 'lib/solace/squads_smart_accounts/composers/execute_settings_transaction_composer.rb', line 41 def proposal params[:proposal].to_s end |
#rent_payer ⇒ String
Extracts the rent payer address from the params
55 56 57 |
# File 'lib/solace/squads_smart_accounts/composers/execute_settings_transaction_composer.rb', line 55 def rent_payer params[:rent_payer].to_s end |
#settings ⇒ String
Extracts the settings address from the params
27 28 29 |
# File 'lib/solace/squads_smart_accounts/composers/execute_settings_transaction_composer.rb', line 27 def settings params[:settings].to_s end |
#setup_accounts ⇒ Object
Declares all accounts required by this instruction.
81 82 83 84 85 86 87 88 89 90 91 92 |
# File 'lib/solace/squads_smart_accounts/composers/execute_settings_transaction_composer.rb', line 81 def setup_accounts # rubocop:disable Metrics/AbcSize account_context.add_writable_nonsigner(settings) account_context.add_readonly_signer(signer) account_context.add_writable_nonsigner(proposal) account_context.add_readonly_nonsigner(transaction) account_context.add_writable_signer(rent_payer) account_context.add_readonly_nonsigner(system_program) account_context.add_readonly_nonsigner(program_id) # SpendingLimit PDAs initialized/closed by the actions, in action order. spending_limit_accounts.each { |account| account_context.add_writable_nonsigner(account) } end |
#signer ⇒ String
Extracts the executing signer address from the params
34 35 36 |
# File 'lib/solace/squads_smart_accounts/composers/execute_settings_transaction_composer.rb', line 34 def signer params[:signer].to_s end |
#spending_limit_accounts ⇒ Array<String>
Extracts the spending limit PDAs touched by the actions from the params
62 63 64 |
# File 'lib/solace/squads_smart_accounts/composers/execute_settings_transaction_composer.rb', line 62 def spending_limit_accounts (params[:spending_limit_accounts] || []).map(&:to_s) end |
#system_program ⇒ String
Returns the system program id from the constants
76 77 78 |
# File 'lib/solace/squads_smart_accounts/composers/execute_settings_transaction_composer.rb', line 76 def system_program Solace::Constants::SYSTEM_PROGRAM_ID end |
#transaction ⇒ String
Extracts the settings transaction PDA address from the params
48 49 50 |
# File 'lib/solace/squads_smart_accounts/composers/execute_settings_transaction_composer.rb', line 48 def transaction params[:transaction].to_s end |