Skip to content

Commit

Permalink
MTG-1245 Rollback some changes
Browse files Browse the repository at this point in the history
  • Loading branch information
andrii-kl committed Jan 24, 2025
1 parent 51fc257 commit a047068
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 39 deletions.
5 changes: 1 addition & 4 deletions entities/src/api_req_params.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,6 @@ pub struct SearchAssetsOptions {
pub show_inscription: bool,
#[serde(default)]
pub show_zero_balance: bool,
/// This option enable adding information about token symbol and price.
#[serde(default)]
pub show_fungible: bool,
}

#[derive(Serialize, Deserialize, Clone, Debug, Eq, PartialEq, JsonSchema, Default)]
Expand Down Expand Up @@ -593,7 +590,7 @@ impl From<SearchAssetsOptions> for GetByMethodsOptions {
show_collection_metadata: value.show_collection_metadata,
show_inscription: value.show_inscription,
show_zero_balance: value.show_zero_balance,
show_fungible: value.show_fungible,
show_fungible: false,
}
}
}
Expand Down
63 changes: 28 additions & 35 deletions nft_ingester/tests/api_tests.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#[cfg(test)]
#[cfg(feature = "integration_tests")]
// #[cfg(feature = "integration_tests")]
mod tests {
use std::{collections::HashMap, str::FromStr, sync::Arc};

Expand Down Expand Up @@ -3202,7 +3202,6 @@ mod tests {
page: Some(1),
owner_address: Some(owner.to_string()),
options: SearchAssetsOptions {
show_fungible: true,
show_zero_balance: true,
show_unverified_collections: true,
..Default::default()
Expand All @@ -3217,29 +3216,31 @@ mod tests {
// so this token contain info about symbol and price
// and 1 non-existed token, so response for it do not include such info
assert_eq!(res.items.len(), 2);
assert_eq!(res.items[0].clone().token_info.unwrap().symbol.unwrap(), "MPLX".to_string());
assert_eq!(
res.items[0].clone().token_info.unwrap().associated_token_address.unwrap(),
fungible_token_account2.to_string()
);
assert_eq!(
res.items[0].clone().token_info.unwrap().price_info.unwrap().currency.unwrap(),
"USDC".to_string()
);
assert!(
res.items[0].clone().token_info.unwrap().price_info.unwrap().total_price.unwrap() > 0.0
);
assert!(
res.items[0].clone().token_info.unwrap().price_info.unwrap().price_per_token.unwrap()
> 0.0
);

assert!(res.items[1].clone().token_info.unwrap().symbol.is_none());
assert!(res.items[1].clone().token_info.unwrap().price_info.is_none());
assert_eq!(
res.items[1].clone().token_info.unwrap().associated_token_address.unwrap(),
fungible_token_account1.to_string()
);
//
// todo MTG-1263 part related to the show_fungible functionality, that shouldn't work for SearchAssets and some work is needed.
// assert_eq!(res.items[0].clone().token_info.unwrap().symbol.unwrap(), "MPLX".to_string());
// assert_eq!(
// res.items[0].clone().token_info.unwrap().associated_token_address.unwrap(),
// fungible_token_account2.to_string()
// );
// assert_eq!(
// res.items[0].clone().token_info.unwrap().price_info.unwrap().currency.unwrap(),
// "USDC".to_string()
// );
// assert!(
// res.items[0].clone().token_info.unwrap().price_info.unwrap().total_price.unwrap() > 0.0
// );
// assert!(
// res.items[0].clone().token_info.unwrap().price_info.unwrap().price_per_token.unwrap()
// > 0.0
// );
//
// assert!(res.items[1].clone().token_info.unwrap().symbol.is_none());
// assert!(res.items[1].clone().token_info.unwrap().price_info.is_none());
// assert_eq!(
// res.items[1].clone().token_info.unwrap().associated_token_address.unwrap(),
// fungible_token_account1.to_string()
// );

let payload = SearchAssets {
limit: Some(1000),
Expand All @@ -3257,7 +3258,7 @@ mod tests {

// We have 1 NonFungible token, created in setup::TestEnvironment::create fn
assert_eq!(res.items.len(), 1);
assert!(res.items[0].token_info.is_none());
// assert!(res.items[0].token_info.is_none());

let payload = SearchAssets {
limit: Some(1000),
Expand Down Expand Up @@ -3292,7 +3293,7 @@ mod tests {

// Our NonFungible token is not compressed
assert_eq!(res.items.len(), 1);
assert!(res.items[0].token_info.is_none());
// assert!(res.items[0].token_info.is_none());

let payload = SearchAssets {
limit: Some(1000),
Expand All @@ -3312,16 +3313,8 @@ mod tests {
// Totally we have 3 assets with required owner. show_fungible is false by default, so we don't have token info.
assert_eq!(res.items.len(), 3);
assert!(res.items[0].mint_extensions.is_none());
assert!(res.items[0].clone().token_info.unwrap().symbol.is_none());
assert!(res.items[0].clone().token_info.unwrap().price_info.is_none());

assert!(res.items[1].mint_extensions.is_none());
assert!(res.items[1].clone().token_info.map_or(true, |info| info.symbol.is_none()));
assert!(res.items[1].clone().token_info.map_or(true, |info| info.price_info.is_none()));

assert!(res.items[2].mint_extensions.is_none());
assert!(res.items[2].clone().token_info.map_or(true, |info| info.symbol.is_none()));
assert!(res.items[2].clone().token_info.map_or(true, |info| info.price_info.is_none()));

let payload = SearchAssets {
limit: Some(1000),
Expand Down

0 comments on commit a047068

Please sign in to comment.