Class: Solace::Composers::SquadsSmartAccountsExecuteTransactionComposer
- Inherits:
-
Base
- Object
- Base
- Solace::Composers::SquadsSmartAccountsExecuteTransactionComposer
- Defined in:
- lib/solace/squads_smart_accounts/composers/execute_transaction_composer.rb
Overview
Composes an ‘executeTransaction` instruction for the Squads Smart Account program.
Executes the inner instructions of an Approved proposal’s stored Transaction. The stored message’s account metas are appended as remaining accounts in their canonical order. The vault (smart account) PDA is the message’s signer but cannot sign the outer transaction — the program signs it via CPI — so it is forced to a non-signer here, mirroring SquadsSmartAccountsExecuteTransactionSyncComposer.
Required params:
:settings [#to_s] Base58 address of the settings account.
:proposal [#to_s] The Proposal PDA (must be Approved).
:transaction [#to_s] The Transaction PDA to execute.
:signer [#to_s, Keypair] The executing signer (must sign; needs Execute permission).
:smart_account [#to_s] The vault PDA the message spends from (forced non-signer).
:account_metas [Array<Hash>] The stored message's account metas, in order —
each { pubkey: #to_s, signer: Boolean, writable: Boolean } (Transaction#account_metas).
Instance Method Summary collapse
-
#account_metas ⇒ Array<Hash>
The ordered stored-message account metas (from Transaction#account_metas), whose pubkeys are already base58 strings and flags already booleans.
-
#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: the fixed accounts followed by each stored-message account with its flags.
-
#signer ⇒ String
Extracts the executing signer address from the params.
-
#smart_account ⇒ String
Extracts the vault (smart account) address from the params.
-
#transaction ⇒ String
Extracts the transaction PDA address from the params.
Instance Method Details
#account_metas ⇒ Array<Hash>
The ordered stored-message account metas (from Transaction#account_metas), whose pubkeys are already base58 strings and flags already booleans.
62 63 64 |
# File 'lib/solace/squads_smart_accounts/composers/execute_transaction_composer.rb', line 62 def params[:account_metas] end |
#build_instruction(context) ⇒ Solace::Instruction
Builds the instruction with resolved account indices. The remaining account indices preserve the stored message’s account_keys order.
90 91 92 93 94 95 96 97 98 99 |
# File 'lib/solace/squads_smart_accounts/composers/execute_transaction_composer.rb', line 90 def build_instruction(context) SquadsSmartAccounts::Instructions::ExecuteTransactionInstruction.build( settings_index: context.index_of(settings), proposal_index: context.index_of(proposal), transaction_index: context.index_of(transaction), signer_index: context.index_of(signer), program_index: context.index_of(program_id), remaining_account_indices: .map { || context.index_of([:pubkey]) } ) 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_transaction_composer.rb', line 69 def program_id SquadsSmartAccounts::PROGRAM_ID end |
#proposal ⇒ String
Extracts the proposal PDA address from the params
33 34 35 |
# File 'lib/solace/squads_smart_accounts/composers/execute_transaction_composer.rb', line 33 def proposal params[:proposal].to_s end |
#settings ⇒ String
Extracts the settings address from the params
26 27 28 |
# File 'lib/solace/squads_smart_accounts/composers/execute_transaction_composer.rb', line 26 def settings params[:settings].to_s end |
#setup_accounts ⇒ Object
Declares all accounts required by this instruction: the fixed accounts followed by each stored-message account with its flags.
75 76 77 78 79 80 81 82 83 |
# File 'lib/solace/squads_smart_accounts/composers/execute_transaction_composer.rb', line 75 def setup_accounts account_context.add_writable_nonsigner(settings) account_context.add_writable_nonsigner(proposal) account_context.add_readonly_nonsigner(transaction) account_context.add_readonly_signer(signer) account_context.add_readonly_nonsigner(program_id) .each { || add_remaining_account() } end |
#signer ⇒ String
Extracts the executing signer address from the params
47 48 49 |
# File 'lib/solace/squads_smart_accounts/composers/execute_transaction_composer.rb', line 47 def signer params[:signer].to_s end |
#smart_account ⇒ String
Extracts the vault (smart account) address from the params
54 55 56 |
# File 'lib/solace/squads_smart_accounts/composers/execute_transaction_composer.rb', line 54 def smart_account params[:smart_account].to_s end |
#transaction ⇒ String
Extracts the transaction PDA address from the params
40 41 42 |
# File 'lib/solace/squads_smart_accounts/composers/execute_transaction_composer.rb', line 40 def transaction params[:transaction].to_s end |