carbon_token_2022_decoder/instructions/
initialize_multisig.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/// Initializes a multisignature account with N provided signers.
14///
15/// Multisignature accounts can used in place of any single owner/delegate
16/// accounts in any token instruction that require an owner/delegate to be
17/// present. The variant field represents the number of signers (M)
18/// required to validate this multisignature account.
19///
20/// The `InitializeMultisig` instruction requires no signers and MUST be
21/// included within the same Transaction as the system program's
22/// `CreateAccount` instruction that creates the account being initialized.
23/// Otherwise another party can acquire ownership of the uninitialized account.
24#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
25#[derive(Debug, Clone, borsh::BorshSerialize, CarbonDeserialize, PartialEq)]
26pub struct InitializeMultisig {
27    /// The number of signers (M) required to validate this multisignature account.
28    pub m: u8,
29}
30
31#[derive(Debug, Clone, PartialEq)]
32#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
33pub struct InitializeMultisigInstructionAccounts {
34    pub multisig: solana_pubkey::Pubkey,
35    pub rent: solana_pubkey::Pubkey,
36    pub remaining: Vec<solana_instruction::AccountMeta>,
37}
38
39impl InitializeMultisig {
40    pub fn decode(data: &[u8]) -> Option<Self> {
41        if data.is_empty() {
42            return None;
43        }
44        let discriminator = &data[0..1];
45        if discriminator != [2] {
46            return None;
47        }
48
49        let data_slice = data;
50
51        let data_slice = &data_slice[1..];
52
53        Self::deserialize(data_slice)
54    }
55}
56
57impl ArrangeAccounts for InitializeMultisig {
58    type ArrangedAccounts = InitializeMultisigInstructionAccounts;
59
60    fn arrange_accounts(
61        accounts: &[solana_instruction::AccountMeta],
62    ) -> Option<Self::ArrangedAccounts> {
63        let mut iter = accounts.iter();
64
65        let multisig = next_account(&mut iter)?;
66        let rent = next_account(&mut iter)?;
67
68        let remaining = iter.as_slice();
69
70        Some(InitializeMultisigInstructionAccounts {
71            multisig,
72            rent,
73            remaining: remaining.to_vec(),
74        })
75    }
76}