Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add showFungible option flag to das #215

Open
wants to merge 21 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 20 commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 13 additions & 12 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 29 additions & 0 deletions blockbuster/src/programs/token_extensions/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,42 @@ pub struct MintAccountExtensions {
pub token_group_member: Option<ShadowTokenGroupMember>,
}

impl MintAccountExtensions {
pub fn is_some(&self) -> bool {
self.default_account_state.is_some()
|| self.confidential_transfer_mint.is_some()
|| self.confidential_transfer_account.is_some()
|| self.confidential_transfer_fee_config.is_some()
|| self.interest_bearing_config.is_some()
|| self.transfer_fee_config.is_some()
|| self.mint_close_authority.is_some()
|| self.permanent_delegate.is_some()
|| self.metadata_pointer.is_some()
|| self.metadata.is_some()
|| self.transfer_hook.is_some()
|| self.group_pointer.is_some()
|| self.token_group.is_some()
|| self.group_member_pointer.is_some()
|| self.token_group_member.is_some()
}
}

#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct TokenAccountExtensions {
pub confidential_transfer: Option<ShadowConfidentialTransferAccount>,
pub cpi_guard: Option<ShadowCpiGuard>,
pub memo_transfer: Option<ShadowMemoTransfer>,
pub transfer_fee_amount: Option<ShadowTransferFeeAmount>,
}

