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

[explorer] sorts Objects by Type and then ID #1841

Merged
merged 2 commits into from
May 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
16 changes: 9 additions & 7 deletions explorer/client/src/__tests__/e2e.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -309,20 +309,20 @@ describe('End-to-end Tests', () => {
page,
'receiverAddress',
'addresses',
'playerOne',
'player1',
1
);
});
it('go from object to child object and back', async () => {
await navigationTemplate(page, 'playerTwo', 'objects', 'Image1', 1);
await navigationTemplate(page, 'player2', 'objects', 'Image1', 1);
});
it('go from parent to broken image object and back', async () => {
const parentValue = 'ObjectWBrokenChild';
await page.goto(`${BASE_URL}/objects/${parentValue}`);

//Click on child in Owned Objects List:
const objectLink = await page.$(
`div#ownedObjects > div:nth-child(2)`
`div#ownedObjects > div:nth-child(1)`
);
await objectLink.click();

Expand Down Expand Up @@ -380,7 +380,7 @@ describe('End-to-end Tests', () => {
(el: any) => el.textContent,
objectIDEl
);
expect(objectValue.trim()).toBe('playerNine');
expect(objectValue.trim()).toBe('player0');
});
it('to go to the last page', async () => {
const address = 'ownsAllAddress';
Expand All @@ -399,7 +399,9 @@ describe('End-to-end Tests', () => {
(el: any) => el.textContent,
objectIDEl
);
expect(objectValue.trim()).toBe('playerTen');
expect(objectValue.trim()).toBe(
'7bc832ec31709638cd8d9323e90edf332gff4389'
);
});
it('where last and next disappear in final page', async () => {
const address = 'ownsAllAddress';
Expand Down Expand Up @@ -435,7 +437,7 @@ describe('End-to-end Tests', () => {
(el: any) => el.textContent,
objectIDEl
);
expect(objectValue.trim()).toBe('playerNine');
expect(objectValue.trim()).toBe('player0');
});

it('to go to first page', async () => {
Expand All @@ -459,7 +461,7 @@ describe('End-to-end Tests', () => {
(el: any) => el.textContent,
objectIDEl
);
expect(objectValue.trim()).toBe('playerOne');
expect(objectValue.trim()).toBe('ChildObjectWBrokenImage');
});
it('where first and back disappear in first page', async () => {
const address = 'ownsAllAddress';
Expand Down
11 changes: 10 additions & 1 deletion explorer/client/src/components/ownedobjects/OwnedObjects.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,16 @@ function OwnedObjectAPI({ id }: { id: string }) {

function OwnedObjectLayout({ results }: { results: resultType }) {
const coin_results = results.filter(({ Type }) => IS_COIN_TYPE(Type));
const other_results = results.filter(({ Type }) => !IS_COIN_TYPE(Type));
const other_results = results
.filter(({ Type }) => !IS_COIN_TYPE(Type))
.sort((a, b) => {
if (a.Type > b.Type) return 1;
if (a.Type < b.Type) return -1;
if (a.Type === b.Type) {
return a.id <= b.id ? -1 : 1;
}
return 0;
});

return (
<div>
Expand Down
34 changes: 17 additions & 17 deletions explorer/client/src/utils/static/mock_data.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"data": [
{
"id": "playerOne",
"id": "player1",
"owner": "SingleOwner(k#receiverAddress)",
"category": "object",
"version": "6",
Expand All @@ -25,7 +25,7 @@
}
},
{
"id": "playerTwo",
"id": "player2",
"owner": "SingleOwner(k#receiverAddress)",
"category": "object",
"version": "5",
Expand Down Expand Up @@ -57,7 +57,7 @@
}
},
{
"id": "anotherPlayer",
"id": "player0",
"owner": "SingleOwner(k#)",
"category": "object",
"version": "100",
Expand All @@ -79,7 +79,7 @@
}
},
{
"id": "playerThree",
"id": "player3",
"owner": "SingleOwner(k#)",
"category": "object",
"version": "100",
Expand All @@ -101,7 +101,7 @@
}
},
{
"id": "playerFour",
"id": "player4",
"owner": "SingleOwner(k#)",
"category": "object",
"version": "100",
Expand All @@ -123,7 +123,7 @@
}
},
{
"id": "playerFive",
"id": "player5",
"owner": "SingleOwner(k#)",
"category": "object",
"version": "100",
Expand All @@ -145,7 +145,7 @@
}
},
{
"id": "playerSix",
"id": "player6",
"owner": "SingleOwner(k#)",
"category": "object",
"version": "100",
Expand All @@ -167,7 +167,7 @@
}
},
{
"id": "playerSeven",
"id": "player7",
"owner": "SingleOwner(k#)",
"category": "object",
"version": "100",
Expand All @@ -189,7 +189,7 @@
}
},
{
"id": "playerEight",
"id": "player8",
"owner": "SingleOwner(k#)",
"category": "object",
"version": "100",
Expand All @@ -211,7 +211,7 @@
}
},
{
"id": "playerNine",
"id": "player9",
"owner": "SingleOwner(k#)",
"category": "object",
"version": "100",
Expand All @@ -233,7 +233,7 @@
}
},
{
"id": "playerTen",
"id": "playerA1",
"owner": "SingleOwner(k#)",
"category": "object",
"version": "100",
Expand All @@ -258,7 +258,7 @@
{
"id": "Image1",
"category": "object",
"owner": "SingleOwner(k#playerTwo)",
"owner": "SingleOwner(k#player2)",
"version": "1",
"readonly": "true",
"objType": "0x2::Cosmetic::Plant",
Expand Down Expand Up @@ -427,7 +427,7 @@
{
"id": "standaloneObject",
"category": "object",
"owner": "SingleOwner(k#playerTwo)",
"owner": "SingleOwner(k#player2)",
"version": "87",
"readonly": "true",
"objType": "0x2::Coin::Coin<0x2::USD::USD>",
Expand All @@ -441,7 +441,7 @@
{
"id": "standaloneObject200",
"category": "object",
"owner": "SingleOwner(k#playerTwo)",
"owner": "SingleOwner(k#player2)",
"version": "87",
"readonly": "true",
"objType": "0x2::Coin::Coin<0x2::USD::USD>",
Expand All @@ -455,7 +455,7 @@
{
"id": "standaloneObjectSUI50",
"category": "object",
"owner": "SingleOwner(k#playerTwo)",
"owner": "SingleOwner(k#player2)",
"version": "87",
"readonly": "true",
"objType": "0x2::Coin::Coin<0x2::SUI::SUI>",
Expand All @@ -469,7 +469,7 @@
{
"id": "standaloneObjectSUI150",
"category": "object",
"owner": "SingleOwner(k#playerTwo)",
"owner": "SingleOwner(k#player2)",
"version": "87",
"readonly": "true",
"objType": "0x2::Coin::Coin<0x2::SUI::SUI>",
Expand All @@ -488,7 +488,7 @@
{
"id": "CollectionObject",
"category": "object",
"owner": "SingleOwner(k#playerTwo)",
"owner": "SingleOwner(k#player2)",
"version": "2",
"readonly": "false",
"objType": "0x2::MystenUniverse::Collection",
Expand Down
50 changes: 25 additions & 25 deletions explorer/client/src/utils/static/owned_object.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,46 +4,46 @@
"id": "ownsAllAddress",
"objects": [
{
"objectId": "playerOne"
"objectId": "player1"
},
{
"objectId": "anotherPlayer"
"objectId": "player0"
},
{
"objectId": "playerTwo"
"objectId": "player2"
},
{
"objectId": "playerThree"
"objectId": "player3"
},

{
"objectId": "7bc832ec31709638cd8d9323e90edf332gff4389"
},
{
"objectId": "playerFour"
"objectId": "player4"
},

{
"objectId": "ComponentObject"
},
{
"objectId": "playerFive"
"objectId": "player5"
},

{
"objectId": "CollectionObject"
},
{
"objectId": "playerSix"
"objectId": "player6"
},
{
"objectId": "playerSeven"
"objectId": "player7"
},
{
"objectId": "playerEight"
"objectId": "player8"
},
{
"objectId": "playerNine"
"objectId": "player9"
},
{
"objectId": "ObjectThatOwns"
Expand Down Expand Up @@ -79,7 +79,7 @@
"objectId": "Image8"
},
{
"objectId": "playerTen"
"objectId": "playerA1"
},
{
"objectId": "standaloneObject"
Expand All @@ -99,46 +99,46 @@
"id": "ObjectThatOwns",
"objects": [
{
"objectId": "playerOne"
"objectId": "player1"
},
{
"objectId": "anotherPlayer"
"objectId": "player0"
},
{
"objectId": "playerTwo"
"objectId": "player2"
},
{
"objectId": "playerThree"
"objectId": "player3"
},

{
"objectId": "7bc832ec31709638cd8d9323e90edf332gff4389"
},
{
"objectId": "playerFour"
"objectId": "player4"
},

{
"objectId": "ComponentObject"
},
{
"objectId": "playerFive"
"objectId": "player5"
},

{
"objectId": "CollectionObject"
},
{
"objectId": "playerSix"
"objectId": "player6"
},
{
"objectId": "playerSeven"
"objectId": "player7"
},
{
"objectId": "playerEight"
"objectId": "player8"
},
{
"objectId": "playerNine"
"objectId": "player9"
},
{
"objectId": "ObjectThatOwns"
Expand Down Expand Up @@ -174,7 +174,7 @@
"objectId": "Image8"
},
{
"objectId": "playerTen"
"objectId": "playerA1"
},
{
"objectId": "standaloneObject"
Expand Down Expand Up @@ -212,7 +212,7 @@
]
},
{
"id": "playerTwo",
"id": "player2",
"objects": [
{
"objectId": "standaloneObject",
Expand All @@ -228,11 +228,11 @@
"id": "receiverAddress",
"objects": [
{
"objectId": "playerOne",
"objectId": "player1",
"version": 6
},
{
"objectId": "playerTwo",
"objectId": "player2",
"version": 5
}
]
Expand Down