Skip to content

Commit

Permalink
fix: #1371: candelesticks and the rest (#1429)
Browse files Browse the repository at this point in the history
* fix(services): add priority scores to the assets service

* fix(minifront): #1371: fix candlesticks and asset out balance

* fix(minifront): remove unneeded line

* chore: changeset
  • Loading branch information
VanishMax authored Jul 5, 2024
1 parent 6c2bfdc commit dc77a52
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
6 changes: 6 additions & 0 deletions .changeset/tasty-emus-worry.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@penumbra-zone/services': patch
'minifront': patch
---

Services: add priority scores to the `assets` service. Minifront: fix rendering issues
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,9 @@ const getAssetOutBalance = (
const balanceViewMetadata = getMetadataFromBalancesResponse(balance);

return (
getAddressIndex(balance.accountAddress).equals(getAddressIndex(assetIn.accountAddress)) &&
assetOut.equals(balanceViewMetadata)
getAddressIndex(balance.accountAddress).account ===
getAddressIndex(assetIn.accountAddress).account &&
assetOut.penumbraAssetId?.equals(balanceViewMetadata.penumbraAssetId)
);
});
const matchedBalance = getBalanceView.optional()(match);
Expand Down Expand Up @@ -161,6 +162,9 @@ export const TokenSwapInput = () => {
</div>
</div>
</div>
</div>

<div className='pt-2'>
{priceHistory.startMetadata && priceHistory.endMetadata && priceHistory.candles.length ? (
<CandlestickPlot
className='h-[480px] w-full bg-charcoal'
Expand Down
4 changes: 4 additions & 0 deletions packages/services/src/view-service/assets.ts
Original file line number Diff line number Diff line change
@@ -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)();
Expand Down Expand Up @@ -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 };
}
};

0 comments on commit dc77a52

Please sign in to comment.