Skip to main content

squads_multisig_program/instructions/
transaction_buffer_close.rs

1use anchor_lang::prelude::*;
2
3use crate::errors::*;
4use crate::state::*;
5
6#[derive(Accounts)]
7pub struct TransactionBufferClose<'info> {
8    #[account(
9        seeds = [SEED_PREFIX, SEED_MULTISIG, multisig.create_key.as_ref()],
10        bump = multisig.bump,
11    )]
12    pub multisig: Account<'info, Multisig>,
13
14    #[account(
15        mut,
16        // Rent gets returned to the creator
17        close = creator,
18        // Only the creator can close the buffer
19        constraint = transaction_buffer.creator == creator.key() @ MultisigError::Unauthorized,
20        // Account can be closed anytime by the creator, regardless of the
21        // current multisig transaction index
22        seeds = [
23            SEED_PREFIX,
24            multisig.key().as_ref(),
25            SEED_TRANSACTION_BUFFER,
26            creator.key().as_ref(),
27            &transaction_buffer.buffer_index.to_le_bytes()
28        ],
29        bump
30    )]
31    pub transaction_buffer: Account<'info, TransactionBuffer>,
32
33    /// The member of the multisig that created the TransactionBuffer.
34    pub creator: Signer<'info>,
35}
36
37impl TransactionBufferClose<'_> {
38    fn validate(&self) -> Result<()> {
39        Ok(())
40    }
41
42    /// Close a transaction buffer account.
43    #[access_control(ctx.accounts.validate())]
44    pub fn transaction_buffer_close(ctx: Context<Self>) -> Result<()> {
45        Ok(())
46    }
47}