From 9c5c9825cd6a21008380177ce5841101a4de1d32 Mon Sep 17 00:00:00 2001 From: Gabe Rodriguez Date: Tue, 5 Nov 2024 16:23:58 -0800 Subject: [PATCH] Review updates --- package.json | 1 - pnpm-lock.yaml | 11 ----------- src/pages/trade/api/candles.tsx | 10 +--------- src/pages/trade/redirect.tsx | 3 +++ src/shared/api/server/candles/index.ts | 21 --------------------- src/shared/database/index.ts | 10 +--------- 6 files changed, 5 insertions(+), 51 deletions(-) diff --git a/package.json b/package.json index d2f4d842..bad1c6e8 100644 --- a/package.json +++ b/package.json @@ -62,7 +62,6 @@ "framer-motion": "^11.3.31", "grpc-tools": "^1.12.4", "grpc_tools_node_protoc_ts": "^5.3.3", - "iso-datestring-validator": "^2.2.2", "kysely": "^0.27.4", "lightweight-charts": "^4.2.0", "lodash": "^4.17.21", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index ff0aa7c4..4eba2e49 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -127,9 +127,6 @@ importers: grpc_tools_node_protoc_ts: specifier: ^5.3.3 version: 5.3.3 - iso-datestring-validator: - specifier: ^2.2.2 - version: 2.2.2 kysely: specifier: ^0.27.4 version: 0.27.4 @@ -7761,12 +7758,6 @@ packages: integrity: sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==, } - iso-datestring-validator@2.2.2: - resolution: - { - integrity: sha512-yLEMkBbLZTlVQqOnQ4FiMujR6T4DEcCb1xizmvXS+OxuhwcbtynoosRzdMA69zZCShCNAbi+gJ71FxZBBXx1SA==, - } - iterator.prototype@1.1.2: resolution: { @@ -15922,8 +15913,6 @@ snapshots: isexe@2.0.0: {} - iso-datestring-validator@2.2.2: {} - iterator.prototype@1.1.2: dependencies: define-properties: 1.2.1 diff --git a/src/pages/trade/api/candles.tsx b/src/pages/trade/api/candles.tsx index c6909ce6..4afc12d5 100644 --- a/src/pages/trade/api/candles.tsx +++ b/src/pages/trade/api/candles.tsx @@ -5,23 +5,15 @@ import { usePathSymbols } from '@/pages/trade/model/use-path.ts'; import { OhlcData } from 'lightweight-charts'; import { DurationWindow } from '@/shared/database/schema.ts'; -const DEX_ENABLED_DATE = '2024-08-01'; - export const useCandles = (durationWindow: DurationWindow) => { const { baseSymbol, quoteSymbol } = usePathSymbols(); const query = useQuery({ - queryKey: ['candles', baseSymbol, quoteSymbol, durationWindow, DEX_ENABLED_DATE], + queryKey: ['candles', baseSymbol, quoteSymbol, durationWindow], queryFn: async (): Promise => { - const todayIso = new Date().toISOString().split('T')[0]; - if (!todayIso) { - throw new Error("Unable to generate today's date as an iso string"); - } const paramsObj = { baseAsset: baseSymbol, quoteAsset: quoteSymbol, - startDate: todayIso, - endDate: DEX_ENABLED_DATE, durationWindow, }; const baseUrl = '/api/candles'; diff --git a/src/pages/trade/redirect.tsx b/src/pages/trade/redirect.tsx index 7c0c9066..e036a58b 100644 --- a/src/pages/trade/redirect.tsx +++ b/src/pages/trade/redirect.tsx @@ -4,6 +4,7 @@ import { redirect } from 'next/navigation'; import { ChainRegistryClient } from '@penumbra-labs/registry'; import { envQueryFn } from '@/shared/api/env/env.ts'; import { useQuery } from '@tanstack/react-query'; +import { assetPatterns } from '@penumbra-zone/types/assets'; const redirectSymbolsQueryFn = async () => { const { PENUMBRA_CHAIN_ID } = await envQueryFn(); @@ -11,7 +12,9 @@ const redirectSymbolsQueryFn = async () => { const registry = await chainRegistryClient.remote.get(PENUMBRA_CHAIN_ID); const allAssets = registry .getAllAssets() + .filter(m => !assetPatterns.delegationToken.matches(m.display)) .toSorted((a, b) => Number(b.priorityScore - a.priorityScore)); + const baseAsset = allAssets[0]?.symbol; const quoteAsset = allAssets[1]?.symbol; if (!baseAsset || !quoteAsset) { diff --git a/src/shared/api/server/candles/index.ts b/src/shared/api/server/candles/index.ts index 3678f249..5f210848 100644 --- a/src/shared/api/server/candles/index.ts +++ b/src/shared/api/server/candles/index.ts @@ -1,7 +1,6 @@ import { NextRequest, NextResponse } from 'next/server'; import { ChainRegistryClient } from '@penumbra-labs/registry'; import { pindexer } from '@/shared/database'; -import { isValidDate } from 'iso-datestring-validator'; import { CandleApiResponse } from '@/shared/api/server/candles/types.ts'; import { durationWindows, isDurationWindow } from '@/shared/database/schema.ts'; import { dbCandleToOhlc, mergeCandles } from '@/shared/api/server/candles/utils.ts'; @@ -33,22 +32,6 @@ export async function GET(req: NextRequest): Promise=', end) .execute(); } }