Class: Solace::Composers::SquadsSmartAccountsExecuteSettingsTransactionSyncComposer
- Inherits:
-
Base
- Object
- Base
- Solace::Composers::SquadsSmartAccountsExecuteSettingsTransactionSyncComposer
- Defined in:
- lib/solace/squads_smart_accounts/composers/execute_settings_transaction_sync_composer.rb
Overview
Composes an ‘executeSettingsTransactionSync` instruction for the Squads Smart Account program.
Synchronously applies a batch of SettingsActions to an autonomous smart account. The outer transaction must be co-signed by enough smart account signers to reach the settings threshold — controlled accounts are rejected by the program (use the *AsAuthority composers instead).
Required params:
:settings [String] Base58 address of the settings account.
:signers [Array<#to_s, Keypair>] Co-signers proving threshold consensus.
:actions [Array<SquadsSmartAccounts::SettingsAction>] Actions applied atomically.
:rent_payer [#to_s, Keypair] Pays for settings reallocation (must sign).
Optional params:
:spending_limit_accounts [Array<#to_s>] SpendingLimit PDAs initialized or
closed by AddSpendingLimit/RemoveSpendingLimit
actions, in action order (default: []).
:memo [String] Indexing memo (default: nil).
Instance Method Summary collapse
-
#actions ⇒ Array<SquadsSmartAccounts::SettingsAction>
Extracts the settings actions from the params.
-
#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.
-
#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.
-
#signers ⇒ Array<String>
Extracts the co-signer addresses 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.
Instance Method Details
#actions ⇒ Array<SquadsSmartAccounts::SettingsAction>
Extracts the settings actions from the params
42 43 44 |
# File 'lib/solace/squads_smart_accounts/composers/execute_settings_transaction_sync_composer.rb', line 42 def actions params[:actions] end |
#build_instruction(context) ⇒ Solace::Instruction
Builds the instruction with resolved account indices.
99 100 101 102 103 104 105 106 107 108 109 110 111 |
# File 'lib/solace/squads_smart_accounts/composers/execute_settings_transaction_sync_composer.rb', line 99 def build_instruction(context) SquadsSmartAccounts::Instructions::ExecuteSettingsTransactionSyncInstruction.build( num_signers: signers.length, actions:, memo:, settings_index: context.index_of(settings), rent_payer_index: context.index_of(rent_payer), system_program_index: context.index_of(system_program), program_index: context.index_of(program_id), signer_indices: signers.map { |signer| context.index_of(signer) }, spending_limit_indices: spending_limit_accounts.map { |account| context.index_of(account) } ) end |
#memo ⇒ String?
Extracts the memo from the params
63 64 65 |
# File 'lib/solace/squads_smart_accounts/composers/execute_settings_transaction_sync_composer.rb', line 63 def memo params[:memo] end |
#program_id ⇒ String
Returns the Squads Smart Account program id from the constants
70 71 72 |
# File 'lib/solace/squads_smart_accounts/composers/execute_settings_transaction_sync_composer.rb', line 70 def program_id SquadsSmartAccounts::PROGRAM_ID end |
#rent_payer ⇒ String
Extracts the rent payer address from the params
49 50 51 |
# File 'lib/solace/squads_smart_accounts/composers/execute_settings_transaction_sync_composer.rb', line 49 def rent_payer params[:rent_payer].to_s end |
#settings ⇒ String
Extracts the settings address from the params
28 29 30 |
# File 'lib/solace/squads_smart_accounts/composers/execute_settings_transaction_sync_composer.rb', line 28 def settings params[:settings].to_s end |
#setup_accounts ⇒ Object
Declares all accounts required by this instruction.
82 83 84 85 86 87 88 89 90 91 92 93 |
# File 'lib/solace/squads_smart_accounts/composers/execute_settings_transaction_sync_composer.rb', line 82 def setup_accounts account_context.add_writable_nonsigner(settings) account_context.add_writable_signer(rent_payer) account_context.add_readonly_nonsigner(system_program) account_context.add_readonly_nonsigner(program_id) # Co-signers proving threshold consensus (remaining accounts) signers.each { |signer| account_context.add_readonly_signer(signer) } # SpendingLimit PDAs initialized/closed by the actions follow the signers spending_limit_accounts.each { |account| account_context.add_writable_nonsigner(account) } end |
#signers ⇒ Array<String>
Extracts the co-signer addresses from the params
35 36 37 |
# File 'lib/solace/squads_smart_accounts/composers/execute_settings_transaction_sync_composer.rb', line 35 def signers params[:signers].map(&:to_s) end |
#spending_limit_accounts ⇒ Array<String>
Extracts the spending limit PDAs touched by the actions from the params
56 57 58 |
# File 'lib/solace/squads_smart_accounts/composers/execute_settings_transaction_sync_composer.rb', line 56 def spending_limit_accounts (params[:spending_limit_accounts] || []).map(&:to_s) end |
#system_program ⇒ String
Returns the system program id from the constants
77 78 79 |
# File 'lib/solace/squads_smart_accounts/composers/execute_settings_transaction_sync_composer.rb', line 77 def system_program Solace::Constants::SYSTEM_PROGRAM_ID end |