impl TokenAccountExtensions {
pub fn is_some(&self) -> bool {
self.confidential_transfer.is_some()
|| self.cpi_guard.is_some()
|| self.memo_transfer.is_some()
|| self.transfer_fee_amount.is_some()
}
}
#[derive(Debug, PartialEq)]
pub struct TokenAccount {
pub account: Account,
Expand Down
15 changes: 14 additions & 1 deletion digital_asset_types/src/dao/extensions/asset.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use crate::dao::{
asset, asset_authority, asset_creators, asset_data, asset_grouping,
asset_v1_account_attachments,
sea_orm_active_enums::{OwnerType, RoyaltyTargetType},
token_accounts,
};

#[derive(Copy, Clone, Debug, EnumIter)]
Expand All @@ -13,6 +14,7 @@ pub enum Relation {
AssetAuthority,
AssetCreators,
AssetGrouping,
TokenAccounts,
}

impl RelationTrait for Relation {
Expand All @@ -22,6 +24,10 @@ impl RelationTrait for Relation {
.from(asset::Column::AssetData)
.to(asset_data::Column::Id)
.into(),
Self::TokenAccounts => asset::Entity::belongs_to(token_accounts::Entity)
.from(asset::Column::Id)
.to(token_accounts::Column::Mint)
.into(),
Self::AssetV1AccountAttachments => {
asset::Entity::has_many(asset_v1_account_attachments::Entity).into()
}
Expand Down Expand Up @@ -62,6 +68,12 @@ impl Related<asset_grouping::Entity> for asset::Entity {
}
}

impl Related<token_accounts::Entity> for asset::Entity {
fn to() -> RelationDef {
Relation::TokenAccounts.def()
}
}

impl Default for RoyaltyTargetType {
fn default() -> Self {
Self::Creators
Expand All @@ -76,7 +88,7 @@ impl Default for asset::Model {
specification_version: None,
specification_asset_class: None,
owner: None,
owner_type: OwnerType::Single,
owner_type: OwnerType::Unknown,
delegate: None,
frozen: Default::default(),
supply: Default::default(),
Expand All @@ -103,6 +115,7 @@ impl Default for asset::Model {
owner_delegate_seq: None,
leaf_seq: None,
base_info_seq: None,
mint_extensions: None,
mpl_core_plugins: None,
mpl_core_unknown_plugins: None,
mpl_core_collection_current_size: None,
Expand Down
1 change: 1 addition & 0 deletions digital_asset_types/src/dao/extensions/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ pub mod asset_data;
pub mod asset_grouping;
pub mod asset_v1_account_attachment;
pub mod instruction;
pub mod token_accounts;
25 changes: 25 additions & 0 deletions digital_asset_types/src/dao/extensions/token_accounts.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
use sea_orm::{EntityTrait, EnumIter, Related, RelationDef, RelationTrait};

use crate::dao::{asset, token_accounts};

#[derive(Copy, Clone, Debug, EnumIter)]
pub enum Relation {
Asset,
}

impl RelationTrait for Relation {
fn def(&self) -> RelationDef {
match self {
Self::Asset => token_accounts::Entity::belongs_to(asset::Entity)
.from(token_accounts::Column::Mint)
.to(asset::Column::Id)
.into(),
}
}
}

impl Related<asset::Entity> for token_accounts::Entity {
fn to() -> RelationDef {
Relation::Asset.def()
}
}
5 changes: 4 additions & 1 deletion digital_asset_types/src/dao/full_asset.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
use crate::dao::{asset, asset_authority, asset_creators, asset_data, asset_grouping};

use super::tokens;

#[derive(Clone, Debug, PartialEq)]
pub struct FullAsset {
pub asset: asset::Model,
pub data: asset_data::Model,
pub data: Option<asset_data::Model>,
pub token_info: Option<tokens::Model>,
pub authorities: Vec<asset_authority::Model>,
pub creators: Vec<asset_creators::Model>,
pub groups: Vec<asset_grouping::Model>,
Expand Down
3 changes: 3 additions & 0 deletions digital_asset_types/src/dao/generated/asset.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ pub struct Model {
pub owner_delegate_seq: Option<i64>,
pub leaf_seq: Option<i64>,
pub base_info_seq: Option<i64>,
pub mint_extensions: Option<Json>,
pub mpl_core_plugins: Option<Json>,
pub mpl_core_unknown_plugins: Option<Json>,
pub mpl_core_collection_num_minted: Option<i32>,
Expand Down Expand Up @@ -93,6 +94,7 @@ pub enum Column {
OwnerDelegateSeq,
LeafSeq,
BaseInfoSeq,
MintExtensions,
MplCorePlugins,
MplCoreUnknownPlugins,
MplCoreCollectionNumMinted,
Expand Down Expand Up @@ -153,6 +155,7 @@ impl ColumnTrait for Column {
Self::OwnerDelegateSeq => ColumnType::BigInteger.def().null(),
Self::LeafSeq => ColumnType::BigInteger.def().null(),
Self::BaseInfoSeq => ColumnType::BigInteger.def().null(),
Self::MintExtensions => ColumnType::JsonBinary.def().null(),
Self::MplCorePlugins => ColumnType::JsonBinary.def().null(),
Self::MplCoreUnknownPlugins => ColumnType::JsonBinary.def().null(),
Self::MplCoreCollectionNumMinted => ColumnType::Integer.def().null(),
Expand Down
3 changes: 3 additions & 0 deletions digital_asset_types/src/dao/generated/token_accounts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ pub struct Model {
pub delegated_amount: i64,
pub slot_updated: i64,
pub token_program: Vec<u8>,
pub extensions: Option<Json>,
}

#[derive(Copy, Clone, Debug, EnumIter, DeriveColumn)]
Expand All @@ -38,6 +39,7 @@ pub enum Column {
DelegatedAmount,
SlotUpdated,
TokenProgram,
Extensions,
}

#[derive(Copy, Clone, Debug, EnumIter, DerivePrimaryKey)]
Expand Down Expand Up @@ -69,6 +71,7 @@ impl ColumnTrait for Column {
Self::DelegatedAmount => ColumnType::BigInteger.def(),
Self::SlotUpdated => ColumnType::BigInteger.def(),
Self::TokenProgram => ColumnType::Binary.def(),
Self::Extensions => ColumnType::Json.def().null(),
}
}
}
Expand Down
13 changes: 13 additions & 0 deletions digital_asset_types/src/dao/generated/tokens.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ pub struct Model {
pub close_authority: Option<Vec<u8>>,
pub extension_data: Option<Vec<u8>>,
pub slot_updated: i64,
pub extensions: Option<Json>,
}

#[derive(Copy, Clone, Debug, EnumIter, DeriveColumn)]
Expand All @@ -36,6 +37,7 @@ pub enum Column {
CloseAuthority,
ExtensionData,
SlotUpdated,
Extensions,
}

#[derive(Copy, Clone, Debug, EnumIter, DerivePrimaryKey)]
Expand Down Expand Up @@ -66,6 +68,7 @@ impl ColumnTrait for Column {
Self::CloseAuthority => ColumnType::Binary.def().null(),
Self::ExtensionData => ColumnType::Binary.def().null(),
Self::SlotUpdated => ColumnType::BigInteger.def(),
Self::Extensions => ColumnType::JsonBinary.def().null(),
}
}
}
Expand All @@ -77,3 +80,13 @@ impl RelationTrait for Relation {
}

impl ActiveModelBehavior for ActiveModel {}

pub trait IsNonFungible {
fn is_non_fungible(&self) -> bool;
}

impl IsNonFungible for Model {
fn is_non_fungible(&self) -> bool {
self.decimals == 0 && self.supply == 1.into()
}
}
Loading