Skip to content

Commit

Permalink
Merge branch 'main' into cl_audits_upstream
Browse files Browse the repository at this point in the history
  • Loading branch information
linuskendall authored Jul 27, 2023
2 parents 1866282 + 3ca1303 commit 515ff53
Show file tree
Hide file tree
Showing 45 changed files with 1,312 additions and 542 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ Then with a local `DATABASE_URL` var exported like this `export DATABASE_URL=pos

If you need to install `sea-orm-cli` run `cargo install sea-orm-cli`.

Note: The current SeaORM types were generated using version 0.9.3 so unless you want to upgrade you can install using `cargo install sea-orm-cli --version 0.9.3`.

Also note: The migration `m20230224_093722_performance_improvements` needs to be commented out of the migration lib.rs in order for the Sea ORM `Relations` to generate correctly.

#### Developing Locally
*Prerequisites*
* A Postgres Server running with the database setup according to ./init.sql
Expand Down
4 changes: 1 addition & 3 deletions das_api/src/api/api_impl.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
use std::vec;

use digital_asset_types::{
dao::{
scopes::asset::get_grouping,
Expand Down Expand Up @@ -356,7 +354,7 @@ impl ApiContract for DasApi {
} = payload;
let gs = get_grouping(&self.db_connection, group_key.clone(), group_value.clone()).await?;
Ok(GetGroupingResponse {
group_key: group_key,
group_key,
group_name: group_value,
group_size: gs.size,
})
Expand Down
2 changes: 1 addition & 1 deletion das_api/src/api/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::{DasApiError, RpcModule};
use crate::DasApiError;
use async_trait::async_trait;
use digital_asset_types::rpc::filter::SearchConditionType;
use digital_asset_types::rpc::response::AssetList;
Expand Down
4 changes: 2 additions & 2 deletions das_api/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ mod config;
mod error;
mod validation;

use std::time::{Duration, Instant};
use std::time::Instant;
use {
crate::api::DasApi,
crate::builder::RpcApiBuilder,
Expand All @@ -17,7 +17,7 @@ use {
std::net::UdpSocket,
};

use hyper::{http, Method};
use hyper::Method;
use log::{debug, info};
use tower_http::cors::{Any, CorsLayer};

Expand Down
41 changes: 25 additions & 16 deletions digital_asset_types/src/dao/generated/asset.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ impl EntityName for Entity {
pub struct Model {
pub id: Vec<u8>,
pub alt_id: Option<Vec<u8>>,
pub specification_version: SpecificationVersions,
pub specification_asset_class: SpecificationAssetClass,
pub specification_version: Option<SpecificationVersions>,
pub specification_asset_class: Option<SpecificationAssetClass>,
pub owner: Option<Vec<u8>>,
pub owner_type: OwnerType,
pub delegate: Option<Vec<u8>>,
Expand All @@ -30,19 +30,22 @@ pub struct Model {
pub supply_mint: Option<Vec<u8>>,
pub compressed: bool,
pub compressible: bool,
pub seq: i64,
pub seq: Option<i64>,
pub tree_id: Option<Vec<u8>>,
pub leaf: Option<Vec<u8>>,
pub nonce: i64,
pub nonce: Option<i64>,
pub royalty_target_type: RoyaltyTargetType,
pub royalty_target: Option<Vec<u8>>,
pub royalty_amount: i32,
pub asset_data: Option<Vec<u8>>,
pub created_at: Option<DateTimeWithTimeZone>,
pub burnt: bool,
pub slot_updated: i64,
pub slot_updated: Option<i64>,
pub data_hash: Option<String>,
pub creator_hash: Option<String>,
pub owner_delegate_seq: Option<i64>,
pub was_decompressed: bool,
pub leaf_seq: Option<i64>,
}

#[derive(Copy, Clone, Debug, EnumIter, DeriveColumn)]
Expand Down Expand Up @@ -72,6 +75,9 @@ pub enum Column {
SlotUpdated,
DataHash,
CreatorHash,
OwnerDelegateSeq,
WasDecompressed,
LeafSeq,
}

#[derive(Copy, Clone, Debug, EnumIter, DerivePrimaryKey)]
Expand All @@ -91,8 +97,8 @@ pub enum Relation {
AssetData,
AssetV1AccountAttachments,
AssetCreators,
AssetGrouping,
AssetAuthority,
AssetGrouping,
}

impl ColumnTrait for Column {
Expand All @@ -101,8 +107,8 @@ impl ColumnTrait for Column {
match self {
Self::Id => ColumnType::Binary.def(),
Self::AltId => ColumnType::Binary.def().null(),
Self::SpecificationVersion => SpecificationVersions::db_type(),
Self::SpecificationAssetClass => SpecificationAssetClass::db_type(),
Self::SpecificationVersion => SpecificationVersions::db_type().null(),
Self::SpecificationAssetClass => SpecificationAssetClass::db_type().null(),
Self::Owner => ColumnType::Binary.def().null(),
Self::OwnerType => OwnerType::db_type(),
Self::Delegate => ColumnType::Binary.def().null(),
Expand All @@ -111,19 +117,22 @@ impl ColumnTrait for Column {
Self::SupplyMint => ColumnType::Binary.def().null(),
Self::Compressed => ColumnType::Boolean.def(),
Self::Compressible => ColumnType::Boolean.def(),
Self::Seq => ColumnType::BigInteger.def(),
Self::Seq => ColumnType::BigInteger.def().null(),
Self::TreeId => ColumnType::Binary.def().null(),
Self::Leaf => ColumnType::Binary.def().null(),
Self::Nonce => ColumnType::BigInteger.def(),
Self::Nonce => ColumnType::BigInteger.def().null(),
Self::RoyaltyTargetType => RoyaltyTargetType::db_type(),
Self::RoyaltyTarget => ColumnType::Binary.def().null(),
Self::RoyaltyAmount => ColumnType::Integer.def(),
Self::AssetData => ColumnType::Binary.def().null(),
Self::CreatedAt => ColumnType::TimestampWithTimeZone.def().null(),
Self::Burnt => ColumnType::Boolean.def(),
Self::SlotUpdated => ColumnType::BigInteger.def(),
Self::SlotUpdated => ColumnType::BigInteger.def().null(),
Self::DataHash => ColumnType::Char(Some(50u32)).def().null(),
Self::CreatorHash => ColumnType::Char(Some(50u32)).def().null(),
Self::OwnerDelegateSeq => ColumnType::BigInteger.def().null(),
Self::WasDecompressed => ColumnType::Boolean.def(),
Self::LeafSeq => ColumnType::BigInteger.def().null(),
}
}
}
Expand All @@ -139,8 +148,8 @@ impl RelationTrait for Relation {
Entity::has_many(super::asset_v1_account_attachments::Entity).into()
}
Self::AssetCreators => Entity::has_many(super::asset_creators::Entity).into(),
Self::AssetGrouping => Entity::has_many(super::asset_grouping::Entity).into(),
Self::AssetAuthority => Entity::has_many(super::asset_authority::Entity).into(),
Self::AssetGrouping => Entity::has_many(super::asset_grouping::Entity).into(),
}
}
}
Expand All @@ -163,15 +172,15 @@ impl Related<super::asset_creators::Entity> for Entity {
}
}

impl Related<super::asset_grouping::Entity> for Entity {
impl Related<super::asset_authority::Entity> for Entity {
fn to() -> RelationDef {
Relation::AssetGrouping.def()
Relation::AssetAuthority.def()
}
}

impl Related<super::asset_authority::Entity> for Entity {
impl Related<super::asset_grouping::Entity> for Entity {
fn to() -> RelationDef {
Relation::AssetAuthority.def()
Relation::AssetGrouping.def()
}
}

Expand Down
8 changes: 4 additions & 4 deletions digital_asset_types/src/dao/generated/asset_creators.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ pub struct Model {
pub creator: Vec<u8>,
pub share: i32,
pub verified: bool,
pub seq: i64,
pub slot_updated: i64,
pub seq: Option<i64>,
pub slot_updated: Option<i64>,
pub position: i16,
}

Expand Down Expand Up @@ -62,8 +62,8 @@ impl ColumnTrait for Column {
Self::Creator => ColumnType::Binary.def(),
Self::Share => ColumnType::Integer.def(),
Self::Verified => ColumnType::Boolean.def(),
Self::Seq => ColumnType::BigInteger.def(),
Self::SlotUpdated => ColumnType::BigInteger.def(),
Self::Seq => ColumnType::BigInteger.def().null(),
Self::SlotUpdated => ColumnType::BigInteger.def().null(),
Self::Position => ColumnType::SmallInteger.def(),
}
}
Expand Down
18 changes: 12 additions & 6 deletions digital_asset_types/src/dao/generated/asset_grouping.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,11 @@ pub struct Model {
pub id: i64,
pub asset_id: Vec<u8>,
pub group_key: String,
pub group_value: String,
pub seq: i64,
pub slot_updated: i64,
pub group_value: Option<String>,
pub seq: Option<i64>,
pub slot_updated: Option<i64>,
pub verified: bool,
pub group_info_seq: Option<i64>,
}

#[derive(Copy, Clone, Debug, EnumIter, DeriveColumn)]
Expand All @@ -30,6 +32,8 @@ pub enum Column {
GroupValue,
Seq,
SlotUpdated,
Verified,
GroupInfoSeq,
}

#[derive(Copy, Clone, Debug, EnumIter, DerivePrimaryKey)]
Expand All @@ -56,9 +60,11 @@ impl ColumnTrait for Column {
Self::Id => ColumnType::BigInteger.def(),
Self::AssetId => ColumnType::Binary.def(),
Self::GroupKey => ColumnType::Text.def(),
Self::GroupValue => ColumnType::Text.def(),
Self::Seq => ColumnType::BigInteger.def(),
Self::SlotUpdated => ColumnType::BigInteger.def(),
Self::GroupValue => ColumnType::Text.def().null(),
Self::Seq => ColumnType::BigInteger.def().null(),
Self::SlotUpdated => ColumnType::BigInteger.def().null(),
Self::Verified => ColumnType::Boolean.def(),
Self::GroupInfoSeq => ColumnType::BigInteger.def().null(),
}
}
}
Expand Down
124 changes: 62 additions & 62 deletions digital_asset_types/src/dao/generated/sea_orm_active_enums.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,34 +4,30 @@ use sea_orm::entity::prelude::*;
use serde::{Deserialize, Serialize};

#[derive(Debug, Clone, PartialEq, EnumIter, DeriveActiveEnum, Serialize, Deserialize)]
#[sea_orm(
rs_type = "String",
db_type = "Enum",
enum_name = "specification_versions"
)]
pub enum SpecificationVersions {
#[sea_orm(rs_type = "String", db_type = "Enum", enum_name = "mutability")]
pub enum Mutability {
#[sea_orm(string_value = "immutable")]
Immutable,
#[sea_orm(string_value = "mutable")]
Mutable,
#[sea_orm(string_value = "unknown")]
Unknown,
#[sea_orm(string_value = "v0")]
V0,
#[sea_orm(string_value = "v1")]
V1,
#[sea_orm(string_value = "v2")]
V2,
}
#[derive(Debug, Clone, PartialEq, EnumIter, DeriveActiveEnum, Serialize, Deserialize)]
#[sea_orm(
rs_type = "String",
db_type = "Enum",
enum_name = "royalty_target_type"
enum_name = "v1_account_attachments"
)]
pub enum RoyaltyTargetType {
#[sea_orm(string_value = "creators")]
Creators,
#[sea_orm(string_value = "fanout")]
Fanout,
#[sea_orm(string_value = "single")]
Single,
pub enum V1AccountAttachments {
#[sea_orm(string_value = "edition")]
Edition,
#[sea_orm(string_value = "edition_marker")]
EditionMarker,
#[sea_orm(string_value = "master_edition_v1")]
MasterEditionV1,
#[sea_orm(string_value = "master_edition_v2")]
MasterEditionV2,
#[sea_orm(string_value = "unknown")]
Unknown,
}
Expand All @@ -48,50 +44,18 @@ pub enum TaskStatus {
Success,
}
#[derive(Debug, Clone, PartialEq, EnumIter, DeriveActiveEnum, Serialize, Deserialize)]
#[sea_orm(rs_type = "String", db_type = "Enum", enum_name = "chain_mutability")]
pub enum ChainMutability {
#[sea_orm(string_value = "immutable")]
Immutable,
#[sea_orm(string_value = "mutable")]
Mutable,
#[sea_orm(string_value = "unknown")]
Unknown,
}
#[derive(Debug, Clone, PartialEq, EnumIter, DeriveActiveEnum, Serialize, Deserialize)]
#[sea_orm(rs_type = "String", db_type = "Enum", enum_name = "owner_type")]
pub enum OwnerType {
#[sea_orm(string_value = "single")]
Single,
#[sea_orm(string_value = "token")]
Token,
#[sea_orm(string_value = "unknown")]
Unknown,
}
#[derive(Debug, Clone, PartialEq, EnumIter, DeriveActiveEnum, Serialize, Deserialize)]
#[sea_orm(rs_type = "String", db_type = "Enum", enum_name = "mutability")]
pub enum Mutability {
#[sea_orm(string_value = "immutable")]
Immutable,
#[sea_orm(string_value = "mutable")]
Mutable,
#[sea_orm(string_value = "unknown")]
Unknown,
}
#[derive(Debug, Clone, PartialEq, EnumIter, DeriveActiveEnum, Serialize, Deserialize)]
#[sea_orm(
rs_type = "String",
db_type = "Enum",
enum_name = "v1_account_attachments"
enum_name = "royalty_target_type"
)]
pub enum V1AccountAttachments {
#[sea_orm(string_value = "edition")]
Edition,
#[sea_orm(string_value = "edition_marker")]
EditionMarker,
#[sea_orm(string_value = "master_edition_v1")]
MasterEditionV1,
#[sea_orm(string_value = "master_edition_v2")]
MasterEditionV2,
pub enum RoyaltyTargetType {
#[sea_orm(string_value = "creators")]
Creators,
#[sea_orm(string_value = "fanout")]
Fanout,
#[sea_orm(string_value = "single")]
Single,
#[sea_orm(string_value = "unknown")]
Unknown,
}
Expand All @@ -116,10 +80,46 @@ pub enum SpecificationAssetClass {
Print,
#[sea_orm(string_value = "PRINTABLE_NFT")]
PrintableNft,
#[sea_orm(string_value = "PROGRAMMABLE_NFT")]
ProgrammableNft,
#[sea_orm(string_value = "TRANSFER_RESTRICTED_NFT")]
TransferRestrictedNft,
#[sea_orm(string_value = "unknown")]
Unknown,
#[sea_orm(string_value = "PNFT")]
ProgrammableNft,
}
#[derive(Debug, Clone, PartialEq, EnumIter, DeriveActiveEnum, Serialize, Deserialize)]
#[sea_orm(rs_type = "String", db_type = "Enum", enum_name = "chain_mutability")]
pub enum ChainMutability {
#[sea_orm(string_value = "immutable")]
Immutable,
#[sea_orm(string_value = "mutable")]
Mutable,
#[sea_orm(string_value = "unknown")]
Unknown,
}
#[derive(Debug, Clone, PartialEq, EnumIter, DeriveActiveEnum, Serialize, Deserialize)]
#[sea_orm(
rs_type = "String",
db_type = "Enum",
enum_name = "specification_versions"
)]
pub enum SpecificationVersions {
#[sea_orm(string_value = "unknown")]
Unknown,
#[sea_orm(string_value = "v0")]
V0,
#[sea_orm(string_value = "v1")]
V1,
#[sea_orm(string_value = "v2")]
V2,
}
#[derive(Debug, Clone, PartialEq, EnumIter, DeriveActiveEnum, Serialize, Deserialize)]
#[sea_orm(rs_type = "String", db_type = "Enum", enum_name = "owner_type")]
pub enum OwnerType {
#[sea_orm(string_value = "single")]
Single,
#[sea_orm(string_value = "token")]
Token,
#[sea_orm(string_value = "unknown")]
Unknown,
}
Loading

0 comments on commit 515ff53

Please sign in to comment.