From 4bc78848b57d2c2cfe6053a34ec2bc3e85cacfcf Mon Sep 17 00:00:00 2001 From: Luis Herasme Date: Fri, 2 Aug 2024 10:34:29 -0400 Subject: [PATCH] feat: add LatestGasPrice component (#470) * feat: add LatestGasPrice component * feat: Add Blob gas price to ExplorerDetails component * feat: Update ExplorerDetails component to display Blob gas price with EtherUnitDisplay * chore: update changeset --- .changeset/modern-boxes-nail.md | 5 +++++ .changeset/quiet-ladybugs-accept.md | 5 +++++ apps/web/src/components/ExplorerDetails.tsx | 14 ++++++++++++++ apps/web/src/icons/gas.svg | 6 ++++++ packages/api/src/routers/block/getGasPrice.ts | 7 +++++++ packages/api/src/routers/block/index.ts | 2 ++ 6 files changed, 39 insertions(+) create mode 100644 .changeset/modern-boxes-nail.md create mode 100644 .changeset/quiet-ladybugs-accept.md create mode 100644 apps/web/src/icons/gas.svg create mode 100644 packages/api/src/routers/block/getGasPrice.ts diff --git a/.changeset/modern-boxes-nail.md b/.changeset/modern-boxes-nail.md new file mode 100644 index 000000000..a644cc35f --- /dev/null +++ b/.changeset/modern-boxes-nail.md @@ -0,0 +1,5 @@ +--- +"@blobscan/api": minor +--- + +Added procedure to get the latest block diff --git a/.changeset/quiet-ladybugs-accept.md b/.changeset/quiet-ladybugs-accept.md new file mode 100644 index 000000000..b96d2f833 --- /dev/null +++ b/.changeset/quiet-ladybugs-accept.md @@ -0,0 +1,5 @@ +--- +"@blobscan/web": minor +--- + +Added blob gas price to the ExplorerDetails component diff --git a/apps/web/src/components/ExplorerDetails.tsx b/apps/web/src/components/ExplorerDetails.tsx index dd0b205e4..71f671064 100644 --- a/apps/web/src/components/ExplorerDetails.tsx +++ b/apps/web/src/components/ExplorerDetails.tsx @@ -6,7 +6,9 @@ import Skeleton from "react-loading-skeleton"; import { api } from "~/api-client"; import { env } from "~/env.mjs"; +import Gas from "~/icons/gas.svg"; import { capitalize, formatNumber, formatTtl } from "~/utils"; +import { EtherUnitDisplay } from "./Displays/EtherUnitDisplay"; type ExplorerDetailsItemProps = { name: string; @@ -35,6 +37,8 @@ function ExplorerDetailsItem({ export function ExplorerDetails() { const { data: syncStateData } = api.syncState.getState.useQuery(); const { data: blobStoragesState } = api.blobStoragesState.getState.useQuery(); + const { data: latestBlock } = api.block.getLatestBlock.useQuery(); + const explorerDetailsItems: ExplorerDetailsItemProps[] = [ { name: "Network", value: capitalize(env.NEXT_PUBLIC_NETWORK_NAME) }, { @@ -43,6 +47,16 @@ export function ExplorerDetails() { ? formatNumber(syncStateData.lastUpperSyncedSlot ?? 0) : undefined, }, + { + name: "Blob gas price", + icon: , + value: latestBlock && ( + + ), + }, ]; if (blobStoragesState && blobStoragesState.swarmDataTTL) { diff --git a/apps/web/src/icons/gas.svg b/apps/web/src/icons/gas.svg new file mode 100644 index 000000000..50fc34094 --- /dev/null +++ b/apps/web/src/icons/gas.svg @@ -0,0 +1,6 @@ + + + + + + diff --git a/packages/api/src/routers/block/getGasPrice.ts b/packages/api/src/routers/block/getGasPrice.ts new file mode 100644 index 000000000..c2ccaefb1 --- /dev/null +++ b/packages/api/src/routers/block/getGasPrice.ts @@ -0,0 +1,7 @@ +import { prisma } from "@blobscan/db"; + +import { publicProcedure } from "../../procedures"; + +export const getLatestBlock = publicProcedure.query(async () => { + return await prisma.block.findLatest(); +}); diff --git a/packages/api/src/routers/block/index.ts b/packages/api/src/routers/block/index.ts index 2397f8a02..7c32e2cd7 100644 --- a/packages/api/src/routers/block/index.ts +++ b/packages/api/src/routers/block/index.ts @@ -1,8 +1,10 @@ import { t } from "../../trpc-client"; import { getAll } from "./getAll"; import { getByBlockId } from "./getByBlockId"; +import { getLatestBlock } from "./getGasPrice"; export const blockRouter = t.router({ getAll, getByBlockId, + getLatestBlock, });