Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add navigation arrows to blob details page #560

Open
wants to merge 52 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
dc90e08
feat: add navigation arrows to blob details page
luis-herasme Sep 10, 2024
37a9a2f
refactor: send only the commitment
luis-herasme Sep 10, 2024
819ced4
getBlobNeighbours to remove sorting by blockNumber
luis-herasme Sep 10, 2024
02e39b7
refactor: add loading spinner to blob details page
luis-herasme Sep 12, 2024
7bea8aa
Merge branch 'main' into next-blob
luis-herasme Sep 22, 2024
047a55a
ci: deploy to Vercel using git tags (like v0.1.0) (#555)
PabloCastellano Sep 23, 2024
0e839f7
refactor: Update styling in BlobCard and BlockCard components (#580)
luis-herasme Sep 25, 2024
553fd12
feat(api): add `count` query parameter (#577)
PJColombo Sep 25, 2024
9558afd
test(api): re-add missing snapshot files
PJColombo Sep 25, 2024
f1c9406
perf: decouple item counting logic from data fetching (#581)
PJColombo Sep 26, 2024
3c17ee0
feat(db): add tx index to `BlobsOnTransactions` model (#584)
PJColombo Sep 26, 2024
a9df38f
perf(db): update indexes (#585)
PJColombo Sep 30, 2024
c78c589
docs: update about storages
PabloCastellano Oct 2, 2024
347a663
feat: add category and rollup stats (#576)
PJColombo Oct 4, 2024
1bfe801
ci: revert: pull_request_target -> pull_request
PabloCastellano Oct 5, 2024
247341b
chore(ci): fix GitHub action workflows (#588)
PJColombo Oct 5, 2024
ef0664e
test: fix tests (#589)
PJColombo Oct 6, 2024
4ff01c1
chore(blob-decoder): fix majin blob mismatch version
PJColombo Oct 6, 2024
b9587f9
chore(docker): set up PostgreSQL and pass the DB connection to Docker…
PJColombo Oct 6, 2024
8391a1a
chore(docker): add missing set up action to docker release workflow
PJColombo Oct 6, 2024
c058475
chore(docker): fix misplaced env var
PJColombo Oct 6, 2024
6709e50
ci: postgres service
PabloCastellano Oct 7, 2024
518e030
ci: run postgres in host network
PabloCastellano Oct 7, 2024
0beed6b
ci: deploy to vercel using github actions
PabloCastellano Oct 7, 2024
5e5e84a
ci: install pnpm
PabloCastellano Oct 7, 2024
1efa2ce
ci: fix vercel.json
PabloCastellano Oct 7, 2024
fdd1e4f
ci: vercel requires prisma binary target rhel-openssl-1.0.x
PabloCastellano Oct 7, 2024
ef95086
chore: version packages (#489)
github-actions[bot] Oct 7, 2024
fae3200
ci: run CI workflow on tags too
PabloCastellano Oct 7, 2024
cb301b5
ci: tags is not needed in this workflow
PabloCastellano Oct 7, 2024
70545d7
ci: fix workflow to build docker image
PabloCastellano Oct 7, 2024
e1530d0
chore: update Dockerfile ENV to latest format
PabloCastellano Oct 7, 2024
21629c7
ci: fix changesets workflow
PabloCastellano Oct 7, 2024
34e7a73
ci: fix changesets workflow
PabloCastellano Oct 7, 2024
ed63d06
ci: fix changesets workflow
PabloCastellano Oct 7, 2024
80c1edf
ci: fix deploy-production workflow
PabloCastellano Oct 7, 2024
0906851
chore: lint dockerfile
PabloCastellano Oct 7, 2024
720ae95
fix: add musl binaryTarget to schema.prisma
PabloCastellano Oct 7, 2024
6a5583b
ci: nohup ./deploy-blobscan.sh
PabloCastellano Oct 8, 2024
a9311a1
docs: order sections (#587)
PabloCastellano Oct 13, 2024
82ef0ea
refactor: Simplify SurfaceCardBase component (#579)
luis-herasme Oct 13, 2024
95583dd
feat: add navigation arrows to blob details page
luis-herasme Sep 10, 2024
b31fb07
perf: decouple item counting logic from data fetching (#581)
PJColombo Sep 26, 2024
7d19c4e
feat(rollups): add missing sepolia rollups (#591)
PJColombo Oct 14, 2024
35f2b74
Posthog api (#578)
luis-herasme Oct 17, 2024
93ec38d
perf: decouple item counting logic from data fetching (#581)
PJColombo Sep 26, 2024
bd2f7de
perf: decouple item counting logic from data fetching (#581)
PJColombo Sep 26, 2024
32d7533
Merge branch 'main' into next-blob
luis-herasme Oct 19, 2024
901632f
Merge branch 'main' into next-blob
luis-herasme Oct 19, 2024
5d29910
merge main
luis-herasme Oct 19, 2024
523fcf5
chore: improve next/prev blob performance
luis-herasme Oct 20, 2024
19156df
Merge branch 'main' into next-blob
luis-herasme Nov 25, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 36 additions & 1 deletion apps/web/src/pages/blob/[hash].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,10 @@ import type { DropdownProps, Option } from "~/components/Dropdown";
import type { DetailsLayoutProps } from "~/components/Layouts/DetailsLayout";
import { DetailsLayout } from "~/components/Layouts/DetailsLayout";
import { Link } from "~/components/Link";
import { NavArrows } from "~/components/NavArrows";
import { BlockStatus } from "~/components/Status";
import { api } from "~/api-client";
import Loading from "~/icons/loading.svg";
import type { Rollup } from "~/types";
import {
buildBlockRoute,
Expand Down Expand Up @@ -56,6 +58,21 @@ const Blob: NextPage = function () {
(blobViewMode) => ({ value: blobViewMode })
);

const enabled = Boolean(router.isReady && blob && blob.transactions[0]);

const { data: neighbors } = api.blob.getBlobNeighbours.useQuery(
blob && blob.transactions[0]
? {
commitment: blob.commitment,
}
: {
commitment: "",
},
{
enabled,
}
);

useEffect(() => {
if (!decoder) {
return;
Expand Down Expand Up @@ -167,7 +184,25 @@ const Blob: NextPage = function () {
return (
<>
<DetailsLayout
header="Blob Details"
header={
<div className="flex items-center justify-start gap-4">
Blob Details
{neighbors ? (
<NavArrows
prev={{
href: neighbors?.prev ? `/blob/${neighbors.prev}` : undefined,
tooltip: "Previous blob from this sender",
}}
next={{
href: neighbors?.next ? `/blob/${neighbors.next}` : undefined,
tooltip: "Next blob from this sender",
}}
/>
) : (
<Loading className="h-5 w-5 animate-spin" />
)}
</div>
}
fields={blob ? detailsFields : undefined}
/>
<Card
Expand Down
101 changes: 101 additions & 0 deletions packages/api/src/routers/blob/getBlobNeighbours.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
import { prisma } from "@blobscan/db";
import { z } from "@blobscan/zod";

import { publicProcedure } from "../../procedures";

const inputSchema = z.object({
commitment: z.string(),
});

type Input = z.infer<typeof inputSchema>;

export const getBlobNeighbours = publicProcedure
.input(inputSchema)
.query(async ({ input }) => {
const [next, prev] = await Promise.all([
getBlobNeighbor(input, "next"),
getBlobNeighbor(input, "prev"),
]);

return {
next,
prev,
};
});

Check warning on line 24 in packages/api/src/routers/blob/getBlobNeighbours.ts

View check run for this annotation

Codecov / codecov/patch

packages/api/src/routers/blob/getBlobNeighbours.ts#L15-L24

Added lines #L15 - L24 were not covered by tests

async function getBlobNeighbor(
input: Input,
direction: "next" | "prev"
): Promise<string | null> {
const blob = await prisma.blobsOnTransactions.findFirst({
where: {
blob: {
commitment: input.commitment,
},
},
select: {
index: true,
blockNumber: true,
transaction: {
select: {
hash: true,
fromId: true,
index: true,
},
},
},
});

if (!blob) {
return null;
}

const nextBlobInTx = await prisma.blobsOnTransactions.findFirst({
where: {
OR: [
// Same transaction
{
txHash: blob.transaction.hash,
index: direction === "next" ? { gt: blob.index } : { lt: blob.index },
},
// Different transaction same block
blob.transaction.index
? {
blockNumber: blob.blockNumber,
transaction: {
fromId: blob.transaction.fromId,
},
txIndex:
direction === "next"
? { gt: blob.transaction.index }
: { lt: blob.transaction.index },
}
: {},
// Different block
{
blockNumber:
direction === "next"
? { gt: blob.blockNumber }
: { lt: blob.blockNumber },
transaction: {
fromId: blob.transaction.fromId,
},
},
],
},
select: {
blobHash: true,
txIndex: true,
},
orderBy:
direction === "next"
? [{ blockNumber: "asc" }, { index: "asc" }, { txIndex: "asc" }]
: [{ blockNumber: "desc" }, { index: "desc" }, { txIndex: "desc" }],
});

if (nextBlobInTx) {
return nextBlobInTx.blobHash;
}

return null;
}

Check warning on line 101 in packages/api/src/routers/blob/getBlobNeighbours.ts

View check run for this annotation

Codecov / codecov/patch

packages/api/src/routers/blob/getBlobNeighbours.ts#L26-L101

Added lines #L26 - L101 were not covered by tests
2 changes: 2 additions & 0 deletions packages/api/src/routers/blob/index.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import { t } from "../../trpc-client";
import { getAll } from "./getAll";
import { getBlobDataByBlobId } from "./getBlobDataByBlobId";
import { getBlobNeighbours } from "./getBlobNeighbours";
import { getByBlobId } from "./getByBlobId";
import { getCount } from "./getCount";

export const blobRouter = t.router({
getAll,
getByBlobId,
getBlobNeighbours,
getBlobDataByBlobId,
getCount,
});
Loading