Class: Solace::Composers::SquadsSmartAccountsCreateSettingsTransactionComposer
- Inherits:
-
Base
- Object
- Base
- Solace::Composers::SquadsSmartAccountsCreateSettingsTransactionComposer
- Defined in:
- lib/solace/squads_smart_accounts/composers/create_settings_transaction_composer.rb
Overview
Composes a ‘createSettingsTransaction` instruction for the Squads Smart Account program.
Stores a batch of SettingsActions as a SettingsTransaction for later approval and execution. Autonomous accounts only.
Required params:
:settings [#to_s] Base58 address of the settings account.
:transaction [#to_s] The SettingsTransaction PDA to create.
:creator [#to_s, Keypair] A signer creating the transaction (must sign).
:rent_payer [#to_s, Keypair] Funds the new account's rent (must sign).
:actions [Array<SquadsSmartAccounts::SettingsAction>] Actions to store.
Optional params:
: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.
-
#creator ⇒ String
Extracts the creator address from the params.
-
#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.
-
#system_program ⇒ String
Returns the system program id from the constants.
-
#transaction ⇒ String
Extracts the transaction PDA address from the params.
Instance Method Details
#actions ⇒ Array<SquadsSmartAccounts::SettingsAction>
Extracts the settings actions from the params
52 53 54 |
# File 'lib/solace/squads_smart_accounts/composers/create_settings_transaction_composer.rb', line 52 def actions params[:actions] end |
#build_instruction(context) ⇒ Solace::Instruction
Builds the instruction with resolved account indices.
91 92 93 94 95 96 97 98 99 100 101 102 |
# File 'lib/solace/squads_smart_accounts/composers/create_settings_transaction_composer.rb', line 91 def build_instruction(context) SquadsSmartAccounts::Instructions::CreateSettingsTransactionInstruction.build( actions:, memo:, settings_index: context.index_of(settings), transaction_index: context.index_of(transaction), 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
38 39 40 |
# File 'lib/solace/squads_smart_accounts/composers/create_settings_transaction_composer.rb', line 38 def creator params[:creator].to_s end |
#memo ⇒ String?
Extracts the memo from the params
59 60 61 |
# File 'lib/solace/squads_smart_accounts/composers/create_settings_transaction_composer.rb', line 59 def memo params[:memo] end |
#program_id ⇒ String
Returns the Squads Smart Account program id from the constants
66 67 68 |
# File 'lib/solace/squads_smart_accounts/composers/create_settings_transaction_composer.rb', line 66 def program_id SquadsSmartAccounts::PROGRAM_ID end |
#rent_payer ⇒ String
Extracts the rent payer address from the params
45 46 47 |
# File 'lib/solace/squads_smart_accounts/composers/create_settings_transaction_composer.rb', line 45 def rent_payer params[:rent_payer].to_s end |
#settings ⇒ String
Extracts the settings address from the params
24 25 26 |
# File 'lib/solace/squads_smart_accounts/composers/create_settings_transaction_composer.rb', line 24 def settings params[:settings].to_s end |
#setup_accounts ⇒ Object
Declares all accounts required by this instruction.
78 79 80 81 82 83 84 85 |
# File 'lib/solace/squads_smart_accounts/composers/create_settings_transaction_composer.rb', line 78 def setup_accounts account_context.add_writable_nonsigner(settings) account_context.add_writable_nonsigner(transaction) 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
73 74 75 |
# File 'lib/solace/squads_smart_accounts/composers/create_settings_transaction_composer.rb', line 73 def system_program Solace::Constants::SYSTEM_PROGRAM_ID end |
#transaction ⇒ String
Extracts the transaction PDA address from the params
31 32 33 |
# File 'lib/solace/squads_smart_accounts/composers/create_settings_transaction_composer.rb', line 31 def transaction params[:transaction].to_s end |