Class: Solace::SquadsSmartAccounts::Instructions::CreateTransactionInstruction
- Inherits:
-
Object
- Object
- Solace::SquadsSmartAccounts::Instructions::CreateTransactionInstruction
- Defined in:
- lib/solace/squads_smart_accounts/instructions/create_transaction_instruction.rb
Overview
Encodes the ‘createTransaction` instruction for the Squads Smart Account program.
Stores a pending vault transaction (a compiled TransactionMessage) on-chain. The transaction does not execute here — it awaits a proposal and approvals.
IDL accounts (in order):
0. settings — writable, non-signer
1. transaction — writable, non-signer (PDA to be created)
2. creator — readonly, signer
3. rentPayer — writable, signer (funds the new account's rent)
4. systemProgram — readonly, non-signer
5. program — readonly, non-signer (the Squads program itself)
NOTE: the bundled IDL is stale for this instruction. The deployed program is the newer version that (a) models the args as a ‘TransactionPayload` enum variant and (b) requires the Squads `program` as a trailing account. Both are reflected here.
Constant Summary collapse
- DISCRIMINATOR =
8-byte Anchor discriminator: SHA256(“global:create_transaction”)
[227, 193, 53, 239, 55, 126, 112, 105].freeze
Class Method Summary collapse
-
.build(account_index:, ephemeral_signers:, transaction_message:, memo:, settings_index:, transaction_index:, creator_index:, rent_payer_index:, system_program_index:, program_index:) ⇒ Solace::Instruction
Builds a Instruction for createTransaction.
-
.data(account_index:, ephemeral_signers:, transaction_message:, memo:) ⇒ Array<Integer>
Encodes the ‘CreateTransactionArgs::TransactionPayload` variant in Borsh.
Class Method Details
.build(account_index:, ephemeral_signers:, transaction_message:, memo:, settings_index:, transaction_index:, creator_index:, rent_payer_index:, system_program_index:, program_index:) ⇒ Solace::Instruction
Builds a Instruction for createTransaction.
40 41 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 |
# File 'lib/solace/squads_smart_accounts/instructions/create_transaction_instruction.rb', line 40 def self.build( account_index:, ephemeral_signers:, transaction_message:, memo:, settings_index:, transaction_index:, creator_index:, rent_payer_index:, system_program_index:, program_index: ) Solace::Instruction.new.tap do |ix| ix.program_index = program_index ix.accounts = [ settings_index, transaction_index, creator_index, rent_payer_index, system_program_index, program_index ] ix.data = data( account_index:, ephemeral_signers:, transaction_message:, memo: ) end end |
.data(account_index:, ephemeral_signers:, transaction_message:, memo:) ⇒ Array<Integer>
Encodes the ‘CreateTransactionArgs::TransactionPayload` variant in Borsh.
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
# File 'lib/solace/squads_smart_accounts/instructions/create_transaction_instruction.rb', line 75 def self.data( account_index:, ephemeral_signers:, transaction_message:, memo: ) DISCRIMINATOR + # Borsh enum variant index for `CreateTransactionArgs::TransactionPayload`. # The deployed program models the args as an enum (TransactionPayload | # PolicyPayload) even though the bundled IDL still describes the legacy # flat struct — so the serialized data leads with this variant byte. [0] + [account_index] + [ephemeral_signers] + Solace::Utils::Codecs.encode_bytes() + Solace::Utils::Codecs.encode_option_string(memo) end |