carbon_token_program_decoder/instructions/
revoke.rs1use carbon_core::{account_utils::next_account, deserialize::ArrangeAccounts};
3#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
5#[derive(Debug, Clone, borsh::BorshSerialize, borsh::BorshDeserialize, PartialEq)]
6pub struct Revoke {}
7
8#[derive(Debug, Clone, PartialEq)]
9#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
10pub struct RevokeInstructionAccounts {
11 pub source: solana_pubkey::Pubkey,
12 pub owner: solana_pubkey::Pubkey,
13 pub remaining: Vec<solana_instruction::AccountMeta>,
14}
15
16impl Revoke {
17 pub fn decode(data: &[u8]) -> Option<Self> {
18 if data.is_empty() {
19 return None;
20 }
21 let discriminator = &data[0..1];
22 if discriminator != [5] {
23 return None;
24 }
25
26 let mut data_slice = data;
27
28 data_slice = &data_slice[1..];
29
30 borsh::BorshDeserialize::deserialize(&mut data_slice).ok()
31 }
32}
33
34impl ArrangeAccounts for Revoke {
35 type ArrangedAccounts = RevokeInstructionAccounts;
36
37 fn arrange_accounts(
38 accounts: &[solana_instruction::AccountMeta],
39 ) -> Option<Self::ArrangedAccounts> {
40 let mut iter = accounts.iter();
41
42 let source = next_account(&mut iter)?;
43 let owner = next_account(&mut iter)?;
44
45 let remaining = iter.as_slice();
46
47 Some(RevokeInstructionAccounts {
48 source,
49 owner,
50 remaining: remaining.to_vec(),
51 })
52 }
53}