Skip to content

Commit 95583dd

Browse files
committed
feat: add navigation arrows to blob details page
1 parent 82ef0ea commit 95583dd

File tree

2 files changed

+38
-33
lines changed

2 files changed

+38
-33
lines changed

apps/web/src/pages/blob/[hash].tsx

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,24 @@ const Blob: NextPage = function () {
5959
);
6060

6161
const { data: neighbors } = api.blob.getBlobNeighbours.useQuery(
62-
{
63-
commitment: blob ? blob.commitment : "",
64-
},
62+
blob &&
63+
blob.transactions[0] &&
64+
blob.transactions[0].from &&
65+
blob.transactions[0].index !== undefined
66+
? {
67+
txHash: blob.transactions[0].hash,
68+
commitment: blob.commitment,
69+
transactionIndex: blob.transactions[0].index,
70+
senderAddress: blob.transactions[0].from,
71+
blockNumber: blob.transactions[0].blockNumber,
72+
}
73+
: {
74+
txHash: "",
75+
commitment: "",
76+
transactionIndex: 0,
77+
senderAddress: "",
78+
blockNumber: 0,
79+
},
6580
{
6681
enabled: Boolean(router.isReady && blob && blob.transactions[0]),
6782
}

packages/api/src/routers/blob/getBlobNeighbours.ts

Lines changed: 20 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ import { z } from "@blobscan/zod";
44
import { publicProcedure } from "../../procedures";
55

66
const inputSchema = z.object({
7+
txHash: z.string(),
8+
transactionIndex: z.number(),
9+
senderAddress: z.string(),
10+
blockNumber: z.number(),
711
commitment: z.string(),
812
});
913

@@ -61,36 +65,22 @@ async function getBlobNeighbor(
6165
// Next/prev transaction
6266
{
6367
transaction: {
64-
fromId: blob.transaction.fromId,
65-
OR:
66-
blob.transaction.index !== null
67-
? [
68-
{
69-
blockNumber:
70-
direction === "next"
71-
? { gt: blob.blockNumber }
72-
: { lt: blob.blockNumber },
73-
},
74-
{
75-
AND: [
76-
{ blockNumber: blob.blockNumber },
77-
{
78-
index:
79-
direction === "next"
80-
? { gt: blob.transaction.index }
81-
: { lt: blob.transaction.index },
82-
},
83-
],
84-
},
85-
]
86-
: [
87-
{
88-
blockNumber:
89-
direction === "next"
90-
? { gt: blob.blockNumber }
91-
: { lt: blob.blockNumber },
92-
},
93-
],
68+
fromId: input.senderAddress,
69+
OR: [
70+
{
71+
blockNumber:
72+
direction === "next"
73+
? { gt: input.blockNumber }
74+
: { lt: input.blockNumber },
75+
},
76+
{
77+
blockNumber: input.blockNumber,
78+
index:
79+
direction === "next"
80+
? { gt: input.transactionIndex }
81+
: { lt: input.transactionIndex },
82+
},
83+
],
9484
},
9585
},
9686
],

0 commit comments

Comments
 (0)