pub mod bonding_curve_row;
pub mod fee_config_row;
pub mod fee_program_global_row;
pub mod global_row;
pub mod pool_row;
pub mod sharing_config_row;
pub mod social_fee_pda_row;
pub use self::{
bonding_curve_row::*, fee_config_row::*, fee_program_global_row::*, global_row::*, pool_row::*,
sharing_config_row::*, social_fee_pda_row::*,
};
use super::PumpFeesAccount;
pub struct PumpFeesAccountsMigration;
impl sqlx_migrator::Migration<sqlx::Postgres> for PumpFeesAccountsMigration {
fn app(&self) -> &str {
"pump-fees"
}
fn name(&self) -> &str {
"pump_fees_accounts"
}
fn operations(&self) -> Vec<Box<dyn sqlx_migrator::Operation<sqlx::Postgres>>> {
vec![
Box::new(BondingCurveMigrationOperation),
Box::new(FeeConfigMigrationOperation),
Box::new(FeeProgramGlobalMigrationOperation),
Box::new(GlobalMigrationOperation),
Box::new(PoolMigrationOperation),
Box::new(SharingConfigMigrationOperation),
Box::new(SocialFeePdaMigrationOperation),
]
}
fn parents(&self) -> Vec<Box<dyn sqlx_migrator::Migration<sqlx::Postgres>>> {
vec![]
}
}
pub struct PumpFeesAccountWithMetadata(
pub PumpFeesAccount,
pub carbon_core::account::AccountMetadata,
);
impl From<(PumpFeesAccount, carbon_core::account::AccountMetadata)>
for PumpFeesAccountWithMetadata
{
fn from(value: (PumpFeesAccount, carbon_core::account::AccountMetadata)) -> Self {
PumpFeesAccountWithMetadata(value.0, value.1)
}
}
#[async_trait::async_trait]
impl carbon_core::postgres::operations::Insert for PumpFeesAccountWithMetadata {
async fn insert(&self, pool: &sqlx::PgPool) -> carbon_core::error::CarbonResult<()> {
let PumpFeesAccountWithMetadata(account, metadata) = self;
match account {
PumpFeesAccount::BondingCurve(account) => {
let row = bonding_curve_row::BondingCurveRow::from_parts(
*account.clone(),
metadata.clone(),
);
row.insert(pool).await?;
Ok(())
}
PumpFeesAccount::FeeConfig(account) => {
let row =
fee_config_row::FeeConfigRow::from_parts(*account.clone(), metadata.clone());
row.insert(pool).await?;
Ok(())
}
PumpFeesAccount::FeeProgramGlobal(account) => {
let row = fee_program_global_row::FeeProgramGlobalRow::from_parts(
*account.clone(),
metadata.clone(),
);
row.insert(pool).await?;
Ok(())
}
PumpFeesAccount::Global(account) => {
let row = global_row::GlobalRow::from_parts(*account.clone(), metadata.clone());
row.insert(pool).await?;
Ok(())
}
PumpFeesAccount::Pool(account) => {
let row = pool_row::PoolRow::from_parts(*account.clone(), metadata.clone());
row.insert(pool).await?;
Ok(())
}
PumpFeesAccount::SharingConfig(account) => {
let row = sharing_config_row::SharingConfigRow::from_parts(
*account.clone(),
metadata.clone(),
);
row.insert(pool).await?;
Ok(())
}
PumpFeesAccount::SocialFeePda(account) => {
let row = social_fee_pda_row::SocialFeePdaRow::from_parts(
*account.clone(),
metadata.clone(),
);
row.insert(pool).await?;
Ok(())
}
}
}
}
#[async_trait::async_trait]
impl carbon_core::postgres::operations::Upsert for PumpFeesAccountWithMetadata {
async fn upsert(&self, pool: &sqlx::PgPool) -> carbon_core::error::CarbonResult<()> {
let PumpFeesAccountWithMetadata(account, metadata) = self;
match account {
PumpFeesAccount::BondingCurve(account) => {
let row = bonding_curve_row::BondingCurveRow::from_parts(
*account.clone(),
metadata.clone(),
);
row.upsert(pool).await?;
Ok(())
}
PumpFeesAccount::FeeConfig(account) => {
let row =
fee_config_row::FeeConfigRow::from_parts(*account.clone(), metadata.clone());
row.upsert(pool).await?;
Ok(())
}
PumpFeesAccount::FeeProgramGlobal(account) => {
let row = fee_program_global_row::FeeProgramGlobalRow::from_parts(
*account.clone(),
metadata.clone(),
);
row.upsert(pool).await?;
Ok(())
}
PumpFeesAccount::Global(account) => {
let row = global_row::GlobalRow::from_parts(*account.clone(), metadata.clone());
row.upsert(pool).await?;
Ok(())
}
PumpFeesAccount::Pool(account) => {
let row = pool_row::PoolRow::from_parts(*account.clone(), metadata.clone());
row.upsert(pool).await?;
Ok(())
}
PumpFeesAccount::SharingConfig(account) => {
let row = sharing_config_row::SharingConfigRow::from_parts(
*account.clone(),
metadata.clone(),
);
row.upsert(pool).await?;
Ok(())
}
PumpFeesAccount::SocialFeePda(account) => {
let row = social_fee_pda_row::SocialFeePdaRow::from_parts(
*account.clone(),
metadata.clone(),
);
row.upsert(pool).await?;
Ok(())
}
}
}
}