From 2025487edf940e4caece8584c0cf7c18d933a142 Mon Sep 17 00:00:00 2001 From: Max Korsunov Date: Fri, 5 Jul 2024 21:59:17 +0200 Subject: [PATCH 1/4] fix(services): add priority scores to the assets service --- packages/services/src/view-service/assets.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/services/src/view-service/assets.ts b/packages/services/src/view-service/assets.ts index 8e6bfaef7f..49d5c5b45f 100644 --- a/packages/services/src/view-service/assets.ts +++ b/packages/services/src/view-service/assets.ts @@ -1,6 +1,7 @@ import type { Impl } from '.'; import { servicesCtx } from '../ctx/prax'; import { assetPatterns, RegexMatcher } from '@penumbra-zone/types/assets'; +import { getAssetPriorityScore } from './util/asset-priority-score'; export const assets: Impl['assets'] = async function* (req, ctx) { const services = await ctx.values.get(servicesCtx)(); @@ -48,6 +49,9 @@ export const assets: Impl['assets'] = async function* (req, ctx) { for await (const metadata of indexedDb.iterateAssetsMetadata()) { if (filtered && !patterns.find(p => p.pattern.matches(metadata.display))) continue; + if (!metadata.priorityScore) { + metadata.priorityScore = getAssetPriorityScore(metadata, indexedDb.stakingTokenAssetId); + } yield { denomMetadata: metadata }; } }; From d7b50418d08a8ee87dfc1c2bbfbf3819614ffd21 Mon Sep 17 00:00:00 2001 From: Max Korsunov Date: Fri, 5 Jul 2024 21:59:43 +0200 Subject: [PATCH 2/4] fix(minifront): #1371: fix candlesticks and asset out balance --- .../src/components/swap/swap-form/token-swap-input.tsx | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/apps/minifront/src/components/swap/swap-form/token-swap-input.tsx b/apps/minifront/src/components/swap/swap-form/token-swap-input.tsx index 17d9f5c8e4..1cb0822fb5 100644 --- a/apps/minifront/src/components/swap/swap-form/token-swap-input.tsx +++ b/apps/minifront/src/components/swap/swap-form/token-swap-input.tsx @@ -37,12 +37,15 @@ const getAssetOutBalance = ( ) => { if (!assetIn || !assetOut) return zeroValueView(); + const assetOutMetadata = new Metadata(assetOut); + const match = balancesResponses.find(balance => { const balanceViewMetadata = getMetadataFromBalancesResponse(balance); return ( - getAddressIndex(balance.accountAddress).equals(getAddressIndex(assetIn.accountAddress)) && - assetOut.equals(balanceViewMetadata) + getAddressIndex(balance.accountAddress).account === + getAddressIndex(assetIn.accountAddress).account && + assetOutMetadata.penumbraAssetId?.equals(balanceViewMetadata.penumbraAssetId) ); }); const matchedBalance = getBalanceView.optional()(match); @@ -161,6 +164,9 @@ export const TokenSwapInput = () => { + + +
{priceHistory.startMetadata && priceHistory.endMetadata && priceHistory.candles.length ? ( Date: Fri, 5 Jul 2024 22:04:46 +0200 Subject: [PATCH 3/4] fix(minifront): remove unneeded line --- .../src/components/swap/swap-form/token-swap-input.tsx | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/apps/minifront/src/components/swap/swap-form/token-swap-input.tsx b/apps/minifront/src/components/swap/swap-form/token-swap-input.tsx index 1cb0822fb5..a3bc306e91 100644 --- a/apps/minifront/src/components/swap/swap-form/token-swap-input.tsx +++ b/apps/minifront/src/components/swap/swap-form/token-swap-input.tsx @@ -37,15 +37,13 @@ const getAssetOutBalance = ( ) => { if (!assetIn || !assetOut) return zeroValueView(); - const assetOutMetadata = new Metadata(assetOut); - const match = balancesResponses.find(balance => { const balanceViewMetadata = getMetadataFromBalancesResponse(balance); return ( getAddressIndex(balance.accountAddress).account === getAddressIndex(assetIn.accountAddress).account && - assetOutMetadata.penumbraAssetId?.equals(balanceViewMetadata.penumbraAssetId) + assetOut.penumbraAssetId?.equals(balanceViewMetadata.penumbraAssetId) ); }); const matchedBalance = getBalanceView.optional()(match); From d47f6a51b2238841221f81530a04139a49515640 Mon Sep 17 00:00:00 2001 From: Max Korsunov Date: Fri, 5 Jul 2024 22:05:39 +0200 Subject: [PATCH 4/4] chore: changeset --- .changeset/tasty-emus-worry.md | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 .changeset/tasty-emus-worry.md diff --git a/.changeset/tasty-emus-worry.md b/.changeset/tasty-emus-worry.md new file mode 100644 index 0000000000..6bcc9d6936 --- /dev/null +++ b/.changeset/tasty-emus-worry.md @@ -0,0 +1,6 @@ +--- +'@penumbra-zone/services': patch +'minifront': patch +--- + +Services: add priority scores to the `assets` service. Minifront: fix rendering issues