Class: Solace::SquadsSmartAccounts::Instructions::AddSpendingLimitAsAuthorityInstruction
- Inherits:
-
Object
- Object
- Solace::SquadsSmartAccounts::Instructions::AddSpendingLimitAsAuthorityInstruction
- Defined in:
- lib/solace/squads_smart_accounts/instructions/add_spending_limit_as_authority_instruction.rb
Overview
Encodes the ‘addSpendingLimitAsAuthority` instruction for the Squads Smart Account program.
Creates a SpendingLimit PDA granting designated signers a pre-authorized allowance from a vault. Only callable by the account’s settings authority — no consensus involved.
IDL accounts (in order):
0. settings — readonly, non-signer
1. settingsAuthority — readonly, signer
2. spendingLimit — writable, non-signer (PDA to be created)
3. rentPayer — writable, signer (funds the new account's rent)
4. systemProgram — readonly, non-signer
5. program — readonly, non-signer
Constant Summary collapse
- DISCRIMINATOR =
8-byte Anchor discriminator: SHA256(“global:add_spending_limit_as_authority”)
[169, 189, 84, 54, 30, 244, 223, 212].freeze
Class Method Summary collapse
-
.build(seed:, account_index:, mint:, amount:, period:, signers:, destinations:, expiration:, memo:, settings_index:, settings_authority_index:, spending_limit_index:, rent_payer_index:, system_program_index:, program_index:) ⇒ Solace::Instruction
Builds a Instruction for addSpendingLimitAsAuthority.
-
.data(seed:, account_index:, mint:, amount:, period:, signers:, destinations:, expiration:, memo:) ⇒ Array<Integer>
Encodes the ‘AddSpendingLimitArgs` struct in Borsh format.
Class Method Details
.build(seed:, account_index:, mint:, amount:, period:, signers:, destinations:, expiration:, memo:, settings_index:, settings_authority_index:, spending_limit_index:, rent_payer_index:, system_program_index:, program_index:) ⇒ Solace::Instruction
Builds a Instruction for addSpendingLimitAsAuthority.
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 77 78 79 80 81 82 |
# File 'lib/solace/squads_smart_accounts/instructions/add_spending_limit_as_authority_instruction.rb', line 42 def self.build( seed:, account_index:, mint:, amount:, period:, signers:, destinations:, expiration:, memo:, settings_index:, settings_authority_index:, spending_limit_index:, rent_payer_index:, system_program_index:, program_index: ) Solace::Instruction.new.tap do |ix| ix.program_index = program_index ix.accounts = [ settings_index, , spending_limit_index, rent_payer_index, system_program_index, program_index ] ix.data = data( seed:, account_index:, mint:, amount:, period:, signers:, destinations:, expiration:, memo: ) end end |
.data(seed:, account_index:, mint:, amount:, period:, signers:, destinations:, expiration:, memo:) ⇒ Array<Integer>
Encodes the ‘AddSpendingLimitArgs` struct in Borsh format.
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 |
# File 'lib/solace/squads_smart_accounts/instructions/add_spending_limit_as_authority_instruction.rb', line 87 def self.data( seed:, account_index:, mint:, amount:, period:, signers:, destinations:, expiration:, memo: ) DISCRIMINATOR + Solace::Utils::Codecs.encode_pubkey(seed) + [account_index] + Solace::Utils::Codecs.encode_pubkey(mint) + Solace::Utils::Codecs.encode_le_u64(amount).bytes + [period] + Solace::Utils::Codecs.encode_vec_pubkeys(signers) + Solace::Utils::Codecs.encode_vec_pubkeys(destinations) + Solace::Utils::Codecs.encode_le_i64(expiration).bytes + Solace::Utils::Codecs.encode_option_string(memo) end |