Skip to content

Commit

Permalink
fix: stacks nft sorting by using the fully qualified token id (#211)
Browse files Browse the repository at this point in the history
Co-authored-by: Den <[email protected]>
  • Loading branch information
fedeerbes and dhriaznov authored Oct 10, 2024
1 parent d607d67 commit 170bbad
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions stacksCollectible/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,8 @@ export function applySortAndCollectionsFilters(
const orderedCollection = {
...collection,
all_nfts: collection.all_nfts.sort((a, b) => {
const aStarred = starredCollectibleIds.indexOf(`${a.asset_identifier}::${a.identifier.tokenId}`);
const bStarred = starredCollectibleIds.indexOf(`${b.asset_identifier}::${b.identifier.tokenId}`);
const aStarred = starredCollectibleIds.indexOf(`${a.asset_identifier}:${a.identifier.tokenId}`);
const bStarred = starredCollectibleIds.indexOf(`${b.asset_identifier}:${b.identifier.tokenId}`);
// Non-starred items have -1, so they should move to the right
if (aStarred === -1) return 1;
if (bStarred === -1) return -1;
Expand Down
2 changes: 1 addition & 1 deletion tests/stacks/stacksNfts.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@ describe('applySortAndCollectionsFilters', () => {
});

it('should show starred NFTs inside a collection in front', () => {
const starredCollectibleIds = ['SP497E7RX3233ATBS2AB9G4WTHB63X5PBSP5VGAQ.boom-nfts::boom::13285'];
const starredCollectibleIds = ['SP497E7RX3233ATBS2AB9G4WTHB63X5PBSP5VGAQ.boom-nfts::boom:13285'];
const result = applySortAndCollectionsFilters(mockStacksCollection, { starredCollectibleIds });
expect(result).toStrictEqual(mockStarredItemInACollection);
});
Expand Down

0 comments on commit 170bbad

Please sign in to comment.