diff --git a/das_api/src/api/api_impl.rs b/das_api/src/api/api_impl.rs index 4b55f43d8..8656e7776 100644 --- a/das_api/src/api/api_impl.rs +++ b/das_api/src/api/api_impl.rs @@ -374,6 +374,7 @@ impl ApiContract for DasApi { negate, condition_type, interface, + token_type, owner_address, owner_type, creator_address, @@ -403,7 +404,7 @@ impl ApiContract for DasApi { // Deserialize search assets query let spec: Option<(SpecificationVersions, SpecificationAssetClass)> = - interface.map(|x| x.into()); + interface.clone().map(|x| x.into()); let specification_version = spec.clone().map(|x| x.0); let specification_asset_class = spec.map(|x| x.1); let condition_type = condition_type.map(|x| match x { @@ -431,8 +432,10 @@ impl ApiContract for DasApi { let saq = SearchAssetsQuery { negate, condition_type, + interface, specification_version, specification_asset_class, + token_type, owner_address, owner_type, creator_address, diff --git a/das_api/src/api/mod.rs b/das_api/src/api/mod.rs index 2e1da73ca..cbfc18e9a 100644 --- a/das_api/src/api/mod.rs +++ b/das_api/src/api/mod.rs @@ -1,6 +1,6 @@ use crate::error::DasApiError; use async_trait::async_trait; -use digital_asset_types::rpc::filter::{AssetSortDirection, SearchConditionType}; +use digital_asset_types::rpc::filter::{AssetSortDirection, SearchConditionType, TokenTypeClass}; use digital_asset_types::rpc::options::Options; use digital_asset_types::rpc::response::{AssetList, TransactionSignatureList}; use digital_asset_types::rpc::{filter::AssetSorting, response::GetGroupingResponse}; @@ -94,6 +94,7 @@ pub struct SearchAssets { pub negate: Option, pub condition_type: Option, pub interface: Option, + pub token_type: Option, pub owner_address: Option, pub owner_type: Option, pub creator_address: Option, diff --git a/digital_asset_types/src/dao/extensions/asset.rs b/digital_asset_types/src/dao/extensions/asset.rs index ace692d7e..1d8e7f1d3 100644 --- a/digital_asset_types/src/dao/extensions/asset.rs +++ b/digital_asset_types/src/dao/extensions/asset.rs @@ -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)] @@ -13,6 +14,7 @@ pub enum Relation { AssetAuthority, AssetCreators, AssetGrouping, + TokenAccounts, } impl RelationTrait for Relation { @@ -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() } @@ -62,6 +68,12 @@ impl Related for asset::Entity { } } +impl Related for asset::Entity { + fn to() -> RelationDef { + Relation::TokenAccounts.def() + } +} + impl Default for RoyaltyTargetType { fn default() -> Self { Self::Creators diff --git a/digital_asset_types/src/dao/extensions/mod.rs b/digital_asset_types/src/dao/extensions/mod.rs index bcfc3e130..af3baad66 100644 --- a/digital_asset_types/src/dao/extensions/mod.rs +++ b/digital_asset_types/src/dao/extensions/mod.rs @@ -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; diff --git a/digital_asset_types/src/dao/extensions/token_accounts.rs b/digital_asset_types/src/dao/extensions/token_accounts.rs new file mode 100644 index 000000000..a8c8f60eb --- /dev/null +++ b/digital_asset_types/src/dao/extensions/token_accounts.rs @@ -0,0 +1,26 @@ +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 for token_accounts::Entity { + fn to() -> RelationDef { + Relation::Asset.def() + } +} diff --git a/digital_asset_types/src/dao/mod.rs b/digital_asset_types/src/dao/mod.rs index bf1e540ab..8e6dc4ecb 100644 --- a/digital_asset_types/src/dao/mod.rs +++ b/digital_asset_types/src/dao/mod.rs @@ -2,6 +2,8 @@ mod full_asset; mod generated; pub mod scopes; +use crate::rpc::{filter::TokenTypeClass, Interface}; + use self::sea_orm_active_enums::{ OwnerType, RoyaltyTargetType, SpecificationAssetClass, SpecificationVersions, }; @@ -52,8 +54,10 @@ pub struct SearchAssetsQuery { pub negate: Option, /// Defaults to [ConditionType::All] pub condition_type: Option, + pub interface: Option, pub specification_version: Option, pub specification_asset_class: Option, + pub token_type: Option, pub owner_address: Option>, pub owner_type: Option, pub creator_address: Option>, @@ -75,6 +79,33 @@ pub struct SearchAssetsQuery { } impl SearchAssetsQuery { + pub fn check_for_onwer_type_and_token_type(&self) -> Result<(), DbErr> { + if self.token_type.is_some() && self.owner_type.is_some() { + return Err(DbErr::Custom( + "`owner_type` is not supported when using `token_type` field".to_string(), + )); + } + Ok(()) + } + + pub fn check_for_owner_address_and_token_type(&self) -> Result<(), DbErr> { + if self.owner_address.is_none() && self.token_type.is_some() { + return Err(DbErr::Custom( + "Must provide `owner_address` when using `token_type` field".to_string(), + )); + } + Ok(()) + } + pub fn check_for_token_type_and_interface(&self) -> Result<(), DbErr> { + if self.token_type.is_some() && self.interface.is_some() { + return Err(DbErr::Custom( + "`specification_asset_class` is not supported when using `token_type` field" + .to_string(), + )); + } + Ok(()) + } + pub fn conditions(&self) -> Result<(Condition, Vec), DbErr> { let mut conditions = match self.condition_type { // None --> default to all when no option is provided @@ -88,16 +119,38 @@ impl SearchAssetsQuery { .clone() .map(|x| asset::Column::SpecificationVersion.eq(x)), ) - .add_option( + .add_option({ + self.check_for_owner_address_and_token_type()?; + self.check_for_onwer_type_and_token_type()?; + self.token_type.as_ref().map(|x| match x { + TokenTypeClass::Compressed => asset::Column::TreeId.is_not_null(), + TokenTypeClass::Nft => asset::Column::TreeId.is_null().and( + asset::Column::SpecificationAssetClass + .eq(SpecificationAssetClass::Nft) + .or(asset::Column::SpecificationAssetClass + .eq(SpecificationAssetClass::MplCoreAsset)) + .or(asset::Column::SpecificationAssetClass + .eq(SpecificationAssetClass::ProgrammableNft)), + ), + TokenTypeClass::NonFungible => asset::Column::SpecificationAssetClass + .eq(SpecificationAssetClass::Nft) + .or(asset::Column::SpecificationAssetClass + .eq(SpecificationAssetClass::ProgrammableNft)) + .or(asset::Column::SpecificationAssetClass + .eq(SpecificationAssetClass::MplCoreAsset)), + TokenTypeClass::Fungible => asset::Column::SpecificationAssetClass + .eq(SpecificationAssetClass::FungibleAsset) + .or(asset::Column::SpecificationAssetClass + .eq(SpecificationAssetClass::FungibleToken)), + TokenTypeClass::All => asset::Column::SpecificationAssetClass.is_not_null(), + }) + }) + .add_option({ + self.check_for_token_type_and_interface()?; self.specification_asset_class .clone() - .map(|x| asset::Column::SpecificationAssetClass.eq(x)), - ) - .add_option( - self.owner_address - .to_owned() - .map(|x| asset::Column::Owner.eq(x)), - ) + .map(|x| asset::Column::SpecificationAssetClass.eq(x)) + }) .add_option( self.delegate .to_owned() @@ -145,16 +198,34 @@ impl SearchAssetsQuery { if let Some(o) = self.owner_type.clone() { conditions = conditions.add(asset::Column::OwnerType.eq(o)); } else { - // Default to NFTs - // - // In theory, the owner_type=single check should be sufficient, - // however there is an old bug that has marked some non-NFTs as "single" with supply > 1. - // The supply check guarentees we do not include those. - conditions = conditions.add_option(Some( - asset::Column::OwnerType - .eq(OwnerType::Single) - .and(asset::Column::Supply.lte(1)), - )); + match self.token_type { + Some(TokenTypeClass::Fungible) => { + conditions = conditions.add_option(Some( + asset::Column::OwnerType.eq(OwnerType::Token).and( + (asset::Column::SpecificationAssetClass + .eq(SpecificationAssetClass::FungibleToken)) + .or(asset::Column::SpecificationAssetClass + .eq(SpecificationAssetClass::FungibleAsset)), + ), + )); + } + Some(TokenTypeClass::All) => { + conditions = conditions + .add_option(Some(asset::Column::SpecificationAssetClass.is_not_null())); + } + _ => { + // Default to NFTs + // + // In theory, the owner_type=single check should be sufficient, + // however there is an old bug that has marked some non-NFTs as "single" with supply > 1. + // The supply check guarentees we do not include those. + conditions = conditions.add_option(Some( + asset::Column::OwnerType + .eq(OwnerType::Single) + .and(asset::Column::Supply.lte(1)), + )); + } + } } if let Some(c) = self.creator_address.to_owned() { @@ -194,6 +265,25 @@ impl SearchAssetsQuery { joins.push(rel); } + if let Some(o) = self.owner_address.to_owned() { + if self.token_type == Some(TokenTypeClass::Fungible) + || self.token_type == Some(TokenTypeClass::All) + { + conditions = conditions.add(token_accounts::Column::Owner.eq(o)); + let rel = extensions::token_accounts::Relation::Asset + .def() + .rev() + .on_condition(|left, right| { + Expr::tbl(right, token_accounts::Column::Mint) + .eq(Expr::tbl(left, asset::Column::Id)) + .into_condition() + }); + joins.push(rel); + } else { + conditions = conditions.add(asset::Column::Owner.eq(o)); + } + } + if let Some(g) = self.grouping.to_owned() { let cond = Condition::all() .add(asset_grouping::Column::GroupKey.eq(g.0)) diff --git a/digital_asset_types/src/rpc/filter.rs b/digital_asset_types/src/rpc/filter.rs index a471f21fb..e90b4a158 100644 --- a/digital_asset_types/src/rpc/filter.rs +++ b/digital_asset_types/src/rpc/filter.rs @@ -1,4 +1,5 @@ use schemars::JsonSchema; +use sea_orm::entity::prelude::*; use serde::{Deserialize, Serialize}; #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize, JsonSchema)] @@ -31,6 +32,15 @@ pub enum AssetSortBy { None, } +#[derive(Debug, Clone, PartialEq, Eq, EnumIter, Serialize, Deserialize, JsonSchema)] +pub enum TokenTypeClass { + Fungible, + NonFungible, + Compressed, + Nft, + All, +} + #[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize, JsonSchema)] pub enum AssetSortDirection { #[serde(rename = "asc")] diff --git a/integration_tests/tests/data/accounts/search_asset_with_token_type_all/42AYryUGNmJMe9ycBXZekkYvdTehgbtECHs7SLu5JJTB b/integration_tests/tests/data/accounts/search_asset_with_token_type_all/42AYryUGNmJMe9ycBXZekkYvdTehgbtECHs7SLu5JJTB new file mode 100644 index 000000000..17af7f79e Binary files /dev/null and b/integration_tests/tests/data/accounts/search_asset_with_token_type_all/42AYryUGNmJMe9ycBXZekkYvdTehgbtECHs7SLu5JJTB differ diff --git a/integration_tests/tests/data/accounts/search_asset_with_token_type_all/7oSzJpyztTuK124EyPAw2nbF4Vaj2P9MU9vww1QN1k8p b/integration_tests/tests/data/accounts/search_asset_with_token_type_all/7oSzJpyztTuK124EyPAw2nbF4Vaj2P9MU9vww1QN1k8p new file mode 100644 index 000000000..118ca2a0c Binary files /dev/null and b/integration_tests/tests/data/accounts/search_asset_with_token_type_all/7oSzJpyztTuK124EyPAw2nbF4Vaj2P9MU9vww1QN1k8p differ diff --git a/integration_tests/tests/data/accounts/search_asset_with_token_type_all/7sVGLDmpnYqX5EvTg7i3tpRNEugeaUyDC9HtPSb3V3DS b/integration_tests/tests/data/accounts/search_asset_with_token_type_all/7sVGLDmpnYqX5EvTg7i3tpRNEugeaUyDC9HtPSb3V3DS new file mode 100644 index 000000000..05f08bf57 Binary files /dev/null and b/integration_tests/tests/data/accounts/search_asset_with_token_type_all/7sVGLDmpnYqX5EvTg7i3tpRNEugeaUyDC9HtPSb3V3DS differ diff --git a/integration_tests/tests/data/accounts/search_asset_with_token_type_all/8t77ShMViat27Sjphvi1FVPaGrhFcttPAkEnLCFp49Bo b/integration_tests/tests/data/accounts/search_asset_with_token_type_all/8t77ShMViat27Sjphvi1FVPaGrhFcttPAkEnLCFp49Bo new file mode 100644 index 000000000..36feef591 Binary files /dev/null and b/integration_tests/tests/data/accounts/search_asset_with_token_type_all/8t77ShMViat27Sjphvi1FVPaGrhFcttPAkEnLCFp49Bo differ diff --git a/integration_tests/tests/data/accounts/search_asset_with_token_type_all/DVHQquD7pQFUsBoPpW816CU8zQrQCua9mw4Znh9FyKZJ b/integration_tests/tests/data/accounts/search_asset_with_token_type_all/DVHQquD7pQFUsBoPpW816CU8zQrQCua9mw4Znh9FyKZJ new file mode 100644 index 000000000..450366f15 Binary files /dev/null and b/integration_tests/tests/data/accounts/search_asset_with_token_type_all/DVHQquD7pQFUsBoPpW816CU8zQrQCua9mw4Znh9FyKZJ differ diff --git a/integration_tests/tests/data/accounts/search_asset_with_token_type_all/HboN9TsoMSKJAp388G752pSUscb8iZwgdH459KSJxbZT b/integration_tests/tests/data/accounts/search_asset_with_token_type_all/HboN9TsoMSKJAp388G752pSUscb8iZwgdH459KSJxbZT new file mode 100644 index 000000000..db36302a3 Binary files /dev/null and b/integration_tests/tests/data/accounts/search_asset_with_token_type_all/HboN9TsoMSKJAp388G752pSUscb8iZwgdH459KSJxbZT differ diff --git a/integration_tests/tests/data/accounts/search_asset_with_token_type_fungible/6BRNfDfdq1nKyU1TQiCEQLWyPtD8EwUH9Kt2ahsbidUx b/integration_tests/tests/data/accounts/search_asset_with_token_type_fungible/6BRNfDfdq1nKyU1TQiCEQLWyPtD8EwUH9Kt2ahsbidUx new file mode 100644 index 000000000..4311dc97f Binary files /dev/null and b/integration_tests/tests/data/accounts/search_asset_with_token_type_fungible/6BRNfDfdq1nKyU1TQiCEQLWyPtD8EwUH9Kt2ahsbidUx differ diff --git a/integration_tests/tests/data/accounts/search_asset_with_token_type_fungible/7BajpcYgnxmWK91RhrfsdB3Tm83PcDwPvMC8ZinvtTY6 b/integration_tests/tests/data/accounts/search_asset_with_token_type_fungible/7BajpcYgnxmWK91RhrfsdB3Tm83PcDwPvMC8ZinvtTY6 new file mode 100644 index 000000000..c732e2f78 Binary files /dev/null and b/integration_tests/tests/data/accounts/search_asset_with_token_type_fungible/7BajpcYgnxmWK91RhrfsdB3Tm83PcDwPvMC8ZinvtTY6 differ diff --git a/integration_tests/tests/data/accounts/search_asset_with_token_type_fungible/7EYnhQoR9YM3N7UoaKRoA44Uy8JeaZV3qyouov87awMs b/integration_tests/tests/data/accounts/search_asset_with_token_type_fungible/7EYnhQoR9YM3N7UoaKRoA44Uy8JeaZV3qyouov87awMs new file mode 100644 index 000000000..3b72653d8 Binary files /dev/null and b/integration_tests/tests/data/accounts/search_asset_with_token_type_fungible/7EYnhQoR9YM3N7UoaKRoA44Uy8JeaZV3qyouov87awMs differ diff --git a/integration_tests/tests/data/accounts/search_asset_with_token_type_non_fungible/47ackukZJRBkQSufwFnhTkmTzB11Ww8375EDXTwY75wk b/integration_tests/tests/data/accounts/search_asset_with_token_type_non_fungible/47ackukZJRBkQSufwFnhTkmTzB11Ww8375EDXTwY75wk new file mode 100644 index 000000000..d13dae66e Binary files /dev/null and b/integration_tests/tests/data/accounts/search_asset_with_token_type_non_fungible/47ackukZJRBkQSufwFnhTkmTzB11Ww8375EDXTwY75wk differ diff --git a/integration_tests/tests/data/accounts/search_asset_with_token_type_non_fungible/8t77ShMViat27Sjphvi1FVPaGrhFcttPAkEnLCFp49Bo b/integration_tests/tests/data/accounts/search_asset_with_token_type_non_fungible/8t77ShMViat27Sjphvi1FVPaGrhFcttPAkEnLCFp49Bo new file mode 100644 index 000000000..eac706841 Binary files /dev/null and b/integration_tests/tests/data/accounts/search_asset_with_token_type_non_fungible/8t77ShMViat27Sjphvi1FVPaGrhFcttPAkEnLCFp49Bo differ diff --git a/integration_tests/tests/data/accounts/search_asset_with_token_type_non_fungible/AH6VcoSbCGGv8BHeN7K766VUWMcdFRTaXpLvGTLSdAmk b/integration_tests/tests/data/accounts/search_asset_with_token_type_non_fungible/AH6VcoSbCGGv8BHeN7K766VUWMcdFRTaXpLvGTLSdAmk new file mode 100644 index 000000000..47c32c19e Binary files /dev/null and b/integration_tests/tests/data/accounts/search_asset_with_token_type_non_fungible/AH6VcoSbCGGv8BHeN7K766VUWMcdFRTaXpLvGTLSdAmk differ diff --git a/integration_tests/tests/data/accounts/search_asset_with_token_type_non_fungible/DVHQquD7pQFUsBoPpW816CU8zQrQCua9mw4Znh9FyKZJ b/integration_tests/tests/data/accounts/search_asset_with_token_type_non_fungible/DVHQquD7pQFUsBoPpW816CU8zQrQCua9mw4Znh9FyKZJ new file mode 100644 index 000000000..8268e82ec Binary files /dev/null and b/integration_tests/tests/data/accounts/search_asset_with_token_type_non_fungible/DVHQquD7pQFUsBoPpW816CU8zQrQCua9mw4Znh9FyKZJ differ diff --git a/integration_tests/tests/data/accounts/search_asset_with_token_type_non_fungible/ELNshcVjEgQ6nSsogWEQjRTr9EaEHJzKcSenqe2kyx5J b/integration_tests/tests/data/accounts/search_asset_with_token_type_non_fungible/ELNshcVjEgQ6nSsogWEQjRTr9EaEHJzKcSenqe2kyx5J new file mode 100644 index 000000000..6d8ed5e48 Binary files /dev/null and b/integration_tests/tests/data/accounts/search_asset_with_token_type_non_fungible/ELNshcVjEgQ6nSsogWEQjRTr9EaEHJzKcSenqe2kyx5J differ diff --git a/integration_tests/tests/data/accounts/search_asset_with_token_type_non_fungible/HboN9TsoMSKJAp388G752pSUscb8iZwgdH459KSJxbZT b/integration_tests/tests/data/accounts/search_asset_with_token_type_non_fungible/HboN9TsoMSKJAp388G752pSUscb8iZwgdH459KSJxbZT new file mode 100644 index 000000000..f930ec392 Binary files /dev/null and b/integration_tests/tests/data/accounts/search_asset_with_token_type_non_fungible/HboN9TsoMSKJAp388G752pSUscb8iZwgdH459KSJxbZT differ diff --git a/integration_tests/tests/data/accounts/search_asset_with_token_type_regular_nft/2w81QrLYTwSDkNwXgCqKAwrC1Tu6R9mh9BHcxys2Bup2 b/integration_tests/tests/data/accounts/search_asset_with_token_type_regular_nft/2w81QrLYTwSDkNwXgCqKAwrC1Tu6R9mh9BHcxys2Bup2 new file mode 100644 index 000000000..a7efd35f9 Binary files /dev/null and b/integration_tests/tests/data/accounts/search_asset_with_token_type_regular_nft/2w81QrLYTwSDkNwXgCqKAwrC1Tu6R9mh9BHcxys2Bup2 differ diff --git a/integration_tests/tests/data/accounts/search_asset_with_token_type_regular_nft/42AYryUGNmJMe9ycBXZekkYvdTehgbtECHs7SLu5JJTB b/integration_tests/tests/data/accounts/search_asset_with_token_type_regular_nft/42AYryUGNmJMe9ycBXZekkYvdTehgbtECHs7SLu5JJTB new file mode 100644 index 000000000..9c7db2557 Binary files /dev/null and b/integration_tests/tests/data/accounts/search_asset_with_token_type_regular_nft/42AYryUGNmJMe9ycBXZekkYvdTehgbtECHs7SLu5JJTB differ diff --git a/integration_tests/tests/data/accounts/search_asset_with_token_type_regular_nft/7oSzJpyztTuK124EyPAw2nbF4Vaj2P9MU9vww1QN1k8p b/integration_tests/tests/data/accounts/search_asset_with_token_type_regular_nft/7oSzJpyztTuK124EyPAw2nbF4Vaj2P9MU9vww1QN1k8p new file mode 100644 index 000000000..22ba70ff4 Binary files /dev/null and b/integration_tests/tests/data/accounts/search_asset_with_token_type_regular_nft/7oSzJpyztTuK124EyPAw2nbF4Vaj2P9MU9vww1QN1k8p differ diff --git a/integration_tests/tests/data/accounts/search_asset_with_token_type_regular_nft/7sVGLDmpnYqX5EvTg7i3tpRNEugeaUyDC9HtPSb3V3DS b/integration_tests/tests/data/accounts/search_asset_with_token_type_regular_nft/7sVGLDmpnYqX5EvTg7i3tpRNEugeaUyDC9HtPSb3V3DS new file mode 100644 index 000000000..dc785fa4b Binary files /dev/null and b/integration_tests/tests/data/accounts/search_asset_with_token_type_regular_nft/7sVGLDmpnYqX5EvTg7i3tpRNEugeaUyDC9HtPSb3V3DS differ diff --git a/integration_tests/tests/data/accounts/search_asset_with_token_type_regular_nft/CyyZ43boZTaP4mJsbTVUpinFJGMQXSMstJvDeatpEo4S b/integration_tests/tests/data/accounts/search_asset_with_token_type_regular_nft/CyyZ43boZTaP4mJsbTVUpinFJGMQXSMstJvDeatpEo4S new file mode 100644 index 000000000..a75763c95 Binary files /dev/null and b/integration_tests/tests/data/accounts/search_asset_with_token_type_regular_nft/CyyZ43boZTaP4mJsbTVUpinFJGMQXSMstJvDeatpEo4S differ diff --git a/integration_tests/tests/data/accounts/search_asset_with_token_type_regular_nft/iRjBSW4tnw42qxf3tycTYKki1d4bcETt9AfjEwoHYgy b/integration_tests/tests/data/accounts/search_asset_with_token_type_regular_nft/iRjBSW4tnw42qxf3tycTYKki1d4bcETt9AfjEwoHYgy new file mode 100644 index 000000000..dc89d878f Binary files /dev/null and b/integration_tests/tests/data/accounts/search_asset_with_token_type_regular_nft/iRjBSW4tnw42qxf3tycTYKki1d4bcETt9AfjEwoHYgy differ diff --git a/integration_tests/tests/data/largest_token_account_ids/2w81QrLYTwSDkNwXgCqKAwrC1Tu6R9mh9BHcxys2Bup2/2w81QrLYTwSDkNwXgCqKAwrC1Tu6R9mh9BHcxys2Bup2 b/integration_tests/tests/data/largest_token_account_ids/2w81QrLYTwSDkNwXgCqKAwrC1Tu6R9mh9BHcxys2Bup2/2w81QrLYTwSDkNwXgCqKAwrC1Tu6R9mh9BHcxys2Bup2 new file mode 100644 index 000000000..3dc3aa9c3 --- /dev/null +++ b/integration_tests/tests/data/largest_token_account_ids/2w81QrLYTwSDkNwXgCqKAwrC1Tu6R9mh9BHcxys2Bup2/2w81QrLYTwSDkNwXgCqKAwrC1Tu6R9mh9BHcxys2Bup2 @@ -0,0 +1,2 @@ + +Ÿ9mRi\꠽] \ No newline at end of file diff --git a/integration_tests/tests/data/largest_token_account_ids/42AYryUGNmJMe9ycBXZekkYvdTehgbtECHs7SLu5JJTB/42AYryUGNmJMe9ycBXZekkYvdTehgbtECHs7SLu5JJTB b/integration_tests/tests/data/largest_token_account_ids/42AYryUGNmJMe9ycBXZekkYvdTehgbtECHs7SLu5JJTB/42AYryUGNmJMe9ycBXZekkYvdTehgbtECHs7SLu5JJTB new file mode 100644 index 000000000..c9241fcba --- /dev/null +++ b/integration_tests/tests/data/largest_token_account_ids/42AYryUGNmJMe9ycBXZekkYvdTehgbtECHs7SLu5JJTB/42AYryUGNmJMe9ycBXZekkYvdTehgbtECHs7SLu5JJTB @@ -0,0 +1,2 @@ +e 9;:$fEvKA +\%. \ No newline at end of file diff --git a/integration_tests/tests/data/largest_token_account_ids/8t77ShMViat27Sjphvi1FVPaGrhFcttPAkEnLCFp49Bo/8t77ShMViat27Sjphvi1FVPaGrhFcttPAkEnLCFp49Bo b/integration_tests/tests/data/largest_token_account_ids/8t77ShMViat27Sjphvi1FVPaGrhFcttPAkEnLCFp49Bo/8t77ShMViat27Sjphvi1FVPaGrhFcttPAkEnLCFp49Bo new file mode 100644 index 000000000..eb66ffa10 Binary files /dev/null and b/integration_tests/tests/data/largest_token_account_ids/8t77ShMViat27Sjphvi1FVPaGrhFcttPAkEnLCFp49Bo/8t77ShMViat27Sjphvi1FVPaGrhFcttPAkEnLCFp49Bo differ diff --git a/integration_tests/tests/data/largest_token_account_ids/AH6VcoSbCGGv8BHeN7K766VUWMcdFRTaXpLvGTLSdAmk/AH6VcoSbCGGv8BHeN7K766VUWMcdFRTaXpLvGTLSdAmk b/integration_tests/tests/data/largest_token_account_ids/AH6VcoSbCGGv8BHeN7K766VUWMcdFRTaXpLvGTLSdAmk/AH6VcoSbCGGv8BHeN7K766VUWMcdFRTaXpLvGTLSdAmk new file mode 100644 index 000000000..7bc1e9a00 --- /dev/null +++ b/integration_tests/tests/data/largest_token_account_ids/AH6VcoSbCGGv8BHeN7K766VUWMcdFRTaXpLvGTLSdAmk/AH6VcoSbCGGv8BHeN7K766VUWMcdFRTaXpLvGTLSdAmk @@ -0,0 +1 @@ +.BQ*pp-Ug> \ No newline at end of file diff --git a/integration_tests/tests/data/transactions/search_asset_with_token_type_compressed/4URwUGBjbsF7UBUYdSC546tnBy7nD67txsso8D9CR9kGLtbbYh9NkGw15tEp16LLasmJX5VQR4Seh8gDjTrtdpoC b/integration_tests/tests/data/transactions/search_asset_with_token_type_compressed/4URwUGBjbsF7UBUYdSC546tnBy7nD67txsso8D9CR9kGLtbbYh9NkGw15tEp16LLasmJX5VQR4Seh8gDjTrtdpoC new file mode 100644 index 000000000..a9f81afe7 Binary files /dev/null and b/integration_tests/tests/data/transactions/search_asset_with_token_type_compressed/4URwUGBjbsF7UBUYdSC546tnBy7nD67txsso8D9CR9kGLtbbYh9NkGw15tEp16LLasmJX5VQR4Seh8gDjTrtdpoC differ diff --git a/integration_tests/tests/data/transactions/search_asset_with_token_type_compressed/4nKDSvw2kGpccZWLEPnfdP7J1SEexQFRP3xWc9NBtQ1qQeGu3bu5WnAdpcLbjQ4iyX6BQ5QGF69wevE8ZeeY5poA b/integration_tests/tests/data/transactions/search_asset_with_token_type_compressed/4nKDSvw2kGpccZWLEPnfdP7J1SEexQFRP3xWc9NBtQ1qQeGu3bu5WnAdpcLbjQ4iyX6BQ5QGF69wevE8ZeeY5poA new file mode 100644 index 000000000..23b8337f4 Binary files /dev/null and b/integration_tests/tests/data/transactions/search_asset_with_token_type_compressed/4nKDSvw2kGpccZWLEPnfdP7J1SEexQFRP3xWc9NBtQ1qQeGu3bu5WnAdpcLbjQ4iyX6BQ5QGF69wevE8ZeeY5poA differ diff --git a/integration_tests/tests/integration_tests/main.rs b/integration_tests/tests/integration_tests/main.rs index 399b6e583..83fb3eb8a 100644 --- a/integration_tests/tests/integration_tests/main.rs +++ b/integration_tests/tests/integration_tests/main.rs @@ -5,3 +5,4 @@ mod fungibles_and_token_extensions_tests; mod general_scenario_tests; mod mpl_core_tests; mod regular_nft_tests; +mod token_type_test; diff --git a/integration_tests/tests/integration_tests/snapshots/integration_tests__token_type_test__search_asset_with_token_type_all.snap b/integration_tests/tests/integration_tests/snapshots/integration_tests__token_type_test__search_asset_with_token_type_all.snap new file mode 100644 index 000000000..6d58cd939 --- /dev/null +++ b/integration_tests/tests/integration_tests/snapshots/integration_tests__token_type_test__search_asset_with_token_type_all.snap @@ -0,0 +1,148 @@ +--- +source: integration_tests/tests/integration_tests/token_type_test.rs +expression: response +snapshot_kind: text +--- +{ + "total": 2, + "limit": 2, + "page": 1, + "items": [ + { + "interface": "ProgrammableNFT", + "id": "8t77ShMViat27Sjphvi1FVPaGrhFcttPAkEnLCFp49Bo", + "content": { + "$schema": "https://schema.metaplex.com/nft1.0.json", + "json_uri": "https://cdn.hellomoon.io/public/silicons/metadata/1466.json", + "files": [], + "metadata": { + "name": "SILICON #1466", + "symbol": "SILI", + "token_standard": "ProgrammableNonFungible" + }, + "links": {} + }, + "authorities": [ + { + "address": "A2QW89tFNDkkdvJv671tdknAyA21u6hvS7HTUyeMWnf3", + "scopes": [ + "full" + ] + } + ], + "compression": { + "eligible": false, + "compressed": false, + "data_hash": "", + "creator_hash": "", + "asset_hash": "", + "tree": "", + "seq": 0, + "leaf_id": 0 + }, + "grouping": [ + { + "group_key": "collection", + "group_value": "HS1oygRKNBG1nMqjSmaBXSQqQ7apWr14gUU4pW3aDMCP" + } + ], + "royalty": { + "royalty_model": "creators", + "target": null, + "percent": 0.05, + "basis_points": 500, + "primary_sale_happened": true, + "locked": false + }, + "creators": [ + { + "address": "8X2e7Lf3wmA9RPHpPH73kmTqqHHyZE9BcED6Y6TWaZCx", + "share": 0, + "verified": true + }, + { + "address": "5bTgyaCCRNCem3DZXxdRREyesduc6adqwks8rRWGXx8D", + "share": 100, + "verified": false + } + ], + "ownership": { + "frozen": true, + "delegated": true, + "delegate": "D98f1ebFe6kfZTcztLo1iPeKAwogbWHAgXzgSpdRDiu7", + "ownership_model": "single", + "owner": "2oerfxddTpK5hWAmCMYB6fr9WvNrjEH54CHCWK8sAq7g" + }, + "mutable": true, + "burnt": false + }, + { + "interface": "ProgrammableNFT", + "id": "42AYryUGNmJMe9ycBXZekkYvdTehgbtECHs7SLu5JJTB", + "content": { + "$schema": "https://schema.metaplex.com/nft1.0.json", + "json_uri": "https://cdn.hellomoon.io/public/silicons/metadata/2835.json", + "files": [], + "metadata": { + "name": "SILICON #2835", + "symbol": "SILI", + "token_standard": "ProgrammableNonFungible" + }, + "links": {} + }, + "authorities": [ + { + "address": "A2QW89tFNDkkdvJv671tdknAyA21u6hvS7HTUyeMWnf3", + "scopes": [ + "full" + ] + } + ], + "compression": { + "eligible": false, + "compressed": false, + "data_hash": "", + "creator_hash": "", + "asset_hash": "", + "tree": "", + "seq": 0, + "leaf_id": 0 + }, + "grouping": [ + { + "group_key": "collection", + "group_value": "HS1oygRKNBG1nMqjSmaBXSQqQ7apWr14gUU4pW3aDMCP" + } + ], + "royalty": { + "royalty_model": "creators", + "target": null, + "percent": 0.05, + "basis_points": 500, + "primary_sale_happened": true, + "locked": false + }, + "creators": [ + { + "address": "8X2e7Lf3wmA9RPHpPH73kmTqqHHyZE9BcED6Y6TWaZCx", + "share": 0, + "verified": true + }, + { + "address": "5bTgyaCCRNCem3DZXxdRREyesduc6adqwks8rRWGXx8D", + "share": 100, + "verified": false + } + ], + "ownership": { + "frozen": true, + "delegated": true, + "delegate": "D98f1ebFe6kfZTcztLo1iPeKAwogbWHAgXzgSpdRDiu7", + "ownership_model": "single", + "owner": "2oerfxddTpK5hWAmCMYB6fr9WvNrjEH54CHCWK8sAq7g" + }, + "mutable": true, + "burnt": false + } + ] +} diff --git a/integration_tests/tests/integration_tests/snapshots/integration_tests__token_type_test__search_asset_with_token_type_compressed.snap b/integration_tests/tests/integration_tests/snapshots/integration_tests__token_type_test__search_asset_with_token_type_compressed.snap new file mode 100644 index 000000000..59c7dbe8d --- /dev/null +++ b/integration_tests/tests/integration_tests/snapshots/integration_tests__token_type_test__search_asset_with_token_type_compressed.snap @@ -0,0 +1,80 @@ +--- +source: integration_tests/tests/integration_tests/token_type_test.rs +expression: response +snapshot_kind: text +--- +{ + "total": 1, + "limit": 2, + "page": 1, + "items": [ + { + "interface": "V1_NFT", + "id": "7myVr8fEG52mZ3jAwgz88iQRWsuzuVR2nfH8n2AXnBxE", + "content": { + "$schema": "https://schema.metaplex.com/nft1.0.json", + "json_uri": "https://arweave.net/S40vvBVuCvZhAWI3kvk3QreUqVAvR0AaUDObOhB8WIY", + "files": [], + "metadata": { + "name": "Golden Azurite", + "symbol": "OEAs", + "token_standard": "NonFungible" + }, + "links": {} + }, + "authorities": [ + { + "address": "EDAR6p4AUbv9SpD1pDm3gxdSAivdqsHxsf6V9pBc532U", + "scopes": [ + "full" + ] + } + ], + "compression": { + "eligible": false, + "compressed": true, + "data_hash": "B2tu4duCUPequnXh7DxbMnLeLcACHbDCQn3g34s5Cvbx", + "creator_hash": "6UiSCAv4r66MALaqhNE7qdTK84qKk1yJqR4UYtT8qEQ1", + "asset_hash": "8EBnZHUKKB2Vdef34H4L3nxYKkf5RPwCkoHBVLAAM2zN", + "tree": "4r2zZHZvC4Se1KUcCcyCM4ZoFQNGZm2M5FMmUypFocAP", + "seq": 39, + "leaf_id": 5 + }, + "grouping": [ + { + "group_key": "collection", + "group_value": "BwwjnxTHeVWdFieDWmoezta19q1NiwcNNyoon9S38bkM" + } + ], + "royalty": { + "royalty_model": "creators", + "target": null, + "percent": 0.05, + "basis_points": 500, + "primary_sale_happened": true, + "locked": false + }, + "creators": [ + { + "address": "4gETqgEwFLkXX9yk6qBszA6LMjC2kRyyERXsAr2rwhwf", + "share": 100, + "verified": false + } + ], + "ownership": { + "frozen": false, + "delegated": false, + "delegate": null, + "ownership_model": "single", + "owner": "53VVFtLzzi3nL2p1QF591PAB8rbcbsirYepwUphtHU9Q" + }, + "supply": { + "print_max_supply": 0, + "print_current_supply": 0, + "edition_nonce": null + }, + "mutable": true, + "burnt": false + } + ] +} diff --git a/integration_tests/tests/integration_tests/snapshots/integration_tests__token_type_test__search_asset_with_token_type_fungible.snap b/integration_tests/tests/integration_tests/snapshots/integration_tests__token_type_test__search_asset_with_token_type_fungible.snap new file mode 100644 index 000000000..3a0362762 --- /dev/null +++ b/integration_tests/tests/integration_tests/snapshots/integration_tests__token_type_test__search_asset_with_token_type_fungible.snap @@ -0,0 +1,64 @@ +--- +source: integration_tests/tests/integration_tests/token_type_test.rs +expression: response +snapshot_kind: text +--- +{ + "total": 1, + "limit": 1, + "page": 1, + "items": [ + { + "interface": "FungibleToken", + "id": "7EYnhQoR9YM3N7UoaKRoA44Uy8JeaZV3qyouov87awMs", + "content": { + "$schema": "https://schema.metaplex.com/nft1.0.json", + "json_uri": "https://gateway.irys.xyz/P8X64pGutyX5eyTpQmqZr3H4_Lqhm0IYxr5SyzFFNek", + "files": [], + "metadata": { + "name": "Silly Dragon", + "symbol": "SILLY", + "token_standard": "Fungible" + }, + "links": {} + }, + "authorities": [ + { + "address": "38qZKCqcphT5wDrVNJGHYcuenjEtEFPitvrqvMFQkPu7", + "scopes": [ + "full" + ] + } + ], + "compression": { + "eligible": false, + "compressed": false, + "data_hash": "", + "creator_hash": "", + "asset_hash": "", + "tree": "", + "seq": 0, + "leaf_id": 0 + }, + "grouping": [], + "royalty": { + "royalty_model": "creators", + "target": null, + "percent": 0.0, + "basis_points": 0, + "primary_sale_happened": true, + "locked": false + }, + "creators": [], + "ownership": { + "frozen": false, + "delegated": false, + "delegate": null, + "ownership_model": "token", + "owner": "" + }, + "mutable": true, + "burnt": false + } + ] +} diff --git a/integration_tests/tests/integration_tests/snapshots/integration_tests__token_type_test__search_asset_with_token_type_non_fungible.snap b/integration_tests/tests/integration_tests/snapshots/integration_tests__token_type_test__search_asset_with_token_type_non_fungible.snap new file mode 100644 index 000000000..3b14b1809 --- /dev/null +++ b/integration_tests/tests/integration_tests/snapshots/integration_tests__token_type_test__search_asset_with_token_type_non_fungible.snap @@ -0,0 +1,148 @@ +--- +source: integration_tests/tests/integration_tests/token_type_test.rs +expression: response +snapshot_kind: text +--- +{ + "total": 2, + "limit": 2, + "page": 1, + "items": [ + { + "interface": "ProgrammableNFT", + "id": "AH6VcoSbCGGv8BHeN7K766VUWMcdFRTaXpLvGTLSdAmk", + "content": { + "$schema": "https://schema.metaplex.com/nft1.0.json", + "json_uri": "https://cdn.hellomoon.io/public/silicons/metadata/4515.json", + "files": [], + "metadata": { + "name": "SILICON #4515", + "symbol": "SILI", + "token_standard": "ProgrammableNonFungible" + }, + "links": {} + }, + "authorities": [ + { + "address": "A2QW89tFNDkkdvJv671tdknAyA21u6hvS7HTUyeMWnf3", + "scopes": [ + "full" + ] + } + ], + "compression": { + "eligible": false, + "compressed": false, + "data_hash": "", + "creator_hash": "", + "asset_hash": "", + "tree": "", + "seq": 0, + "leaf_id": 0 + }, + "grouping": [ + { + "group_key": "collection", + "group_value": "HS1oygRKNBG1nMqjSmaBXSQqQ7apWr14gUU4pW3aDMCP" + } + ], + "royalty": { + "royalty_model": "creators", + "target": null, + "percent": 0.05, + "basis_points": 500, + "primary_sale_happened": true, + "locked": false + }, + "creators": [ + { + "address": "8X2e7Lf3wmA9RPHpPH73kmTqqHHyZE9BcED6Y6TWaZCx", + "share": 0, + "verified": true + }, + { + "address": "5bTgyaCCRNCem3DZXxdRREyesduc6adqwks8rRWGXx8D", + "share": 100, + "verified": false + } + ], + "ownership": { + "frozen": true, + "delegated": true, + "delegate": "D98f1ebFe6kfZTcztLo1iPeKAwogbWHAgXzgSpdRDiu7", + "ownership_model": "single", + "owner": "2oerfxddTpK5hWAmCMYB6fr9WvNrjEH54CHCWK8sAq7g" + }, + "mutable": true, + "burnt": false + }, + { + "interface": "ProgrammableNFT", + "id": "8t77ShMViat27Sjphvi1FVPaGrhFcttPAkEnLCFp49Bo", + "content": { + "$schema": "https://schema.metaplex.com/nft1.0.json", + "json_uri": "https://cdn.hellomoon.io/public/silicons/metadata/1466.json", + "files": [], + "metadata": { + "name": "SILICON #1466", + "symbol": "SILI", + "token_standard": "ProgrammableNonFungible" + }, + "links": {} + }, + "authorities": [ + { + "address": "A2QW89tFNDkkdvJv671tdknAyA21u6hvS7HTUyeMWnf3", + "scopes": [ + "full" + ] + } + ], + "compression": { + "eligible": false, + "compressed": false, + "data_hash": "", + "creator_hash": "", + "asset_hash": "", + "tree": "", + "seq": 0, + "leaf_id": 0 + }, + "grouping": [ + { + "group_key": "collection", + "group_value": "HS1oygRKNBG1nMqjSmaBXSQqQ7apWr14gUU4pW3aDMCP" + } + ], + "royalty": { + "royalty_model": "creators", + "target": null, + "percent": 0.05, + "basis_points": 500, + "primary_sale_happened": true, + "locked": false + }, + "creators": [ + { + "address": "8X2e7Lf3wmA9RPHpPH73kmTqqHHyZE9BcED6Y6TWaZCx", + "share": 0, + "verified": true + }, + { + "address": "5bTgyaCCRNCem3DZXxdRREyesduc6adqwks8rRWGXx8D", + "share": 100, + "verified": false + } + ], + "ownership": { + "frozen": true, + "delegated": true, + "delegate": "D98f1ebFe6kfZTcztLo1iPeKAwogbWHAgXzgSpdRDiu7", + "ownership_model": "single", + "owner": "2oerfxddTpK5hWAmCMYB6fr9WvNrjEH54CHCWK8sAq7g" + }, + "mutable": true, + "burnt": false + } + ] +} diff --git a/integration_tests/tests/integration_tests/snapshots/integration_tests__token_type_test__search_asset_with_token_type_regular_nft.snap b/integration_tests/tests/integration_tests/snapshots/integration_tests__token_type_test__search_asset_with_token_type_regular_nft.snap new file mode 100644 index 000000000..d8ee5ff5b --- /dev/null +++ b/integration_tests/tests/integration_tests/snapshots/integration_tests__token_type_test__search_asset_with_token_type_regular_nft.snap @@ -0,0 +1,148 @@ +--- +source: integration_tests/tests/integration_tests/token_type_test.rs +expression: response +snapshot_kind: text +--- +{ + "total": 2, + "limit": 2, + "page": 1, + "items": [ + { + "interface": "ProgrammableNFT", + "id": "42AYryUGNmJMe9ycBXZekkYvdTehgbtECHs7SLu5JJTB", + "content": { + "$schema": "https://schema.metaplex.com/nft1.0.json", + "json_uri": "https://cdn.hellomoon.io/public/silicons/metadata/2835.json", + "files": [], + "metadata": { + "name": "SILICON #2835", + "symbol": "SILI", + "token_standard": "ProgrammableNonFungible" + }, + "links": {} + }, + "authorities": [ + { + "address": "A2QW89tFNDkkdvJv671tdknAyA21u6hvS7HTUyeMWnf3", + "scopes": [ + "full" + ] + } + ], + "compression": { + "eligible": false, + "compressed": false, + "data_hash": "", + "creator_hash": "", + "asset_hash": "", + "tree": "", + "seq": 0, + "leaf_id": 0 + }, + "grouping": [ + { + "group_key": "collection", + "group_value": "HS1oygRKNBG1nMqjSmaBXSQqQ7apWr14gUU4pW3aDMCP" + } + ], + "royalty": { + "royalty_model": "creators", + "target": null, + "percent": 0.05, + "basis_points": 500, + "primary_sale_happened": true, + "locked": false + }, + "creators": [ + { + "address": "8X2e7Lf3wmA9RPHpPH73kmTqqHHyZE9BcED6Y6TWaZCx", + "share": 0, + "verified": true + }, + { + "address": "5bTgyaCCRNCem3DZXxdRREyesduc6adqwks8rRWGXx8D", + "share": 100, + "verified": false + } + ], + "ownership": { + "frozen": true, + "delegated": true, + "delegate": "D98f1ebFe6kfZTcztLo1iPeKAwogbWHAgXzgSpdRDiu7", + "ownership_model": "single", + "owner": "2oerfxddTpK5hWAmCMYB6fr9WvNrjEH54CHCWK8sAq7g" + }, + "mutable": true, + "burnt": false + }, + { + "interface": "ProgrammableNFT", + "id": "2w81QrLYTwSDkNwXgCqKAwrC1Tu6R9mh9BHcxys2Bup2", + "content": { + "$schema": "https://schema.metaplex.com/nft1.0.json", + "json_uri": "https://cdn.hellomoon.io/public/silicons/metadata/4685.json", + "files": [], + "metadata": { + "name": "SILICON #4685", + "symbol": "SILI", + "token_standard": "ProgrammableNonFungible" + }, + "links": {} + }, + "authorities": [ + { + "address": "A2QW89tFNDkkdvJv671tdknAyA21u6hvS7HTUyeMWnf3", + "scopes": [ + "full" + ] + } + ], + "compression": { + "eligible": false, + "compressed": false, + "data_hash": "", + "creator_hash": "", + "asset_hash": "", + "tree": "", + "seq": 0, + "leaf_id": 0 + }, + "grouping": [ + { + "group_key": "collection", + "group_value": "HS1oygRKNBG1nMqjSmaBXSQqQ7apWr14gUU4pW3aDMCP" + } + ], + "royalty": { + "royalty_model": "creators", + "target": null, + "percent": 0.05, + "basis_points": 500, + "primary_sale_happened": true, + "locked": false + }, + "creators": [ + { + "address": "8X2e7Lf3wmA9RPHpPH73kmTqqHHyZE9BcED6Y6TWaZCx", + "share": 0, + "verified": true + }, + { + "address": "5bTgyaCCRNCem3DZXxdRREyesduc6adqwks8rRWGXx8D", + "share": 100, + "verified": false + } + ], + "ownership": { + "frozen": true, + "delegated": true, + "delegate": "D98f1ebFe6kfZTcztLo1iPeKAwogbWHAgXzgSpdRDiu7", + "ownership_model": "single", + "owner": "2oerfxddTpK5hWAmCMYB6fr9WvNrjEH54CHCWK8sAq7g" + }, + "mutable": true, + "burnt": false + } + ] +} diff --git a/integration_tests/tests/integration_tests/token_type_test.rs b/integration_tests/tests/integration_tests/token_type_test.rs new file mode 100644 index 000000000..260d92567 --- /dev/null +++ b/integration_tests/tests/integration_tests/token_type_test.rs @@ -0,0 +1,185 @@ +use function_name::named; + +use das_api::api::{self, ApiContract}; + +use itertools::Itertools; + +use serial_test::serial; + +use super::common::*; + +#[tokio::test] +#[serial] +#[named] +async fn test_search_asset_with_token_type_regular_nft() { + let name = trim_test_name(function_name!()); + let setup = TestSetup::new_with_options( + name.clone(), + TestSetupOptions { + network: Some(Network::Mainnet), + }, + ) + .await; + + let seeds: Vec = seed_nfts([ + "42AYryUGNmJMe9ycBXZekkYvdTehgbtECHs7SLu5JJTB", + "2w81QrLYTwSDkNwXgCqKAwrC1Tu6R9mh9BHcxys2Bup2", + ]); + + apply_migrations_and_delete_data(setup.db.clone()).await; + index_seed_events(&setup, seeds.iter().collect_vec()).await; + + let request = r#" + { + "ownerAddress": "2oerfxddTpK5hWAmCMYB6fr9WvNrjEH54CHCWK8sAq7g", + "page": 1, + "limit": 2, + "tokenType": "Nft" + } + "#; + + let request: api::SearchAssets = serde_json::from_str(request).unwrap(); + let response = setup.das_api.search_assets(request).await.unwrap(); + insta::assert_json_snapshot!(name, response); +} + +#[tokio::test] +#[serial] +#[named] +async fn test_search_asset_with_token_type_non_fungible() { + let name = trim_test_name(function_name!()); + let setup = TestSetup::new_with_options( + name.clone(), + TestSetupOptions { + network: Some(Network::Mainnet), + }, + ) + .await; + + let seeds: Vec = seed_nfts([ + "AH6VcoSbCGGv8BHeN7K766VUWMcdFRTaXpLvGTLSdAmk", + "8t77ShMViat27Sjphvi1FVPaGrhFcttPAkEnLCFp49Bo", + ]); + + apply_migrations_and_delete_data(setup.db.clone()).await; + index_seed_events(&setup, seeds.iter().collect_vec()).await; + + let request = r#" + { + "ownerAddress": "2oerfxddTpK5hWAmCMYB6fr9WvNrjEH54CHCWK8sAq7g", + "page": 1, + "limit": 2, + "tokenType": "NonFungible" + } + "#; + + let request: api::SearchAssets = serde_json::from_str(request).unwrap(); + let response = setup.das_api.search_assets(request).await.unwrap(); + insta::assert_json_snapshot!(name, response); +} + +#[tokio::test] +#[serial] +#[named] +async fn test_search_asset_with_token_type_compressed() { + let name = trim_test_name(function_name!()); + let setup = TestSetup::new_with_options( + name.clone(), + TestSetupOptions { + network: Some(Network::Mainnet), + }, + ) + .await; + + let seeds: Vec = seed_txns([ + "4nKDSvw2kGpccZWLEPnfdP7J1SEexQFRP3xWc9NBtQ1qQeGu3bu5WnAdpcLbjQ4iyX6BQ5QGF69wevE8ZeeY5poA", + "4URwUGBjbsF7UBUYdSC546tnBy7nD67txsso8D9CR9kGLtbbYh9NkGw15tEp16LLasmJX5VQR4Seh8gDjTrtdpoC", + ]); + + apply_migrations_and_delete_data(setup.db.clone()).await; + index_seed_events(&setup, seeds.iter().collect_vec()).await; + + let request = r#" + { + "ownerAddress": "53VVFtLzzi3nL2p1QF591PAB8rbcbsirYepwUphtHU9Q", + "page": 1, + "limit": 2, + "tokenType": "Compressed" + } + "#; + + let request: api::SearchAssets = serde_json::from_str(request).unwrap(); + let response = setup.das_api.search_assets(request).await.unwrap(); + insta::assert_json_snapshot!(name, response); +} + +#[tokio::test] +#[serial] +#[named] +async fn test_search_asset_with_token_type_all() { + let name = trim_test_name(function_name!()); + let setup = TestSetup::new_with_options( + name.clone(), + TestSetupOptions { + network: Some(Network::Mainnet), + }, + ) + .await; + + let seeds: Vec = seed_nfts([ + "42AYryUGNmJMe9ycBXZekkYvdTehgbtECHs7SLu5JJTB", + "8t77ShMViat27Sjphvi1FVPaGrhFcttPAkEnLCFp49Bo", + ]); + + apply_migrations_and_delete_data(setup.db.clone()).await; + index_seed_events(&setup, seeds.iter().collect_vec()).await; + + let request = r#" + { + "ownerAddress": "2oerfxddTpK5hWAmCMYB6fr9WvNrjEH54CHCWK8sAq7g", + "page": 1, + "limit": 2, + "tokenType": "All" + } + "#; + + let request: api::SearchAssets = serde_json::from_str(request).unwrap(); + let response = setup.das_api.search_assets(request).await.unwrap(); + insta::assert_json_snapshot!(name, response); +} + +#[tokio::test] +#[serial] +#[named] +async fn test_search_asset_with_token_type_fungible() { + let name = trim_test_name(function_name!()); + let setup = TestSetup::new_with_options( + name.clone(), + TestSetupOptions { + network: Some(Network::Mainnet), + }, + ) + .await; + + let seeds: Vec = seed_accounts([ + "7EYnhQoR9YM3N7UoaKRoA44Uy8JeaZV3qyouov87awMs", + "7BajpcYgnxmWK91RhrfsdB3Tm83PcDwPvMC8ZinvtTY6", + "6BRNfDfdq1nKyU1TQiCEQLWyPtD8EwUH9Kt2ahsbidUx", + ]); + + apply_migrations_and_delete_data(setup.db.clone()).await; + index_seed_events(&setup, seeds.iter().collect_vec()).await; + + let request = r#" + { + "ownerAddress": "2oerfxddTpK5hWAmCMYB6fr9WvNrjEH54CHCWK8sAq7g", + "page": 1, + "limit": 1, + "tokenType": "Fungible" + } + "#; + + let request: api::SearchAssets = serde_json::from_str(request).unwrap(); + let response = setup.das_api.search_assets(request).await.unwrap(); + insta::assert_json_snapshot!(name, response); +}