Class: Solace::SquadsSmartAccounts::Instructions::UseSpendingLimitInstruction
- Inherits:
-
Object
- Object
- Solace::SquadsSmartAccounts::Instructions::UseSpendingLimitInstruction
- Defined in:
- lib/solace/squads_smart_accounts/instructions/use_spending_limit_instruction.rb
Overview
Encodes the ‘useSpendingLimit` instruction for the Squads Smart Account program.
Transfers funds from a vault to a destination within a pre-authorized spending limit — single signature from an allowed signer, no consensus.
IDL accounts (in order):
0. settings — readonly, non-signer
1. signer — readonly, signer (must be allowed by the limit)
2. spendingLimit — writable, non-signer
3. smartAccount — writable, non-signer (vault to transfer from)
4. destination — writable, non-signer
5. systemProgram — readonly, optional (required for SOL limits)
6. mint — readonly, optional (SPL limits only)
7. smartAccountTokenAccount — writable, optional (SPL limits only)
8. destinationTokenAccount — writable, optional (SPL limits only)
9. tokenProgram — readonly, optional (SPL limits only)
10. program — readonly, non-signer
Absent optional accounts are signaled by passing the Squads program ID in their slot (Anchor’s optional-account convention). For SOL limits the four SPL slots must all be the program ID.
Constant Summary collapse
- DISCRIMINATOR =
8-byte Anchor discriminator: SHA256(“global:use_spending_limit”)
[41, 179, 70, 5, 194, 147, 239, 158].freeze
Class Method Summary collapse
-
.build(amount:, decimals:, memo:, settings_index:, signer_index:, spending_limit_index:, smart_account_index:, destination_index:, system_program_index:, mint_index:, smart_account_token_account_index:, destination_token_account_index:, token_program_index:, program_index:) ⇒ Solace::Instruction
Builds a Instruction for useSpendingLimit.
-
.data(amount:, decimals:, memo:) ⇒ Array<Integer>
Encodes the ‘UseSpendingLimitArgs` struct in Borsh format.
Class Method Details
.build(amount:, decimals:, memo:, settings_index:, signer_index:, spending_limit_index:, smart_account_index:, destination_index:, system_program_index:, mint_index:, smart_account_token_account_index:, destination_token_account_index:, token_program_index:, program_index:) ⇒ Solace::Instruction
Builds a Instruction for useSpendingLimit.
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 77 78 79 80 81 82 |
# File 'lib/solace/squads_smart_accounts/instructions/use_spending_limit_instruction.rb', line 48 def self.build( amount:, decimals:, memo:, settings_index:, signer_index:, spending_limit_index:, smart_account_index:, destination_index:, system_program_index:, mint_index:, smart_account_token_account_index:, destination_token_account_index:, token_program_index:, program_index: ) Solace::Instruction.new.tap do |ix| ix.program_index = program_index ix.accounts = [ settings_index, signer_index, spending_limit_index, smart_account_index, destination_index, system_program_index, mint_index, smart_account_token_account_index, destination_token_account_index, token_program_index, program_index ] ix.data = data(amount:, decimals:, memo:) end end |
.data(amount:, decimals:, memo:) ⇒ Array<Integer>
Encodes the ‘UseSpendingLimitArgs` struct in Borsh format.
87 88 89 90 91 92 |
# File 'lib/solace/squads_smart_accounts/instructions/use_spending_limit_instruction.rb', line 87 def self.data(amount:, decimals:, memo:) DISCRIMINATOR + Solace::Utils::Codecs.encode_le_u64(amount).bytes + [decimals] + Solace::Utils::Codecs.encode_option_string(memo) end |