-
Notifications
You must be signed in to change notification settings - Fork 13
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
MTG-1238 feat(api): add showBurnt
option to GetByMethodsOptions
#387
Open
armyhaylenko
wants to merge
1
commit into
develop
Choose a base branch
from
feat/MTG-1238-show-burnt-display-option
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1861,6 +1861,104 @@ mod tests { | |
); | ||
} | ||
|
||
#[tokio::test] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would also add test case for |
||
#[tracing_test::traced_test] | ||
async fn test_get_only_non_burnt_assets_by_owner() { | ||
let cnt = 20; | ||
let cli = Cli::default(); | ||
let (env, generated_assets) = | ||
setup::TestEnvironment::create_burnt(&cli, cnt, SLOT_UPDATED).await; | ||
let api = create_api(&env, None); | ||
let tasks = JoinSet::new(); | ||
let mutexed_tasks = Arc::new(Mutex::new(tasks)); | ||
|
||
let ref_value = generated_assets.owners[8].clone(); | ||
let payload = GetAssetsByOwner { | ||
owner_address: ref_value.owner.value.map(|owner| owner.to_string()).unwrap_or_default(), | ||
sort_by: None, | ||
limit: None, | ||
page: None, | ||
before: None, | ||
after: None, | ||
cursor: None, | ||
options: GetByMethodsOptions { | ||
show_unverified_collections: true, | ||
show_burnt: Some(false), | ||
..Default::default() | ||
}, | ||
}; | ||
|
||
let res = api.get_assets_by_owner(payload, mutexed_tasks.clone()).await.unwrap(); | ||
let res_obj: AssetList = serde_json::from_value(res).unwrap(); | ||
|
||
// in the setup all assets were created as burnt | ||
// meaning that if we do not explicitly specify show_burnt | ||
// in the options, the response will be empty | ||
assert_eq!(res_obj.total, 0, "total should be 0"); | ||
assert_eq!(res_obj.items.len(), 0, "items length should be 0"); | ||
} | ||
|
||
#[tokio::test] | ||
#[tracing_test::traced_test] | ||
async fn test_get_only_burnt_assets_by_owner() { | ||
let cnt = 20; | ||
let cli = Cli::default(); | ||
let (env, generated_assets) = | ||
setup::TestEnvironment::create_burnt(&cli, cnt, SLOT_UPDATED).await; | ||
let api = create_api(&env, None); | ||
let tasks = JoinSet::new(); | ||
let mutexed_tasks = Arc::new(Mutex::new(tasks)); | ||
|
||
let ref_value = generated_assets.owners[8].clone(); | ||
let payload = GetAssetsByOwner { | ||
owner_address: ref_value.owner.value.map(|owner| owner.to_string()).unwrap_or_default(), | ||
sort_by: None, | ||
limit: None, | ||
page: None, | ||
before: None, | ||
after: None, | ||
cursor: None, | ||
options: GetByMethodsOptions { | ||
show_unverified_collections: true, | ||
show_burnt: Some(true), | ||
..Default::default() | ||
}, | ||
}; | ||
|
||
let res = api.get_assets_by_owner(payload, mutexed_tasks.clone()).await.unwrap(); | ||
let res_obj: AssetList = serde_json::from_value(res).unwrap(); | ||
|
||
assert_eq!(res_obj.total, 1, "total should be 1"); | ||
assert_eq!(res_obj.items.len(), 1, "items length should be 1"); | ||
} | ||
|
||
#[tokio::test] | ||
#[tracing_test::traced_test] | ||
async fn test_search_assets_excluding_burnt_assets() { | ||
let cnt = 20; | ||
let cli = Cli::default(); | ||
let (env, _generated_assets) = | ||
setup::TestEnvironment::create_burnt(&cli, cnt, SLOT_UPDATED).await; | ||
let api = create_api(&env, None); | ||
let tasks = JoinSet::new(); | ||
let mutexed_tasks = Arc::new(Mutex::new(tasks)); | ||
let limit = 20; | ||
let payload = SearchAssets { | ||
burnt: Some(false), | ||
limit: Some(limit), | ||
options: SearchAssetsOptions { | ||
show_unverified_collections: true, | ||
..Default::default() | ||
}, | ||
..Default::default() | ||
}; | ||
let res = api.search_assets(payload, mutexed_tasks.clone()).await.unwrap(); | ||
assert!(res.is_object()); | ||
let res_obj: AssetList = serde_json::from_value(res).unwrap(); | ||
assert_eq!(res_obj.total, 0, "total should be 0"); | ||
assert_eq!(res_obj.items.len(), 0, "assets length should be 0"); | ||
} | ||
|
||
#[tokio::test] | ||
#[tracing_test::traced_test] | ||
async fn test_get_assets_by_group() { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems that the conditions of the task are well suited to not use the Option.
show_burnt default value is false.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i honestly don't really agree, i want it to follow a similar behavior to
search_assets
. meaning thatNone
means show all, burnt and not burnt,Some(true)
meaning only show burnt assets, andSome(false)
meaning only show non-burnt assets. we can consider a rename toshow_burnt_only
, but this definitely should be abool
in this case and it would imply that we show either burnt or non-burnt, and not all of them.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we see the task differently. In my version I don't see the need to display only burned nfts.
This can be implemented in this way, but in my opinion, it goes beyond the scope of the task / business requirements.
I see next options:
showBurnt True
- display all (items with option burnt=true / false)showBurnt False
- display only not burnt items (items with option burnt=false)No showBurnt option
is equal to showBurnt False as a default behavior.This approach will allow Wallets to show current nfts (not burned) or to show all. But it's better to get more information/requirements from the business side, since handling three variants complicates the architecture @danenbm
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When I was originally discussing this with Nhan, we had thought that most people care about non-burnt assets, so at that time I was originally thinking of hiding them by default.
However, I have talked to customers (such as Mallow) who told me that people burn the NFTs as part of an NFT collection mechanic, but still want to see the burnt NFT artwork. Also we have recently talked about the importance of matching existing DAS behavior.
Therefore, I have come to the conclusion:
I have one clarifying question:
Whether it's an
Option<bool>
or abool
, in practice the end-user is either specifying the flag or leaving it blank, right? So the complication is just howdisplayOptions
are parsed. In old DAS this would mean replacing a call to:options.unwrap_or_default()
. But I did not see that in this PR at first glance, so not sure how much complexity is required to deal withOption<bool>
.I agree that a bool is simpler and matches how the other
displayOptions
are stored, but I think to have only binary behavior and meet the requirements, we would have to call it something likehideBurntItems
orshowUnburntItemsOnly
and default tofalse
. I think this would be more confusing to end users.If the end user can specify in their request:
"showBurnt": "true"
is just burnt"showBurnt": "false"
is only non-burntI think that would be less confusing to end-user.
We can chat about this at standup as well. This is not high priority feature request. So we can also hold off on this feature if we cannot easily settle on the interface or the complexity.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMHO:
The field is called display options, and it's not a filter. Or at least it shouldn't be one. It should not impact the number of the assets displayed, just the layout. This is already broken by show_inscription, show_zero_balance, show_fungible and probably show_unverified_collections as well. Given this any option that we choose will only increase the conflicting behaviour.
Now for the matter at hand:
Given the existing behaviour we should call the flag
skipBurnt bool
(hideBurnt
will be another alternative)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm now thinking we should just pause on this feature and wait for more customer feedback if it is needed. It is not high priority and nobody has asked for it, and if/when we add it we should also consider backporting to digital-asset-standard-api repo and digital-asset-rpc-infrastructure repo, which is also not something I want to take time doing right now.