Skip to content

Commit

Permalink
add types
Browse files Browse the repository at this point in the history
  • Loading branch information
tahsintunan committed Jan 4, 2024
1 parent caa9bdf commit 8b23eb4
Show file tree
Hide file tree
Showing 4 changed files with 155 additions and 3 deletions.
74 changes: 74 additions & 0 deletions digital_asset_types/src/dao/generated/cl_audits_v2.rs
Original file line number Diff line number Diff line change
@@ -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<u8>,
pub leaf_idx: i64,
pub seq: i64,
pub created_at: DateTime,
pub tx: Vec<u8>,
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 {}
3 changes: 2 additions & 1 deletion digital_asset_types/src/dao/generated/mod.rs
Original file line number Diff line number Diff line change
@@ -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;

Expand All @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions digital_asset_types/src/dao/generated/prelude.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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;
Expand Down
77 changes: 77 additions & 0 deletions digital_asset_types/src/dao/generated/sea_orm_active_enums.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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",
}
}
}

0 comments on commit 8b23eb4

Please sign in to comment.