Class: Solace::Composers::SquadsSmartAccountsCreateSmartAccountComposer
- Inherits:
-
Base
- Object
- Base
- Solace::Composers::SquadsSmartAccountsCreateSmartAccountComposer
- Defined in:
- lib/solace/squads_smart_accounts/composers/create_smart_account_composer.rb
Overview
Composes a ‘createSmartAccount` instruction for the Squads Smart Account program.
Required params:
:creator [String] Base58 pubkey of the account creating the smart account.
:treasury [String] Base58 pubkey of the treasury (from ProgramConfig).
:settings [String] Base58 pubkey of the settings PDA to be created —
derive via Programs::SquadsSmartAccount.get_settings_address.
:threshold [Integer] Number of approvals required to execute a transaction.
:signers [Array<SquadsSmartAccounts::SmartAccountSigner>] Signers on the smart account.
:time_lock [Integer] Seconds between proposal and execution (0 to disable).
Optional params:
:settings_authority [String] Pubkey of the reconfiguration authority (default: nil).
:rent_collector [String] Pubkey for reclaiming rent on closed accounts (default: nil).
:memo [String] Indexing memo (default: nil).
Instance Method Summary collapse
-
#build_instruction(context) ⇒ Solace::Instruction
Builds the instruction with resolved account indices.
-
#config ⇒ String
Returns the program config address from the constants.
-
#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_collector ⇒ String?
Extracts the rent collector address from the params.
-
#settings ⇒ String
Extracts the settings address from the params.
-
#settings_authority ⇒ String?
Extracts the settings authority address from the params.
-
#setup_accounts ⇒ Object
Declares all accounts required by this instruction.
-
#signers ⇒ Array<SquadsSmartAccounts::SmartAccountSigner>
Extracts the signers from the params.
-
#system_program ⇒ String
Returns the system program id from the constants.
-
#threshold ⇒ Integer
Extracts the threshold from the params.
-
#time_lock ⇒ Integer
Extracts the time lock from the params.
-
#treasury ⇒ String
Extracts the treasury address from the params.
Instance Method Details
#build_instruction(context) ⇒ Solace::Instruction
Builds the instruction with resolved account indices.
124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 |
# File 'lib/solace/squads_smart_accounts/composers/create_smart_account_composer.rb', line 124 def build_instruction(context) SquadsSmartAccounts::Instructions::CreateSmartAccountInstruction.build( settings_authority:, threshold:, signers:, time_lock:, rent_collector:, memo:, program_config_index: context.index_of(config), treasury_index: context.index_of(treasury), creator_index: context.index_of(creator), system_program_index: context.index_of(system_program), program_index: context.index_of(program_id), settings_index: context.index_of(settings) ) end |
#config ⇒ String
Returns the program config address from the constants
45 46 47 |
# File 'lib/solace/squads_smart_accounts/composers/create_smart_account_composer.rb', line 45 def config SquadsSmartAccounts::PROGRAM_CONFIG_ADDRESS end |
#creator ⇒ String
Extracts the creator address from the params
31 32 33 |
# File 'lib/solace/squads_smart_accounts/composers/create_smart_account_composer.rb', line 31 def creator params[:creator].to_s end |
#memo ⇒ String?
Extracts the memo from the params
101 102 103 |
# File 'lib/solace/squads_smart_accounts/composers/create_smart_account_composer.rb', line 101 def memo params[:memo] end |
#program_id ⇒ String
Returns the Squads Smart Account program id from the constants
52 53 54 |
# File 'lib/solace/squads_smart_accounts/composers/create_smart_account_composer.rb', line 52 def program_id SquadsSmartAccounts::PROGRAM_ID end |
#rent_collector ⇒ String?
Extracts the rent collector address from the params
73 74 75 |
# File 'lib/solace/squads_smart_accounts/composers/create_smart_account_composer.rb', line 73 def rent_collector params[:rent_collector]&.to_s end |
#settings ⇒ String
Extracts the settings address from the params
38 39 40 |
# File 'lib/solace/squads_smart_accounts/composers/create_smart_account_composer.rb', line 38 def settings params[:settings].to_s end |
#settings_authority ⇒ String?
Extracts the settings authority address from the params
66 67 68 |
# File 'lib/solace/squads_smart_accounts/composers/create_smart_account_composer.rb', line 66 def params[:settings_authority]&.to_s end |
#setup_accounts ⇒ Object
Declares all accounts required by this instruction.
106 107 108 109 110 111 112 113 114 115 116 117 118 |
# File 'lib/solace/squads_smart_accounts/composers/create_smart_account_composer.rb', line 106 def setup_accounts # Required read-only accounts account_context.add_readonly_nonsigner(system_program) account_context.add_readonly_nonsigner(program_id) # Writable accounts account_context.add_writable_nonsigner(config) account_context.add_writable_nonsigner(treasury) account_context.add_writable_nonsigner(settings) # Writable signers account_context.add_writable_signer(creator) end |
#signers ⇒ Array<SquadsSmartAccounts::SmartAccountSigner>
Extracts the signers from the params
94 95 96 |
# File 'lib/solace/squads_smart_accounts/composers/create_smart_account_composer.rb', line 94 def signers params[:signers] end |
#system_program ⇒ String
Returns the system program id from the constants
59 60 61 |
# File 'lib/solace/squads_smart_accounts/composers/create_smart_account_composer.rb', line 59 def system_program Solace::Constants::SYSTEM_PROGRAM_ID end |
#threshold ⇒ Integer
Extracts the threshold from the params
80 81 82 |
# File 'lib/solace/squads_smart_accounts/composers/create_smart_account_composer.rb', line 80 def threshold params[:threshold] end |
#time_lock ⇒ Integer
Extracts the time lock from the params
87 88 89 |
# File 'lib/solace/squads_smart_accounts/composers/create_smart_account_composer.rb', line 87 def time_lock params[:time_lock] end |
#treasury ⇒ String
Extracts the treasury address from the params
24 25 26 |
# File 'lib/solace/squads_smart_accounts/composers/create_smart_account_composer.rb', line 24 def treasury params[:treasury].to_s end |