pub mod global_config_row;
pub mod platform_config_row;
pub mod platform_global_access_row;
pub mod pool_state_row;
pub mod vesting_record_row;
pub use self::{
global_config_row::*, platform_config_row::*, platform_global_access_row::*, pool_state_row::*,
vesting_record_row::*,
};
use super::RaydiumLaunchpadAccount;
pub struct RaydiumLaunchpadAccountsMigration;
impl sqlx_migrator::Migration<sqlx::Postgres> for RaydiumLaunchpadAccountsMigration {
fn app(&self) -> &str {
"raydium-launchpad"
}
fn name(&self) -> &str {
"raydium_launchpad_accounts"
}
fn operations(&self) -> Vec<Box<dyn sqlx_migrator::Operation<sqlx::Postgres>>> {
vec![
Box::new(GlobalConfigMigrationOperation),
Box::new(PlatformConfigMigrationOperation),
Box::new(PlatformGlobalAccessMigrationOperation),
Box::new(PoolStateMigrationOperation),
Box::new(VestingRecordMigrationOperation),
]
}
fn parents(&self) -> Vec<Box<dyn sqlx_migrator::Migration<sqlx::Postgres>>> {
vec![]
}
}
pub struct RaydiumLaunchpadAccountWithMetadata(
pub RaydiumLaunchpadAccount,
pub carbon_core::account::AccountMetadata,
);
impl
From<(
RaydiumLaunchpadAccount,
carbon_core::account::AccountMetadata,
)> for RaydiumLaunchpadAccountWithMetadata
{
fn from(
value: (
RaydiumLaunchpadAccount,
carbon_core::account::AccountMetadata,
),
) -> Self {
RaydiumLaunchpadAccountWithMetadata(value.0, value.1)
}
}
#[async_trait::async_trait]
impl carbon_core::postgres::operations::Insert for RaydiumLaunchpadAccountWithMetadata {
async fn insert(&self, pool: &sqlx::PgPool) -> carbon_core::error::CarbonResult<()> {
let RaydiumLaunchpadAccountWithMetadata(account, metadata) = self;
match account {
RaydiumLaunchpadAccount::GlobalConfig(account) => {
let row = global_config_row::GlobalConfigRow::from_parts(
*account.clone(),
metadata.clone(),
);
row.insert(pool).await?;
Ok(())
}
RaydiumLaunchpadAccount::PlatformConfig(account) => {
let row = platform_config_row::PlatformConfigRow::from_parts(
*account.clone(),
metadata.clone(),
);
row.insert(pool).await?;
Ok(())
}
RaydiumLaunchpadAccount::PlatformGlobalAccess(account) => {
let row = platform_global_access_row::PlatformGlobalAccessRow::from_parts(
*account.clone(),
metadata.clone(),
);
row.insert(pool).await?;
Ok(())
}
RaydiumLaunchpadAccount::PoolState(account) => {
let row =
pool_state_row::PoolStateRow::from_parts(*account.clone(), metadata.clone());
row.insert(pool).await?;
Ok(())
}
RaydiumLaunchpadAccount::VestingRecord(account) => {
let row = vesting_record_row::VestingRecordRow::from_parts(
*account.clone(),
metadata.clone(),
);
row.insert(pool).await?;
Ok(())
}
}
}
}
#[async_trait::async_trait]
impl carbon_core::postgres::operations::Upsert for RaydiumLaunchpadAccountWithMetadata {
async fn upsert(&self, pool: &sqlx::PgPool) -> carbon_core::error::CarbonResult<()> {
let RaydiumLaunchpadAccountWithMetadata(account, metadata) = self;
match account {
RaydiumLaunchpadAccount::GlobalConfig(account) => {
let row = global_config_row::GlobalConfigRow::from_parts(
*account.clone(),
metadata.clone(),
);
row.upsert(pool).await?;
Ok(())
}
RaydiumLaunchpadAccount::PlatformConfig(account) => {
let row = platform_config_row::PlatformConfigRow::from_parts(
*account.clone(),
metadata.clone(),
);
row.upsert(pool).await?;
Ok(())
}
RaydiumLaunchpadAccount::PlatformGlobalAccess(account) => {
let row = platform_global_access_row::PlatformGlobalAccessRow::from_parts(
*account.clone(),
metadata.clone(),
);
row.upsert(pool).await?;
Ok(())
}
RaydiumLaunchpadAccount::PoolState(account) => {
let row =
pool_state_row::PoolStateRow::from_parts(*account.clone(), metadata.clone());
row.upsert(pool).await?;
Ok(())
}
RaydiumLaunchpadAccount::VestingRecord(account) => {
let row = vesting_record_row::VestingRecordRow::from_parts(
*account.clone(),
metadata.clone(),
);
row.upsert(pool).await?;
Ok(())
}
}
}
}