pub mod add_memo_row;
pub use self::add_memo_row::*;
use super::MemoProgramInstruction;
pub struct MemoProgramInstructionsMigration;
impl sqlx_migrator::Migration<sqlx::Postgres> for MemoProgramInstructionsMigration {
fn app(&self) -> &str {
"memo-program"
}
fn name(&self) -> &str {
"memo_program_instructions"
}
fn operations(&self) -> Vec<Box<dyn sqlx_migrator::Operation<sqlx::Postgres>>> {
vec![Box::new(AddMemoMigrationOperation)]
}
fn parents(&self) -> Vec<Box<dyn sqlx_migrator::Migration<sqlx::Postgres>>> {
vec![]
}
}
pub struct MemoProgramInstructionWithMetadata(
pub MemoProgramInstruction,
pub carbon_core::instruction::InstructionMetadata,
pub Vec<solana_instruction::AccountMeta>,
);
impl
From<(
MemoProgramInstruction,
carbon_core::instruction::InstructionMetadata,
Vec<solana_instruction::AccountMeta>,
)> for MemoProgramInstructionWithMetadata
{
fn from(
value: (
MemoProgramInstruction,
carbon_core::instruction::InstructionMetadata,
Vec<solana_instruction::AccountMeta>,
),
) -> Self {
MemoProgramInstructionWithMetadata(value.0, value.1, value.2)
}
}
#[async_trait::async_trait]
impl carbon_core::postgres::operations::Insert for MemoProgramInstructionWithMetadata {
async fn insert(&self, pool: &sqlx::PgPool) -> carbon_core::error::CarbonResult<()> {
let MemoProgramInstructionWithMetadata(decoded_instruction, metadata, raw_accounts) = self;
match decoded_instruction {
MemoProgramInstruction::AddMemo { data, .. } => {
let row = add_memo_row::AddMemoRow::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 MemoProgramInstructionWithMetadata {
async fn upsert(&self, pool: &sqlx::PgPool) -> carbon_core::error::CarbonResult<()> {
let MemoProgramInstructionWithMetadata(decoded_instruction, metadata, raw_accounts) = self;
match decoded_instruction {
MemoProgramInstruction::AddMemo { data, .. } => {
let row = add_memo_row::AddMemoRow::from_parts(
data.clone(),
metadata.clone(),
raw_accounts.clone(),
);
row.upsert(pool).await?;
Ok(())
}
}
}
}