From 8b23eb4e4292d7834ae8d1b34572d8b69540fc07 Mon Sep 17 00:00:00 2001 From: Tahsin Tunan Date: Thu, 4 Jan 2024 21:17:41 +0600 Subject: [PATCH] add types --- .../src/dao/generated/cl_audits_v2.rs | 74 ++++++++++++++++++ digital_asset_types/src/dao/generated/mod.rs | 3 +- .../src/dao/generated/prelude.rs | 4 +- .../src/dao/generated/sea_orm_active_enums.rs | 77 +++++++++++++++++++ 4 files changed, 155 insertions(+), 3 deletions(-) create mode 100644 digital_asset_types/src/dao/generated/cl_audits_v2.rs diff --git a/digital_asset_types/src/dao/generated/cl_audits_v2.rs b/digital_asset_types/src/dao/generated/cl_audits_v2.rs new file mode 100644 index 000000000..d1875c254 --- /dev/null +++ b/digital_asset_types/src/dao/generated/cl_audits_v2.rs @@ -0,0 +1,74 @@ +//! SeaORM Entity. Generated by sea-orm-codegen 0.9.3 + +use super::sea_orm_active_enums::Instruction; +use sea_orm::entity::prelude::*; +use serde::{Deserialize, Serialize}; + +#[derive(Copy, Clone, Default, Debug, DeriveEntity)] +pub struct Entity; + +impl EntityName for Entity { + fn table_name(&self) -> &str { + "cl_audits_v2" + } +} + +#[derive(Clone, Debug, PartialEq, DeriveModel, DeriveActiveModel, Serialize, Deserialize)] +pub struct Model { + pub id: i64, + pub tree: Vec, + pub leaf_idx: i64, + pub seq: i64, + pub created_at: DateTime, + pub tx: Vec, + pub instruction: Instruction, +} + +#[derive(Copy, Clone, Debug, EnumIter, DeriveColumn)] +pub enum Column { + Id, + Tree, + LeafIdx, + Seq, + CreatedAt, + Tx, + Instruction, +} + +#[derive(Copy, Clone, Debug, EnumIter, DerivePrimaryKey)] +pub enum PrimaryKey { + Id, +} + +impl PrimaryKeyTrait for PrimaryKey { + type ValueType = i64; + fn auto_increment() -> bool { + true + } +} + +#[derive(Copy, Clone, Debug, EnumIter)] +pub enum Relation {} + +impl ColumnTrait for Column { + type EntityName = Entity; + fn def(&self) -> ColumnDef { + match self { + Self::Id => ColumnType::BigInteger.def(), + Self::Tree => ColumnType::Binary.def(), + Self::LeafIdx => ColumnType::BigInteger.def(), + Self::Seq => ColumnType::BigInteger.def(), + Self::CreatedAt => ColumnType::DateTime.def(), + Self::Tx => ColumnType::Binary.def(), + Self::Instruction => Instruction::db_type(), + } + } +} + +impl RelationTrait for Relation { + fn def(&self) -> RelationDef { + panic!("No RelationDef") + } +} + +impl ActiveModelBehavior for ActiveModel {} diff --git a/digital_asset_types/src/dao/generated/mod.rs b/digital_asset_types/src/dao/generated/mod.rs index 5db9a8690..68e1db8fa 100644 --- a/digital_asset_types/src/dao/generated/mod.rs +++ b/digital_asset_types/src/dao/generated/mod.rs @@ -1,4 +1,4 @@ -//! SeaORM Entity. Generated by sea-orm-codegen 0.9.3 +//! `SeaORM` Entity. Generated by sea-orm-codegen 0.11.3 pub mod prelude; @@ -10,6 +10,7 @@ pub mod asset_grouping; pub mod asset_v1_account_attachments; pub mod backfill_items; pub mod cl_audits; +pub mod cl_audits_v2; pub mod cl_items; pub mod raw_txn; pub mod sea_orm_active_enums; diff --git a/digital_asset_types/src/dao/generated/prelude.rs b/digital_asset_types/src/dao/generated/prelude.rs index 79759cd1c..e70fd1611 100644 --- a/digital_asset_types/src/dao/generated/prelude.rs +++ b/digital_asset_types/src/dao/generated/prelude.rs @@ -1,4 +1,4 @@ -//! SeaORM Entity. Generated by sea-orm-codegen 0.9.3 +//! `SeaORM` Entity. Generated by sea-orm-codegen 0.11.3 pub use super::asset::Entity as Asset; pub use super::asset_authority::Entity as AssetAuthority; @@ -7,7 +7,7 @@ pub use super::asset_data::Entity as AssetData; pub use super::asset_grouping::Entity as AssetGrouping; pub use super::asset_v1_account_attachments::Entity as AssetV1AccountAttachments; pub use super::backfill_items::Entity as BackfillItems; -pub use super::cl_audits::Entity as ClAudits; +pub use super::cl_audits_v2::Entity as ClAuditsV2; pub use super::cl_items::Entity as ClItems; pub use super::raw_txn::Entity as RawTxn; pub use super::tasks::Entity as Tasks; diff --git a/digital_asset_types/src/dao/generated/sea_orm_active_enums.rs b/digital_asset_types/src/dao/generated/sea_orm_active_enums.rs index 2be0283e7..3f8c21c94 100644 --- a/digital_asset_types/src/dao/generated/sea_orm_active_enums.rs +++ b/digital_asset_types/src/dao/generated/sea_orm_active_enums.rs @@ -123,3 +123,80 @@ pub enum OwnerType { #[sea_orm(string_value = "unknown")] Unknown, } + +#[derive(Debug, Clone, PartialEq, EnumIter, DeriveActiveEnum, Serialize, Deserialize)] +#[sea_orm(rs_type = "String", db_type = "Enum", enum_name = "instruction")] +pub enum Instruction { + #[sea_orm(string_value = "burn")] + Burn, + #[sea_orm(string_value = "cancel_redeem")] + CancelRedeem, + #[sea_orm(string_value = "compress")] + Compress, + #[sea_orm(string_value = "decompress_v1")] + DecompressV1, + #[sea_orm(string_value = "delegate")] + Delegate, + #[sea_orm(string_value = "mint_to_collection_v1")] + MintToCollectionV1, + #[sea_orm(string_value = "mint_v1")] + MintV1, + #[sea_orm(string_value = "redeem")] + Redeem, + #[sea_orm(string_value = "set_and_verify_collection")] + SetAndVerifyCollection, + #[sea_orm(string_value = "transfer")] + Transfer, + #[sea_orm(string_value = "unknown")] + Unknown, + #[sea_orm(string_value = "unverify_collection")] + UnverifyCollection, + #[sea_orm(string_value = "unverify_creator")] + UnverifyCreator, + #[sea_orm(string_value = "verify_collection")] + VerifyCollection, + #[sea_orm(string_value = "verify_creator")] + VerifyCreator, +} +// Added manually for convenience. +impl Instruction { + pub fn from_str(s: &str) -> Self { + match s { + "Burn" => Instruction::Burn, + "CancelRedeem" => Instruction::CancelRedeem, + "Compress" => Instruction::Compress, + "DecompressV1" => Instruction::DecompressV1, + "Delegate" => Instruction::Delegate, + "MintToCollectionV1" => Instruction::MintToCollectionV1, + "MintV1" => Instruction::MintV1, + "Redeem" => Instruction::Redeem, + "SetAndVerifyCollection" => Instruction::SetAndVerifyCollection, + "Transfer" => Instruction::Transfer, + "UnverifyCollection" => Instruction::UnverifyCollection, + "UnverifyCreator" => Instruction::UnverifyCreator, + "VerifyCollection" => Instruction::VerifyCollection, + "VerifyCreator" => Instruction::VerifyCreator, + _ => Instruction::Unknown, + } + } + + pub fn to_str(s: &Self) -> &str { + match s { + Instruction::Burn => "Burn", + Instruction::CancelRedeem => "CancelReddem", + Instruction::Compress => "Compress", + Instruction::DecompressV1 => "DecompressV1", + Instruction::Delegate => "Delegate", + Instruction::MintToCollectionV1 => "MintToCollectionV1", + Instruction::MintV1 => "MintV1", + Instruction::Redeem => "Redeem", + Instruction::SetAndVerifyCollection => "SetAndVerifyCollection", + Instruction::Transfer => "Transfer", + Instruction::UnverifyCollection => "UnverifyCollection", + Instruction::UnverifyCreator => "UnverifyCreator", + Instruction::VerifyCollection => "VerifyCollection", + Instruction::VerifyCreator => "VerifyCreator", + _ => "Unknown", + } + } +}