squads_multisig_program/instructions/
multisig_remove_spending_limit.rs

1use anchor_lang::prelude::*;
2
3use crate::errors::*;
4use crate::state::*;
5
6#[derive(AnchorSerialize, AnchorDeserialize)]
7pub struct MultisigRemoveSpendingLimitArgs {
8    /// Memo is used for indexing only.
9    pub memo: Option<String>,
10}
11
12#[derive(Accounts)]
13pub struct MultisigRemoveSpendingLimit<'info> {
14    #[account(
15        seeds = [SEED_PREFIX, SEED_MULTISIG, multisig.create_key.as_ref()],
16        bump = multisig.bump,
17    )]
18    multisig: Account<'info, Multisig>,
19
20    /// Multisig `config_authority` that must authorize the configuration change.
21    pub config_authority: Signer<'info>,
22
23    #[account(mut, close = rent_collector)]
24    pub spending_limit: Account<'info, SpendingLimit>,
25
26    /// This is usually the same as `config_authority`, but can be a different account if needed.
27    /// CHECK: can be any account.
28    #[account(mut)]
29    pub rent_collector: AccountInfo<'info>,
30}
31
32impl MultisigRemoveSpendingLimit<'_> {
33    fn validate(&self) -> Result<()> {
34        // config_authority
35        require_keys_eq!(
36            self.config_authority.key(),
37            self.multisig.config_authority,
38            MultisigError::Unauthorized
39        );
40
41        // `spending_limit`
42        require_keys_eq!(
43            self.spending_limit.multisig,
44            self.multisig.key(),
45            MultisigError::InvalidAccount
46        );
47
48        Ok(())
49    }
50
51    /// Remove the spending limit from the controlled multisig.
52    /// NOTE: This instruction must be called only by the `config_authority` if one is set (Controlled Multisig).
53    ///       Uncontrolled Mustisigs should use `config_transaction_create` instead.
54    #[access_control(ctx.accounts.validate())]
55    pub fn multisig_remove_spending_limit(
56        ctx: Context<Self>,
57        _args: MultisigRemoveSpendingLimitArgs,
58    ) -> Result<()> {
59        Ok(())
60    }
61}