Skip to content

Commit fd7c6e4

Browse files
committed
feat(insights): mostly finish publishers index page
1 parent 59f3f6f commit fd7c6e4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

73 files changed

+1954
-1133
lines changed

apps/insights/package.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,15 @@
2626
"@pythnetwork/client": "catalog:",
2727
"@pythnetwork/component-library": "workspace:*",
2828
"@pythnetwork/fonts": "workspace:*",
29+
"@pythnetwork/hermes-client": "workspace:*",
2930
"@pythnetwork/known-publishers": "workspace:*",
3031
"@pythnetwork/next-root": "workspace:*",
3132
"@react-hookz/web": "catalog:",
3233
"@solana/web3.js": "catalog:",
3334
"bs58": "catalog:",
3435
"clsx": "catalog:",
3536
"cryptocurrency-icons": "catalog:",
37+
"dnum": "catalog:",
3638
"framer-motion": "catalog:",
3739
"next": "catalog:",
3840
"next-themes": "catalog:",
@@ -41,6 +43,7 @@
4143
"react-aria": "catalog:",
4244
"react-aria-components": "catalog:",
4345
"react-dom": "catalog:",
46+
"recharts": "catalog:",
4447
"swr": "catalog:",
4548
"zod": "catalog:"
4649
},
@@ -49,6 +52,7 @@
4952
"@cprussin/jest-config": "catalog:",
5053
"@cprussin/prettier-config": "catalog:",
5154
"@cprussin/tsconfig": "catalog:",
55+
"@pythnetwork/staking-sdk": "workspace:",
5256
"@svgr/webpack": "catalog:",
5357
"@types/jest": "catalog:",
5458
"@types/node": "catalog:",
Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
11
"use client";
22

3+
import { LoggerProvider } from "@pythnetwork/app-logger/provider";
34
import type { ComponentProps } from "react";
45

56
import { Error } from "../components/Error";
67

78
const GlobalError = (props: ComponentProps<typeof Error>) => (
8-
<html lang="en" dir="ltr">
9-
<body>
10-
<Error {...props} />
11-
</body>
12-
</html>
9+
<LoggerProvider>
10+
<html lang="en" dir="ltr">
11+
<body>
12+
<Error {...props} />
13+
</body>
14+
</html>
15+
</LoggerProvider>
1316
);
1417
export default GlobalError;

apps/insights/src/app/publishers/layout.ts

Lines changed: 0 additions & 1 deletion
This file was deleted.

apps/insights/src/app/publishers/loading.ts

Lines changed: 0 additions & 1 deletion
This file was deleted.

apps/insights/src/app/yesterdays-prices/route.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import type { NextRequest } from "next/server";
22
import { z } from "zod";
33

4-
import { client } from "../../clickhouse";
4+
import { client } from "../../services/clickhouse";
55

66
export async function GET(req: NextRequest) {
77
const symbols = req.nextUrl.searchParams.getAll("symbols");
88
const rows = await client.query({
99
query:
10-
"select * from insights_yesterdays_prices(symbols={symbols: Array(String)})",
10+
"select symbol, price from insights_yesterdays_prices(symbols={symbols: Array(String)})",
1111
query_params: { symbols },
1212
});
1313
const result = await rows.json();
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
"use client";
2+
3+
import { Skeleton } from "@pythnetwork/component-library/Skeleton";
4+
import { Suspense, use } from "react";
5+
6+
type Props<T> = {
7+
placeholderWidth: number;
8+
valuePromise: Promise<T>;
9+
};
10+
11+
export const AsyncValue = <T,>({
12+
placeholderWidth,
13+
valuePromise,
14+
}: Props<T>) => (
15+
<Suspense fallback={<Skeleton width={placeholderWidth} />}>
16+
<ResolvedValue valuePromise={valuePromise} />
17+
</Suspense>
18+
);
19+
20+
const ResolvedValue = <T,>({ valuePromise }: Pick<Props<T>, "valuePromise">) =>
21+
use(valuePromise);
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
"use client";
2+
3+
import * as dnum from "dnum";
4+
import { useMemo } from "react";
5+
import { useLocale } from "react-aria";
6+
7+
const DECIMALS = 6;
8+
9+
type Props = {
10+
mode?: "compact" | "wholePart" | "full";
11+
children: bigint;
12+
};
13+
14+
export const FormattedTokens = ({ children, mode = "compact" }: Props) => {
15+
const { locale } = useLocale();
16+
const value = useMemo(
17+
() =>
18+
dnum.format([children, DECIMALS], {
19+
compact: mode === "compact",
20+
locale,
21+
}),
22+
[children, locale, mode],
23+
);
24+
25+
return mode === "wholePart" ? value.split(".")[0] : value;
26+
};

apps/insights/src/components/H1/index.module.scss

Lines changed: 0 additions & 7 deletions
This file was deleted.

apps/insights/src/components/H1/index.tsx

Lines changed: 0 additions & 10 deletions
This file was deleted.

apps/insights/src/components/LivePrices/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import {
1616
import { useNumberFormatter } from "react-aria";
1717

1818
import styles from "./index.module.scss";
19-
import { client, subscribe } from "../../pyth";
19+
import { client, subscribe } from "../../services/pyth";
2020

2121
export const SKELETON_WIDTH = 20;
2222

0 commit comments

Comments
 (0)