use crate::{WavebreakDecoder, PROGRAM_ID};
#[cfg(feature = "postgres")]
pub mod postgres;
#[cfg(feature = "graphql")]
pub mod graphql;
pub mod authority_config;
pub mod bonding_curve;
pub mod consumed_permission;
pub mod mint_config;
pub mod permission_config;
#[derive(Debug, Clone, PartialEq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "serde", serde(tag = "type", content = "data"))]
pub enum WavebreakAccount {
AuthorityConfig(Box<authority_config::AuthorityConfig>),
BondingCurve(Box<bonding_curve::BondingCurve>),
ConsumedPermission(Box<consumed_permission::ConsumedPermission>),
MintConfig(Box<mint_config::MintConfig>),
PermissionConfig(Box<permission_config::PermissionConfig>),
}
impl<'a> carbon_core::account::AccountDecoder<'a> for WavebreakDecoder {
type AccountType = WavebreakAccount;
fn decode_account(
&self,
account: &'a solana_account::Account,
) -> Option<carbon_core::account::DecodedAccount<Self::AccountType>> {
if account.owner != PROGRAM_ID {
return None;
}
let data = account.data.as_slice();
{
if let Some(decoded) = authority_config::AuthorityConfig::decode(data) {
return Some(carbon_core::account::DecodedAccount {
lamports: account.lamports,
data: WavebreakAccount::AuthorityConfig(Box::new(decoded)),
owner: account.owner,
executable: account.executable,
rent_epoch: account.rent_epoch,
});
}
}
{
if let Some(decoded) = bonding_curve::BondingCurve::decode(data) {
return Some(carbon_core::account::DecodedAccount {
lamports: account.lamports,
data: WavebreakAccount::BondingCurve(Box::new(decoded)),
owner: account.owner,
executable: account.executable,
rent_epoch: account.rent_epoch,
});
}
}
{
if let Some(decoded) = mint_config::MintConfig::decode(data) {
return Some(carbon_core::account::DecodedAccount {
lamports: account.lamports,
data: WavebreakAccount::MintConfig(Box::new(decoded)),
owner: account.owner,
executable: account.executable,
rent_epoch: account.rent_epoch,
});
}
}
{
if let Some(decoded) = permission_config::PermissionConfig::decode(data) {
return Some(carbon_core::account::DecodedAccount {
lamports: account.lamports,
data: WavebreakAccount::PermissionConfig(Box::new(decoded)),
owner: account.owner,
executable: account.executable,
rent_epoch: account.rent_epoch,
});
}
}
{
if let Some(decoded) = consumed_permission::ConsumedPermission::decode(data) {
return Some(carbon_core::account::DecodedAccount {
lamports: account.lamports,
data: WavebreakAccount::ConsumedPermission(Box::new(decoded)),
owner: account.owner,
executable: account.executable,
rent_epoch: account.rent_epoch,
});
}
}
None
}
}