pub mod advance_nonce_account_row;
pub mod allocate_row;
pub mod allocate_with_seed_row;
pub mod assign_row;
pub mod assign_with_seed_row;
pub mod authorize_nonce_account_row;
pub mod create_account_row;
pub mod create_account_with_seed_row;
pub mod initialize_nonce_account_row;
pub mod transfer_sol_row;
pub mod transfer_sol_with_seed_row;
pub mod upgrade_nonce_account_row;
pub mod withdraw_nonce_account_row;
pub use self::{
advance_nonce_account_row::*, allocate_row::*, allocate_with_seed_row::*, assign_row::*,
assign_with_seed_row::*, authorize_nonce_account_row::*, create_account_row::*,
create_account_with_seed_row::*, initialize_nonce_account_row::*, transfer_sol_row::*,
transfer_sol_with_seed_row::*, upgrade_nonce_account_row::*, withdraw_nonce_account_row::*,
};
use super::SystemProgramInstruction;
pub struct SystemProgramInstructionsMigration;
impl sqlx_migrator::Migration<sqlx::Postgres> for SystemProgramInstructionsMigration {
fn app(&self) -> &str {
"system-program"
}
fn name(&self) -> &str {
"system_program_instructions"
}
fn operations(&self) -> Vec<Box<dyn sqlx_migrator::Operation<sqlx::Postgres>>> {
vec![
Box::new(AdvanceNonceAccountMigrationOperation),
Box::new(AllocateMigrationOperation),
Box::new(AllocateWithSeedMigrationOperation),
Box::new(AssignMigrationOperation),
Box::new(AssignWithSeedMigrationOperation),
Box::new(AuthorizeNonceAccountMigrationOperation),
Box::new(CreateAccountMigrationOperation),
Box::new(CreateAccountWithSeedMigrationOperation),
Box::new(InitializeNonceAccountMigrationOperation),
Box::new(TransferSolMigrationOperation),
Box::new(TransferSolWithSeedMigrationOperation),
Box::new(UpgradeNonceAccountMigrationOperation),
Box::new(WithdrawNonceAccountMigrationOperation),
]
}
fn parents(&self) -> Vec<Box<dyn sqlx_migrator::Migration<sqlx::Postgres>>> {
vec![]
}
}
pub struct SystemProgramInstructionWithMetadata(
pub SystemProgramInstruction,
pub carbon_core::instruction::InstructionMetadata,
pub Vec<solana_instruction::AccountMeta>,
);
impl
From<(
SystemProgramInstruction,
carbon_core::instruction::InstructionMetadata,
Vec<solana_instruction::AccountMeta>,
)> for SystemProgramInstructionWithMetadata
{
fn from(
value: (
SystemProgramInstruction,
carbon_core::instruction::InstructionMetadata,
Vec<solana_instruction::AccountMeta>,
),
) -> Self {
SystemProgramInstructionWithMetadata(value.0, value.1, value.2)
}
}
#[async_trait::async_trait]
impl carbon_core::postgres::operations::Insert for SystemProgramInstructionWithMetadata {
async fn insert(&self, pool: &sqlx::PgPool) -> carbon_core::error::CarbonResult<()> {
let SystemProgramInstructionWithMetadata(decoded_instruction, metadata, raw_accounts) =
self;
match decoded_instruction {
SystemProgramInstruction::CreateAccount { data, .. } => {
let row = create_account_row::CreateAccountRow::from_parts(
data.clone(),
metadata.clone(),
raw_accounts.clone(),
);
row.insert(pool).await?;
Ok(())
}
SystemProgramInstruction::Assign { data, .. } => {
let row = assign_row::AssignRow::from_parts(
data.clone(),
metadata.clone(),
raw_accounts.clone(),
);
row.insert(pool).await?;
Ok(())
}
SystemProgramInstruction::TransferSol { data, .. } => {
let row = transfer_sol_row::TransferSolRow::from_parts(
data.clone(),
metadata.clone(),
raw_accounts.clone(),
);
row.insert(pool).await?;
Ok(())
}
SystemProgramInstruction::CreateAccountWithSeed { data, .. } => {
let row = create_account_with_seed_row::CreateAccountWithSeedRow::from_parts(
data.clone(),
metadata.clone(),
raw_accounts.clone(),
);
row.insert(pool).await?;
Ok(())
}
SystemProgramInstruction::AdvanceNonceAccount { data, .. } => {
let row = advance_nonce_account_row::AdvanceNonceAccountRow::from_parts(
data.clone(),
metadata.clone(),
raw_accounts.clone(),
);
row.insert(pool).await?;
Ok(())
}
SystemProgramInstruction::WithdrawNonceAccount { data, .. } => {
let row = withdraw_nonce_account_row::WithdrawNonceAccountRow::from_parts(
data.clone(),
metadata.clone(),
raw_accounts.clone(),
);
row.insert(pool).await?;
Ok(())
}
SystemProgramInstruction::InitializeNonceAccount { data, .. } => {
let row = initialize_nonce_account_row::InitializeNonceAccountRow::from_parts(
data.clone(),
metadata.clone(),
raw_accounts.clone(),
);
row.insert(pool).await?;
Ok(())
}
SystemProgramInstruction::AuthorizeNonceAccount { data, .. } => {
let row = authorize_nonce_account_row::AuthorizeNonceAccountRow::from_parts(
data.clone(),
metadata.clone(),
raw_accounts.clone(),
);
row.insert(pool).await?;
Ok(())
}
SystemProgramInstruction::Allocate { data, .. } => {
let row = allocate_row::AllocateRow::from_parts(
data.clone(),
metadata.clone(),
raw_accounts.clone(),
);
row.insert(pool).await?;
Ok(())
}
SystemProgramInstruction::AllocateWithSeed { data, .. } => {
let row = allocate_with_seed_row::AllocateWithSeedRow::from_parts(
data.clone(),
metadata.clone(),
raw_accounts.clone(),
);
row.insert(pool).await?;
Ok(())
}
SystemProgramInstruction::AssignWithSeed { data, .. } => {
let row = assign_with_seed_row::AssignWithSeedRow::from_parts(
data.clone(),
metadata.clone(),
raw_accounts.clone(),
);
row.insert(pool).await?;
Ok(())
}
SystemProgramInstruction::TransferSolWithSeed { data, .. } => {
let row = transfer_sol_with_seed_row::TransferSolWithSeedRow::from_parts(
data.clone(),
metadata.clone(),
raw_accounts.clone(),
);
row.insert(pool).await?;
Ok(())
}
SystemProgramInstruction::UpgradeNonceAccount { data, .. } => {
let row = upgrade_nonce_account_row::UpgradeNonceAccountRow::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 SystemProgramInstructionWithMetadata {
async fn upsert(&self, pool: &sqlx::PgPool) -> carbon_core::error::CarbonResult<()> {
let SystemProgramInstructionWithMetadata(decoded_instruction, metadata, raw_accounts) =
self;
match decoded_instruction {
SystemProgramInstruction::CreateAccount { data, .. } => {
let row = create_account_row::CreateAccountRow::from_parts(
data.clone(),
metadata.clone(),
raw_accounts.clone(),
);
row.upsert(pool).await?;
Ok(())
}
SystemProgramInstruction::Assign { data, .. } => {
let row = assign_row::AssignRow::from_parts(
data.clone(),
metadata.clone(),
raw_accounts.clone(),
);
row.upsert(pool).await?;
Ok(())
}
SystemProgramInstruction::TransferSol { data, .. } => {
let row = transfer_sol_row::TransferSolRow::from_parts(
data.clone(),
metadata.clone(),
raw_accounts.clone(),
);
row.upsert(pool).await?;
Ok(())
}
SystemProgramInstruction::CreateAccountWithSeed { data, .. } => {
let row = create_account_with_seed_row::CreateAccountWithSeedRow::from_parts(
data.clone(),
metadata.clone(),
raw_accounts.clone(),
);
row.upsert(pool).await?;
Ok(())
}
SystemProgramInstruction::AdvanceNonceAccount { data, .. } => {
let row = advance_nonce_account_row::AdvanceNonceAccountRow::from_parts(
data.clone(),
metadata.clone(),
raw_accounts.clone(),
);
row.upsert(pool).await?;
Ok(())
}
SystemProgramInstruction::WithdrawNonceAccount { data, .. } => {
let row = withdraw_nonce_account_row::WithdrawNonceAccountRow::from_parts(
data.clone(),
metadata.clone(),
raw_accounts.clone(),
);
row.upsert(pool).await?;
Ok(())
}
SystemProgramInstruction::InitializeNonceAccount { data, .. } => {
let row = initialize_nonce_account_row::InitializeNonceAccountRow::from_parts(
data.clone(),
metadata.clone(),
raw_accounts.clone(),
);
row.upsert(pool).await?;
Ok(())
}
SystemProgramInstruction::AuthorizeNonceAccount { data, .. } => {
let row = authorize_nonce_account_row::AuthorizeNonceAccountRow::from_parts(
data.clone(),
metadata.clone(),
raw_accounts.clone(),
);
row.upsert(pool).await?;
Ok(())
}
SystemProgramInstruction::Allocate { data, .. } => {
let row = allocate_row::AllocateRow::from_parts(
data.clone(),
metadata.clone(),
raw_accounts.clone(),
);
row.upsert(pool).await?;
Ok(())
}
SystemProgramInstruction::AllocateWithSeed { data, .. } => {
let row = allocate_with_seed_row::AllocateWithSeedRow::from_parts(
data.clone(),
metadata.clone(),
raw_accounts.clone(),
);
row.upsert(pool).await?;
Ok(())
}
SystemProgramInstruction::AssignWithSeed { data, .. } => {
let row = assign_with_seed_row::AssignWithSeedRow::from_parts(
data.clone(),
metadata.clone(),
raw_accounts.clone(),
);
row.upsert(pool).await?;
Ok(())
}
SystemProgramInstruction::TransferSolWithSeed { data, .. } => {
let row = transfer_sol_with_seed_row::TransferSolWithSeedRow::from_parts(
data.clone(),
metadata.clone(),
raw_accounts.clone(),
);
row.upsert(pool).await?;
Ok(())
}
SystemProgramInstruction::UpgradeNonceAccount { data, .. } => {
let row = upgrade_nonce_account_row::UpgradeNonceAccountRow::from_parts(
data.clone(),
metadata.clone(),
raw_accounts.clone(),
);
row.upsert(pool).await?;
Ok(())
}
}
}
}