use carbon_core::{account_utils::next_account, deserialize::ArrangeAccounts};
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[derive(Debug, Clone, borsh::BorshSerialize, borsh::BorshDeserialize, PartialEq)]
pub struct ClaimSocialFeePda {
pub user_id: String,
pub platform: u8,
}
#[derive(Debug, Clone, PartialEq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct ClaimSocialFeePdaInstructionAccounts {
pub recipient: solana_pubkey::Pubkey,
pub social_fee_pda: solana_pubkey::Pubkey,
pub fee_program_global: solana_pubkey::Pubkey,
pub social_claim_authority: solana_pubkey::Pubkey,
pub event_authority: solana_pubkey::Pubkey,
pub program: solana_pubkey::Pubkey,
pub remaining: Vec<solana_instruction::AccountMeta>,
}
impl ClaimSocialFeePda {
pub fn decode(data: &[u8]) -> Option<Self> {
if data.len() < 8 {
return None;
}
let discriminator = &data[0..8];
if discriminator != [225, 21, 251, 133, 161, 30, 199, 226] {
return None;
}
let mut data_slice = data;
data_slice = &data_slice[8..];
borsh::BorshDeserialize::deserialize(&mut data_slice).ok()
}
}
impl ArrangeAccounts for ClaimSocialFeePda {
type ArrangedAccounts = ClaimSocialFeePdaInstructionAccounts;
fn arrange_accounts(
accounts: &[solana_instruction::AccountMeta],
) -> Option<Self::ArrangedAccounts> {
let mut iter = accounts.iter();
let recipient = next_account(&mut iter)?;
let social_fee_pda = next_account(&mut iter)?;
let fee_program_global = next_account(&mut iter)?;
let social_claim_authority = next_account(&mut iter)?;
let event_authority = next_account(&mut iter)?;
let program = next_account(&mut iter)?;
let remaining = iter.as_slice();
Some(ClaimSocialFeePdaInstructionAccounts {
recipient,
social_fee_pda,
fee_program_global,
social_claim_authority,
event_authority,
program,
remaining: remaining.to_vec(),
})
}
}