Class: Solace::SquadsSmartAccounts::Instructions::CreateSmartAccountInstruction
- Inherits:
-
Object
- Object
- Solace::SquadsSmartAccounts::Instructions::CreateSmartAccountInstruction
- Defined in:
- lib/solace/squads_smart_accounts/instructions/create_smart_account_instruction.rb
Overview
Encodes the ‘createSmartAccount` instruction for the Squads Smart Account program.
Creates a new smart account (multisig) on-chain. The resulting settings account is a PDA derived from the creator’s public key.
IDL accounts (in order):
0. programConfig — writable, non-signer
1. treasury — writable, non-signer
2. creator — writable, signer
3. systemProgram — readonly, non-signer
4. program — readonly, non-signer
5+. settings — writable, non-signer (one or more candidate settings
PDAs as remaining accounts; the program initializes
the one matching the freshly incremented counter)
Constant Summary collapse
- DISCRIMINATOR =
8-byte Anchor discriminator: SHA256(“global:create_smart_account”)
[197, 102, 253, 231, 77, 84, 50, 17].freeze
Class Method Summary collapse
-
.build(settings_authority:, threshold:, signers:, time_lock:, rent_collector:, memo:, program_config_index:, treasury_index:, creator_index:, system_program_index:, program_index:, settings_index:) ⇒ Solace::Instruction
Builds a Instruction for createSmartAccount.
-
.data(settings_authority:, threshold:, signers:, time_lock:, rent_collector:, memo:) ⇒ Array<Integer>
Encodes the ‘CreateSmartAccountArgs` struct in Borsh format.
Class Method Details
.build(settings_authority:, threshold:, signers:, time_lock:, rent_collector:, memo:, program_config_index:, treasury_index:, creator_index:, system_program_index:, program_index:, settings_index:) ⇒ Solace::Instruction
Builds a Instruction for createSmartAccount.
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/solace/squads_smart_accounts/instructions/create_smart_account_instruction.rb', line 42 def self.build( settings_authority:, threshold:, signers:, time_lock:, rent_collector:, memo:, program_config_index:, treasury_index:, creator_index:, system_program_index:, program_index:, settings_index: ) Solace::Instruction.new.tap do |ix| ix.program_index = program_index ix.accounts = [ program_config_index, treasury_index, creator_index, system_program_index, program_index, *Array(settings_index) ] ix.data = data( settings_authority:, threshold:, signers:, time_lock:, rent_collector:, memo: ) end end |
.data(settings_authority:, threshold:, signers:, time_lock:, rent_collector:, memo:) ⇒ Array<Integer>
Encodes the ‘CreateSmartAccountArgs` struct in Borsh format.
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 |
# File 'lib/solace/squads_smart_accounts/instructions/create_smart_account_instruction.rb', line 81 def self.data( settings_authority:, threshold:, signers:, time_lock:, rent_collector:, memo: ) DISCRIMINATOR + Solace::Utils::Codecs.encode_option_pubkey() + Solace::Utils::Codecs.encode_le_u16(threshold).bytes + Solace::Utils::Codecs.encode_smart_account_signers(signers) + Solace::Utils::Codecs.encode_le_u32(time_lock).bytes + Solace::Utils::Codecs.encode_option_pubkey(rent_collector) + Solace::Utils::Codecs.encode_option_string(memo) end |