carbon_token_2022_decoder/instructions/
pause.rs

1//! This code was AUTOGENERATED using the Codama library.
2//! Please DO NOT EDIT THIS FILE, instead use visitors
3//! to add features, then rerun Codama to update it.
4//!
5//! <https://github.com/codama-idl/codama>
6//!
7use carbon_core::account_utils::next_account;
8use carbon_core::borsh;
9use carbon_core::deserialize::ArrangeAccounts;
10use carbon_core::deserialize::CarbonDeserialize;
11use carbon_core::CarbonDeserialize;
12
13/// Pause the mint.
14///
15/// Fails if the mint is not pausable.
16#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
17#[derive(Debug, Clone, borsh::BorshSerialize, CarbonDeserialize, PartialEq)]
18pub struct Pause {
19    pub pausable_discriminator: u8,
20}
21
22#[derive(Debug, Clone, PartialEq)]
23#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
24pub struct PauseInstructionAccounts {
25    pub mint: solana_pubkey::Pubkey,
26    pub authority: solana_pubkey::Pubkey,
27    pub remaining: Vec<solana_instruction::AccountMeta>,
28}
29
30impl Pause {
31    pub fn decode(data: &[u8]) -> Option<Self> {
32        if data.len() < 2 {
33            return None;
34        }
35        let discriminator = &data[0..1];
36        if discriminator != [44] {
37            return None;
38        }
39        let pausable_discriminator = data[1];
40        if pausable_discriminator != 1 {
41            return None;
42        }
43
44        let data_slice = data;
45
46        let data_slice = &data_slice[1..];
47
48        Self::deserialize(data_slice)
49    }
50}
51
52impl ArrangeAccounts for Pause {
53    type ArrangedAccounts = PauseInstructionAccounts;
54
55    fn arrange_accounts(
56        accounts: &[solana_instruction::AccountMeta],
57    ) -> Option<Self::ArrangedAccounts> {
58        let mut iter = accounts.iter();
59
60        let mint = next_account(&mut iter)?;
61        let authority = next_account(&mut iter)?;
62
63        let remaining = iter.as_slice();
64
65        Some(PauseInstructionAccounts {
66            mint,
67            authority,
68            remaining: remaining.to_vec(),
69        })
70    }
71}