Skip to content

Commit b603f2f

Browse files
committed
txid parsed correctly and links in details page made configurable
1 parent d492a52 commit b603f2f

File tree

7 files changed

+61
-52
lines changed

7 files changed

+61
-52
lines changed

backend/docker-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ services:
3030
container_name: batch_explorer_app
3131
environment:
3232
APP_DATABASE_URL: postgres://postgres:password@postgres:5432/batch_explorer_db
33-
STRATA_FULLNODE: "https://fnclientbcc5fe8c4454c314eb0a00cd3882.temp6-testnet1-staging.stratabtc.org/"
33+
STRATA_FULLNODE: "https://strataseq.temp6-testnet1-staging.stratabtc.org/"
3434
APP_FETCH_INTERVAL : 5
3535
ports:
3636
- "3000:3000"

backend/model/src/checkpoint.rs

Lines changed: 21 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,24 @@ pub struct RpcCheckpointInfo {
2121
/// The L2 height range that the checkpoint covers (start, end)
2222
pub l2_range: (L2BlockCommitment, L2BlockCommitment),
2323
/// Info on txn where checkpoint is committed on chain
24-
pub commitment: Option<RpcCheckpointCommitmentInfo>,
24+
pub l1_reference: Option<CheckpointL1Ref>,
2525
/// Confirmation status of checkpoint
2626
pub confirmation_status: Option<RpcCheckpointConfStatus>,
2727
}
2828

2929
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
3030
pub struct L1BlockCommitment {
31-
height: u64,
32-
blkid: L1BlockId,
31+
pub height: u64,
32+
pub blkid: L1BlockId,
33+
}
34+
35+
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
36+
pub struct Buf32(pub [u8; 32]);
37+
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
38+
pub struct CheckpointL1Ref {
39+
pub l1_commitment: L1BlockCommitment,
40+
pub txid: String,
41+
pub wtxid: String,
3342
}
3443
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
3544
pub struct L2BlockCommitment {
@@ -72,24 +81,6 @@ impl Display for RpcCheckpointConfStatus {
7281
}
7382
}
7483

