pub mod burn_row;
pub mod cancel_redeem_row;
pub mod create_tree_row;
pub mod decompress_v1_row;
pub mod delegate_row;
pub mod mint_to_collection_v1_row;
pub mod mint_v1_row;
pub mod redeem_row;
pub mod set_and_verify_collection_row;
pub mod set_decompressible_state_row;
pub mod set_tree_delegate_row;
pub mod transfer_row;
pub mod unverify_collection_row;
pub mod unverify_creator_row;
pub mod update_metadata_row;
pub mod verify_collection_row;
pub mod verify_creator_row;
pub use self::{
burn_row::*, cancel_redeem_row::*, create_tree_row::*, decompress_v1_row::*, delegate_row::*,
mint_to_collection_v1_row::*, mint_v1_row::*, redeem_row::*, set_and_verify_collection_row::*,
set_decompressible_state_row::*, set_tree_delegate_row::*, transfer_row::*,
unverify_collection_row::*, unverify_creator_row::*, update_metadata_row::*,
verify_collection_row::*, verify_creator_row::*,
};
use super::BubblegumInstruction;
pub struct BubblegumInstructionsMigration;
impl sqlx_migrator::Migration<sqlx::Postgres> for BubblegumInstructionsMigration {
fn app(&self) -> &str {
"bubblegum"
}
fn name(&self) -> &str {
"bubblegum_instructions"
}
fn operations(&self) -> Vec<Box<dyn sqlx_migrator::Operation<sqlx::Postgres>>> {
vec![
Box::new(BurnMigrationOperation),
Box::new(CancelRedeemMigrationOperation),
Box::new(CreateTreeMigrationOperation),
Box::new(DecompressV1MigrationOperation),
Box::new(DelegateMigrationOperation),
Box::new(MintToCollectionV1MigrationOperation),
Box::new(MintV1MigrationOperation),
Box::new(RedeemMigrationOperation),
Box::new(SetAndVerifyCollectionMigrationOperation),
Box::new(SetDecompressibleStateMigrationOperation),
Box::new(SetTreeDelegateMigrationOperation),
Box::new(TransferMigrationOperation),
Box::new(UnverifyCollectionMigrationOperation),
Box::new(UnverifyCreatorMigrationOperation),
Box::new(UpdateMetadataMigrationOperation),
Box::new(VerifyCollectionMigrationOperation),
Box::new(VerifyCreatorMigrationOperation),
]
}
fn parents(&self) -> Vec<Box<dyn sqlx_migrator::Migration<sqlx::Postgres>>> {
vec![]
}
}
pub struct BubblegumInstructionWithMetadata(
pub BubblegumInstruction,
pub carbon_core::instruction::InstructionMetadata,
pub Vec<solana_instruction::AccountMeta>,
);
impl
From<(
BubblegumInstruction,
carbon_core::instruction::InstructionMetadata,
Vec<solana_instruction::AccountMeta>,
)> for BubblegumInstructionWithMetadata
{
fn from(
value: (
BubblegumInstruction,
carbon_core::instruction::InstructionMetadata,
Vec<solana_instruction::AccountMeta>,
),
) -> Self {
BubblegumInstructionWithMetadata(value.0, value.1, value.2)
}
}
#[async_trait::async_trait]
impl carbon_core::postgres::operations::Insert for BubblegumInstructionWithMetadata {
async fn insert(&self, pool: &sqlx::PgPool) -> carbon_core::error::CarbonResult<()> {
let BubblegumInstructionWithMetadata(decoded_instruction, metadata, raw_accounts) = self;
match decoded_instruction {
BubblegumInstruction::Burn { data, .. } => {
let row = burn_row::BurnRow::from_parts(
data.clone(),
metadata.clone(),
raw_accounts.clone(),
);
row.insert(pool).await?;
Ok(())
}
BubblegumInstruction::CancelRedeem { data, .. } => {
let row = cancel_redeem_row::CancelRedeemRow::from_parts(
data.clone(),
metadata.clone(),
raw_accounts.clone(),
);
row.insert(pool).await?;
Ok(())
}
BubblegumInstruction::CreateTree { data, .. } => {
let row = create_tree_row::CreateTreeRow::from_parts(
data.clone(),
metadata.clone(),
raw_accounts.clone(),
);
row.insert(pool).await?;
Ok(())
}
BubblegumInstruction::DecompressV1 { data, .. } => {
let row = decompress_v1_row::DecompressV1Row::from_parts(
data.clone(),
metadata.clone(),
raw_accounts.clone(),
);
row.insert(pool).await?;
Ok(())
}
BubblegumInstruction::Delegate { data, .. } => {
let row = delegate_row::DelegateRow::from_parts(
data.clone(),
metadata.clone(),
raw_accounts.clone(),
);
row.insert(pool).await?;
Ok(())
}
BubblegumInstruction::MintToCollectionV1 { data, .. } => {
let row = mint_to_collection_v1_row::MintToCollectionV1Row::from_parts(
data.clone(),
metadata.clone(),
raw_accounts.clone(),
);
row.insert(pool).await?;
Ok(())
}
BubblegumInstruction::MintV1 { data, .. } => {
let row = mint_v1_row::MintV1Row::from_parts(
data.clone(),
metadata.clone(),
raw_accounts.clone(),
);
row.insert(pool).await?;
Ok(())
}
BubblegumInstruction::Redeem { data, .. } => {
let row = redeem_row::RedeemRow::from_parts(
data.clone(),
metadata.clone(),
raw_accounts.clone(),
);
row.insert(pool).await?;
Ok(())
}
BubblegumInstruction::SetAndVerifyCollection { data, .. } => {
let row = set_and_verify_collection_row::SetAndVerifyCollectionRow::from_parts(
data.clone(),
metadata.clone(),
raw_accounts.clone(),
);
row.insert(pool).await?;
Ok(())
}
BubblegumInstruction::SetDecompressibleState { data, .. } => {
let row = set_decompressible_state_row::SetDecompressibleStateRow::from_parts(
data.clone(),
metadata.clone(),
raw_accounts.clone(),
);
row.insert(pool).await?;
Ok(())
}
BubblegumInstruction::SetTreeDelegate { data, .. } => {
let row = set_tree_delegate_row::SetTreeDelegateRow::from_parts(
data.clone(),
metadata.clone(),
raw_accounts.clone(),
);
row.insert(pool).await?;
Ok(())
}
BubblegumInstruction::Transfer { data, .. } => {
let row = transfer_row::TransferRow::from_parts(
data.clone(),
metadata.clone(),
raw_accounts.clone(),
);
row.insert(pool).await?;
Ok(())
}
BubblegumInstruction::UnverifyCollection { data, .. } => {
let row = unverify_collection_row::UnverifyCollectionRow::from_parts(
data.clone(),
metadata.clone(),
raw_accounts.clone(),
);
row.insert(pool).await?;
Ok(())
}
BubblegumInstruction::UnverifyCreator { data, .. } => {
let row = unverify_creator_row::UnverifyCreatorRow::from_parts(
data.clone(),
metadata.clone(),
raw_accounts.clone(),
);
row.insert(pool).await?;
Ok(())
}
BubblegumInstruction::VerifyCollection { data, .. } => {
let row = verify_collection_row::VerifyCollectionRow::from_parts(
data.clone(),
metadata.clone(),
raw_accounts.clone(),
);
row.insert(pool).await?;
Ok(())
}
BubblegumInstruction::VerifyCreator { data, .. } => {
let row = verify_creator_row::VerifyCreatorRow::from_parts(
data.clone(),
metadata.clone(),
raw_accounts.clone(),
);
row.insert(pool).await?;
Ok(())
}
BubblegumInstruction::UpdateMetadata { data, .. } => {
let row = update_metadata_row::UpdateMetadataRow::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 BubblegumInstructionWithMetadata {
async fn upsert(&self, pool: &sqlx::PgPool) -> carbon_core::error::CarbonResult<()> {
let BubblegumInstructionWithMetadata(decoded_instruction, metadata, raw_accounts) = self;
match decoded_instruction {
BubblegumInstruction::Burn { data, .. } => {
let row = burn_row::BurnRow::from_parts(
data.clone(),
metadata.clone(),
raw_accounts.clone(),
);
row.upsert(pool).await?;
Ok(())
}
BubblegumInstruction::CancelRedeem { data, .. } => {
let row = cancel_redeem_row::CancelRedeemRow::from_parts(
data.clone(),
metadata.clone(),
raw_accounts.clone(),
);
row.upsert(pool).await?;
Ok(())
}
BubblegumInstruction::CreateTree { data, .. } => {
let row = create_tree_row::CreateTreeRow::from_parts(
data.clone(),
metadata.clone(),
raw_accounts.clone(),
);
row.upsert(pool).await?;
Ok(())
}
BubblegumInstruction::DecompressV1 { data, .. } => {
let row = decompress_v1_row::DecompressV1Row::from_parts(
data.clone(),
metadata.clone(),
raw_accounts.clone(),
);
row.upsert(pool).await?;
Ok(())
}
BubblegumInstruction::Delegate { data, .. } => {
let row = delegate_row::DelegateRow::from_parts(
data.clone(),
metadata.clone(),
raw_accounts.clone(),
);
row.upsert(pool).await?;
Ok(())
}
BubblegumInstruction::MintToCollectionV1 { data, .. } => {
let row = mint_to_collection_v1_row::MintToCollectionV1Row::from_parts(
data.clone(),
metadata.clone(),
raw_accounts.clone(),
);
row.upsert(pool).await?;
Ok(())
}
BubblegumInstruction::MintV1 { data, .. } => {
let row = mint_v1_row::MintV1Row::from_parts(
data.clone(),
metadata.clone(),
raw_accounts.clone(),
);
row.upsert(pool).await?;
Ok(())
}
BubblegumInstruction::Redeem { data, .. } => {
let row = redeem_row::RedeemRow::from_parts(
data.clone(),
metadata.clone(),
raw_accounts.clone(),
);
row.upsert(pool).await?;
Ok(())
}
BubblegumInstruction::SetAndVerifyCollection { data, .. } => {
let row = set_and_verify_collection_row::SetAndVerifyCollectionRow::from_parts(
data.clone(),
metadata.clone(),
raw_accounts.clone(),
);
row.upsert(pool).await?;
Ok(())
}
BubblegumInstruction::SetDecompressibleState { data, .. } => {
let row = set_decompressible_state_row::SetDecompressibleStateRow::from_parts(
data.clone(),
metadata.clone(),
raw_accounts.clone(),
);
row.upsert(pool).await?;
Ok(())
}
BubblegumInstruction::SetTreeDelegate { data, .. } => {
let row = set_tree_delegate_row::SetTreeDelegateRow::from_parts(
data.clone(),
metadata.clone(),
raw_accounts.clone(),
);
row.upsert(pool).await?;
Ok(())
}
BubblegumInstruction::Transfer { data, .. } => {
let row = transfer_row::TransferRow::from_parts(
data.clone(),
metadata.clone(),
raw_accounts.clone(),
);
row.upsert(pool).await?;
Ok(())
}
BubblegumInstruction::UnverifyCollection { data, .. } => {
let row = unverify_collection_row::UnverifyCollectionRow::from_parts(
data.clone(),
metadata.clone(),
raw_accounts.clone(),
);
row.upsert(pool).await?;
Ok(())
}
BubblegumInstruction::UnverifyCreator { data, .. } => {
let row = unverify_creator_row::UnverifyCreatorRow::from_parts(
data.clone(),
metadata.clone(),
raw_accounts.clone(),
);
row.upsert(pool).await?;
Ok(())
}
BubblegumInstruction::VerifyCollection { data, .. } => {
let row = verify_collection_row::VerifyCollectionRow::from_parts(
data.clone(),
metadata.clone(),
raw_accounts.clone(),
);
row.upsert(pool).await?;
Ok(())
}
BubblegumInstruction::VerifyCreator { data, .. } => {
let row = verify_creator_row::VerifyCreatorRow::from_parts(
data.clone(),
metadata.clone(),
raw_accounts.clone(),
);
row.upsert(pool).await?;
Ok(())
}
BubblegumInstruction::UpdateMetadata { data, .. } => {
let row = update_metadata_row::UpdateMetadataRow::from_parts(
data.clone(),
metadata.clone(),
raw_accounts.clone(),
);
row.upsert(pool).await?;
Ok(())
}
}
}
}