From 221e007d1a99f72fc88d9169f77dd0d2f16df90d Mon Sep 17 00:00:00 2001 From: "Jason M. Hasperhoven" Date: Thu, 17 Oct 2024 17:05:54 +0400 Subject: [PATCH 1/3] Sort assets by priority score --- apps/minifront/src/fetchers/assets.ts | 4 +++- .../src/view-service/util/asset-priority-score.ts | 11 +++++------ 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/apps/minifront/src/fetchers/assets.ts b/apps/minifront/src/fetchers/assets.ts index 9f2317ae8b..e710ce45fc 100644 --- a/apps/minifront/src/fetchers/assets.ts +++ b/apps/minifront/src/fetchers/assets.ts @@ -6,7 +6,9 @@ import { penumbra } from '../penumbra'; export const getAllAssets = async (): Promise => { const responses = await Array.fromAsync(penumbra.service(ViewService).assets({})); - return responses.map(getDenomMetadata); + return responses + .map(getDenomMetadata) + .toSorted((a, b) => Number(b.priorityScore) - Number(a.priorityScore)); }; export const getAssetMetadataById = async (assetId: AssetId): Promise => { diff --git a/packages/services/src/view-service/util/asset-priority-score.ts b/packages/services/src/view-service/util/asset-priority-score.ts index e0a074fb84..2cf5466348 100644 --- a/packages/services/src/view-service/util/asset-priority-score.ts +++ b/packages/services/src/view-service/util/asset-priority-score.ts @@ -24,12 +24,11 @@ export const getAssetPriorityScore = ( return 0n; } - if (metadata.penumbraAssetId?.equals(nativeTokenId)) { - return 50n; - } - - if (assetPatterns.ibc.matches(metadata.display)) { - return 40n; + if ( + metadata.penumbraAssetId?.equals(nativeTokenId) || + assetPatterns.ibc.matches(metadata.display) + ) { + return metadata.priorityScore; } if ( From a0149b7526e53e7caa0d7c53e991a72e1ad5f195 Mon Sep 17 00:00:00 2001 From: "Jason M. Hasperhoven" Date: Wed, 23 Oct 2024 17:17:58 +0400 Subject: [PATCH 2/3] Revert logic in getAssetPriorityScore --- .../src/view-service/util/asset-priority-score.ts | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/packages/services/src/view-service/util/asset-priority-score.ts b/packages/services/src/view-service/util/asset-priority-score.ts index 2cf5466348..e0a074fb84 100644 --- a/packages/services/src/view-service/util/asset-priority-score.ts +++ b/packages/services/src/view-service/util/asset-priority-score.ts @@ -24,11 +24,12 @@ export const getAssetPriorityScore = ( return 0n; } - if ( - metadata.penumbraAssetId?.equals(nativeTokenId) || - assetPatterns.ibc.matches(metadata.display) - ) { - return metadata.priorityScore; + if (metadata.penumbraAssetId?.equals(nativeTokenId)) { + return 50n; + } + + if (assetPatterns.ibc.matches(metadata.display)) { + return 40n; } if ( From e6f3aa59e392a39f7eac1455c74d56d2f571f2c6 Mon Sep 17 00:00:00 2001 From: "Jason M. Hasperhoven" Date: Wed, 23 Oct 2024 17:18:53 +0400 Subject: [PATCH 3/3] Add changeset --- .changeset/grumpy-carpets-kiss.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/grumpy-carpets-kiss.md diff --git a/.changeset/grumpy-carpets-kiss.md b/.changeset/grumpy-carpets-kiss.md new file mode 100644 index 0000000000..f5bf7d8232 --- /dev/null +++ b/.changeset/grumpy-carpets-kiss.md @@ -0,0 +1,5 @@ +--- +'minifront': patch +--- + +Sort assets by priority score