75-
#[derive(Clone, Debug, Deserialize, Serialize)]
76-
pub struct RpcCheckpointCommitmentInfo {
77-
/// block where checkpoint was posted
78-
pub blockhash: String,
79-
80-
/// txid of txn for this checkpoint
81-
pub txid: String,
82-
83-
/// wtxid of txn for this checkpoint
84-
pub wtxid: String,
85-
86-
/// The height of the block where the checkpoint was posted.
87-
pub height: u64,
88-
89-
/// The position of the checkpoint in the block.
90-
pub position: u32,
91-
}
92-
9384
#[derive(
9485
Clone, Debug, PartialEq, DeriveEntityModel, DeriveActiveModelBehavior, Serialize, Deserialize,
9586
)]
@@ -117,7 +108,7 @@ impl From<RpcCheckpointInfo> for ActiveModel {
117108
l2_start: Set(PgU64(info.l2_range.0.slot).to_i64()),
118109
l2_end: Set(PgU64(info.l2_range.1.slot).to_i64()),
119110
batch_txid: Set(info
120-
.commitment
111+
.l1_reference
121112
.as_ref()
122113
.map_or("-".to_string(), |c| c.txid.clone())), // Extracting `txid`
123114
status: Set(info
@@ -138,7 +129,7 @@ pub struct RpcCheckpointInfoBatchExp {
138129
/// The L2 height range that the checkpoint covers (start, end)
139130
pub l2_range: (u64, u64),
140131
/// Info on txn where checkpoint is committed on chain
141-
pub commitment: Option<RpcCheckpointCommitmentInfo>,
132+
pub l1_reference: Option<CheckpointL1Ref>,
142133
/// Confirmation status of checkpoint
143134
pub confirmation_status: Option<RpcCheckpointConfStatus>,
144135
}
@@ -155,12 +146,13 @@ impl From<Model> for RpcCheckpointInfoBatchExp {
155146
PgU64::from_i64(model.l2_start).0,
156147
PgU64::from_i64(model.l2_end).0,
157148
),
158-
commitment: Some(RpcCheckpointCommitmentInfo {
159-
blockhash: String::new(),
160-
txid: model.batch_txid,
161-
wtxid: String::new(),
162-
height: 0,
163-
position: 0,
149+
l1_reference: Some(CheckpointL1Ref {
150+
l1_commitment: L1BlockCommitment {
151+
height: 0,
152+
blkid: "dummy".to_string(),
153+
},
154+
txid: model.batch_txid.clone(),
155+
wtxid: "dummy".to_string(),
164156
}),
165157
confirmation_status: model.status.parse().ok(), // Convert status string to `RpcCheckpointConfStatus`
166158
}

docker-compose.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ services:
3030
container_name: batch_explorer_backend
3131
environment:
3232
APP_DATABASE_URL: postgres://postgres:password@postgres:5432/batch_explorer_db
33-
STRATA_FULLNODE: "http://localhost:62095"
33+
STRATA_FULLNODE: "https://strataseq.temp6-testnet1-staging.stratabtc.org/"
3434
APP_FETCH_INTERVAL: 5
3535
ports:
3636
- "3000:3000"
@@ -49,8 +49,8 @@ services:
4949
- "5173:5173"
5050
environment:
5151
VITE_API_BASE_URL: http://localhost:3000
52-
VITE_BLOCKSCOUT_BASE_URL: https://blockscout.com/eth/mainnet/
53-
VITE_MEMPOOL_BASE_URL: https://explorer2dfa0bab08.temp6-testnet1-staging.stratabtc.org/
52+
VITE_BLOCKSCOUT_BASE_URL: https://blockscout.temp6-testnet1-staging.stratabtc.org/
53+
VITE_MEMPOOL_BASE_URL: https://mempool0713bb23.temp6-testnet1-staging.stratabtc.org/
5454
VITE_REFRESH_INTERVAL: 10000
5555
command: ["npm", "run", "dev", "--", "--host"]
5656

frontend/src/components/CheckpointDetails/index.tsx

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ import { useEffect, useState } from "react";
22
import { useSearchParams } from "react-router-dom";
33
import styles from "../../styles/CheckpointDetails.module.css";
44
import { RpcCheckpointInfoBatchExp } from "../../types";
5+
import { reverseEndian } from "../../utils/lib";
56
import Pagination from "../Paginator/Pagination/index";
6-
77
const CheckpointDetails = () => {
88
const [searchParams] = useSearchParams();
99
const page = searchParams.get("p"); // Get the "p" query parameter
@@ -15,6 +15,9 @@ const CheckpointDetails = () => {
1515
const [firstPage, setFirstPage] = useState(0);
1616
const rowsPerPage = 1; // Fixed value
1717

18+
const MEMPOOL_BASE_URL = import.meta.env.VITE_MEMPOOL_BASE_URL || "https://default-mempool-url.com";
19+
const BLOCKSCOUT_BASE_URL = import.meta.env.VITE_BLOCKSCOUT_BASE_URL || "https://default-blockscout-url.com";
20+
1821
useEffect(() => {
1922
// Convert the query param `p` to a number
2023
const pageNumber = Number(page);
@@ -51,7 +54,14 @@ const CheckpointDetails = () => {
5154
<div className={styles.checkpointContainer}>
5255
<div className={styles.checkpointRow}>
5356
<span className={styles.checkpointLabel}>Batch TXID:</span>
54-
<span className={styles.checkpointValue}>{checkpoint.commitment?.txid}</span>
57+
<a
58+
href={`${MEMPOOL_BASE_URL}tx/${reverseEndian(checkpoint.l1_reference?.txid)}`}
59+
target="_blank"
60+
rel="noreferrer"
61+
>
62+
{reverseEndian(checkpoint.l1_reference?.txid)}
63+
</a>
64+
5565
</div>
5666
<div className={styles.checkpointRow}>
5767
<span className={styles.checkpointLabel}>Epoch index:</span>
@@ -65,7 +75,7 @@ const CheckpointDetails = () => {
6575
<span className={styles.checkpointLabel}>Signet start block:</span>
6676
<span className={styles.checkpointValue}>
6777
<a
68-
href={`https://mempool0713bb23.devnet-annapurna.stratabtc.org/block/${checkpoint.l1_range[0]}`}
78+
href={`${MEMPOOL_BASE_URL}block/${checkpoint.l1_range[0]}`}
6979
target="_blank"
7080
rel="noreferrer"
7181
>
@@ -77,7 +87,7 @@ const CheckpointDetails = () => {
7787
<span className={styles.checkpointLabel}>Signet end block:</span>
7888
<span className={styles.checkpointValue}>
7989
<a
80-
href={`https://mempool0713bb23.devnet-annapurna.stratabtc.org/block/${checkpoint.l1_range[1]}`}
90+
href={`${MEMPOOL_BASE_URL}block/${checkpoint.l1_range[1]}`}
8191
target="_blank"
8292
rel="noreferrer"
8393
>
@@ -89,7 +99,7 @@ const CheckpointDetails = () => {
8999
<span className={styles.checkpointLabel}>Strata start block:</span>
90100
<span className={styles.checkpointValue}>
91101
<a
92-
href={`https://blockscoutb86fae58ae.devnet-annapurna.stratabtc.org/block/${checkpoint.l2_range[0]}`}
102+
href={`${BLOCKSCOUT_BASE_URL}block/${checkpoint.l2_range[0]}`}
93103
target="_blank"
94104
rel="noreferrer"
95105
>
@@ -101,7 +111,7 @@ const CheckpointDetails = () => {
101111
<span className={styles.checkpointLabel}>Strata end block:</span>
102112
<span className={styles.checkpointValue}>
103113
<a
104-
href={`https://blockscoutb86fae58ae.devnet-annapurna.stratabtc.org/block/${checkpoint.l2_range[1]}`}
114+
href={`${BLOCKSCOUT_BASE_URL}block/${checkpoint.l2_range[1]}`}
105115
target="_blank"
106116
rel="noreferrer"
107117
>

frontend/src/components/Table/TableBody/index.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { useEffect, useState } from "react";
22
import { Link, useSearchParams } from "react-router-dom";
33
import { RpcCheckpointInfoBatchExp } from "../../../types";
4-
import { shortenIds } from "../../../utils/lib";
4+
import { reverseEndian, shortenIds } from "../../../utils/lib";
55
import Pagination from "../../Paginator/Pagination";
66
import styles from "./Table.module.css";
77
const TableBody: React.FC = () => {
@@ -81,9 +81,9 @@ const TableBody: React.FC = () => {
8181
<tbody>
8282
{data.map((checkpoint) => (
8383
<tr className={styles.tableRowItems} key={checkpoint.idx}>
84-
<td className={styles.tableCell} title={checkpoint.commitment?.txid}>
85-
<a href={`${MEMPOOL_BASE_URL}tx/${checkpoint.commitment?.txid}`} target="_blank" rel="noreferrer">
86-
{shortenIds(checkpoint.commitment?.txid)}
84+
<td className={styles.tableCell} title={checkpoint.l1_reference?.txid}>
85+
<a href={`${MEMPOOL_BASE_URL}tx/${reverseEndian(checkpoint.l1_reference?.txid)}`} target="_blank" rel="noreferrer">
86+
{shortenIds(reverseEndian(checkpoint.l1_reference?.txid))}
8787
</a>
8888
</td>
8989
<td className={styles.tableCell}>

frontend/src/types/index.tsx

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ export interface RpcCheckpointInfoBatchExp {
33
l1_range: [number, number]; // L1 height range (start, end)
44
l2_range: [number, number]; // L2 height range (start, end)
55
l2_blockid: string; // L2 block ID
6-
commitment?: RpcCheckpointCommitmentInfo;
6+
l1_reference?: CheckpointL1Ref;
77
confirmation_status?: string;
88
}
99

@@ -14,11 +14,13 @@ export interface PaginatedData<T> {
1414
items: T[], // The items for the current page
1515
}
1616

17-
export interface RpcCheckpointCommitmentInfo {
18-
blockhash: string;
19-
// for batch explorer `txid` is the only thing we care about.
20-
txid: string
21-
wtxid: string
22-
height: number,
23-
position: number,
17+
export interface CheckpointL1Ref {
18+
l1_commitment: L1BlockCommitment;
19+
txid: string;
20+
wtxid: string;
21+
}
22+
23+
export interface L1BlockCommitment {
24+
height: number;
25+
blkid: string;
2426
}

frontend/src/utils/lib.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,9 @@ function isRpcCheckpointInfo(data: any): data is RpcCheckpointInfoBatchExp[] {
2222
typeof data[0].l2_blockid === "string"
2323
);
2424
}
25-
export { isRpcCheckpointInfo, shortenIds };
25+
function reverseEndian(value: string | null | undefined): string {
26+
if (!value) return "N/A";
27+
return value.match(/.{2}/g)!.reverse().join("");
28+
}
29+
export { isRpcCheckpointInfo, reverseEndian, shortenIds };
30+

0 commit comments

Comments
 (0)