pub mod batch_thaw_lst_accounts_row;
pub mod initialize_row;
pub mod restake_row;
pub mod unrestake_row;
pub use self::{
batch_thaw_lst_accounts_row::*, initialize_row::*, restake_row::*, unrestake_row::*,
};
use super::SolayerRestakingProgramInstruction;
pub struct SolayerRestakingProgramInstructionsMigration;
impl sqlx_migrator::Migration<sqlx::Postgres> for SolayerRestakingProgramInstructionsMigration {
fn app(&self) -> &str {
"solayer-restaking-program"
}
fn name(&self) -> &str {
"solayer_restaking_program_instructions"
}
fn operations(&self) -> Vec<Box<dyn sqlx_migrator::Operation<sqlx::Postgres>>> {
vec![
Box::new(BatchThawLstAccountsMigrationOperation),
Box::new(InitializeMigrationOperation),
Box::new(RestakeMigrationOperation),
Box::new(UnrestakeMigrationOperation),
]
}
fn parents(&self) -> Vec<Box<dyn sqlx_migrator::Migration<sqlx::Postgres>>> {
vec![]
}
}
pub struct SolayerRestakingProgramInstructionWithMetadata(
pub SolayerRestakingProgramInstruction,
pub carbon_core::instruction::InstructionMetadata,
pub Vec<solana_instruction::AccountMeta>,
);
impl
From<(
SolayerRestakingProgramInstruction,
carbon_core::instruction::InstructionMetadata,
Vec<solana_instruction::AccountMeta>,
)> for SolayerRestakingProgramInstructionWithMetadata
{
fn from(
value: (
SolayerRestakingProgramInstruction,
carbon_core::instruction::InstructionMetadata,
Vec<solana_instruction::AccountMeta>,
),
) -> Self {
SolayerRestakingProgramInstructionWithMetadata(value.0, value.1, value.2)
}
}
#[async_trait::async_trait]
impl carbon_core::postgres::operations::Insert for SolayerRestakingProgramInstructionWithMetadata {
async fn insert(&self, pool: &sqlx::PgPool) -> carbon_core::error::CarbonResult<()> {
let SolayerRestakingProgramInstructionWithMetadata(
decoded_instruction,
metadata,
raw_accounts,
) = self;
match decoded_instruction {
SolayerRestakingProgramInstruction::Initialize { data, .. } => {
let row = initialize_row::InitializeRow::from_parts(
data.clone(),
metadata.clone(),
raw_accounts.clone(),
);
row.insert(pool).await?;
Ok(())
}
SolayerRestakingProgramInstruction::Restake { data, .. } => {
let row = restake_row::RestakeRow::from_parts(
data.clone(),
metadata.clone(),
raw_accounts.clone(),
);
row.insert(pool).await?;
Ok(())
}
SolayerRestakingProgramInstruction::Unrestake { data, .. } => {
let row = unrestake_row::UnrestakeRow::from_parts(
data.clone(),
metadata.clone(),
raw_accounts.clone(),
);
row.insert(pool).await?;
Ok(())
}
SolayerRestakingProgramInstruction::BatchThawLstAccounts { data, .. } => {
let row = batch_thaw_lst_accounts_row::BatchThawLstAccountsRow::from_parts(
data.clone(),
metadata.clone(),
raw_accounts.clone(),
);
row.insert(pool).await?;
Ok(())
}
}
}
}
#[async_trait::async_trait]
impl carbon_core::postgres::operations::Upsert for SolayerRestakingProgramInstructionWithMetadata {
async fn upsert(&self, pool: &sqlx::PgPool) -> carbon_core::error::CarbonResult<()> {
let SolayerRestakingProgramInstructionWithMetadata(
decoded_instruction,
metadata,
raw_accounts,
) = self;
match decoded_instruction {
SolayerRestakingProgramInstruction::Initialize { data, .. } => {
let row = initialize_row::InitializeRow::from_parts(
data.clone(),
metadata.clone(),
raw_accounts.clone(),
);
row.upsert(pool).await?;
Ok(())
}
SolayerRestakingProgramInstruction::Restake { data, .. } => {
let row = restake_row::RestakeRow::from_parts(
data.clone(),
metadata.clone(),
raw_accounts.clone(),
);
row.upsert(pool).await?;
Ok(())
}
SolayerRestakingProgramInstruction::Unrestake { data, .. } => {
let row = unrestake_row::UnrestakeRow::from_parts(
data.clone(),
metadata.clone(),
raw_accounts.clone(),
);
row.upsert(pool).await?;
Ok(())
}
SolayerRestakingProgramInstruction::BatchThawLstAccounts { data, .. } => {
let row = batch_thaw_lst_accounts_row::BatchThawLstAccountsRow::from_parts(
data.clone(),
metadata.clone(),
raw_accounts.clone(),
);
row.upsert(pool).await?;
Ok(())
}
}
}
}