Skip to content

Commit a6bb384

Browse files
committed
feat: implement Explorer
1 parent 29ad41a commit a6bb384

File tree

32 files changed

+3746
-55
lines changed

32 files changed

+3746
-55
lines changed

Cargo.lock

Lines changed: 1162 additions & 33 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ members = [
1515
"indexer_service",
1616
"indexer_service/protocol",
1717
"indexer_service/rpc",
18+
"explorer_service",
1819
"program_methods",
1920
"program_methods/guest",
2021
"test_program_methods",
@@ -114,3 +115,10 @@ actix-web = { version = "=4.1.0", default-features = false, features = [
114115
] }
115116
clap = { version = "4.5.42", features = ["derive", "env"] }
116117
reqwest = { version = "0.12", features = ["json", "rustls-tls", "stream"] }
118+
119+
# Profile for leptos WASM release builds
120+
[profile.wasm-release]
121+
inherits = "release"
122+
opt-level = 'z'
123+
lto = true
124+
codegen-units = 1

explorer_service/.gitignore

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Leptos build outputs
2+
/target
3+
/pkg
4+
/site
5+
6+
# WASM artifacts
7+
*.wasm
8+
9+
# Environment
10+
.env
11+
.env.local

explorer_service/Cargo.toml

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
[package]
2+
name = "explorer_service"
3+
version = "0.1.0"
4+
edition = "2024"
5+
6+
[lib]
7+
crate-type = ["cdylib", "rlib"]
8+
9+
[dependencies]
10+
indexer_service_protocol.workspace = true
11+
12+
# Leptos framework
13+
leptos = "0.8.15"
14+
leptos_meta = "0.8.5"
15+
leptos_router = "0.8.11"
16+
17+
# Serialization
18+
serde.workspace = true
19+
20+
# Logging
21+
log.workspace = true
22+
console_error_panic_hook = "0.1"
23+
console_log = "1.0"
24+
25+
# Date/Time
26+
chrono.workspace = true
27+
28+
# Hex encoding/decoding
29+
hex.workspace = true
30+
31+
# URL encoding
32+
urlencoding = "2.1"
33+
34+
# WASM-specific
35+
wasm-bindgen = "0.2"
36+
web-sys = { version = "0.3", features = [
37+
"Window",
38+
"Document",
39+
"Location",
40+
"HtmlInputElement",
41+
] }
42+
43+
# Server-side dependencies (optional, enabled by features)
44+
indexer_service_rpc = { workspace = true, features = [
45+
"client",
46+
], optional = true }
47+
jsonrpsee = { workspace = true, features = ["http-client"], optional = true }
48+
tokio = { workspace = true, optional = true }
49+
axum = { version = "0.8.8", optional = true }
50+
leptos_axum = { version = "0.8.7", optional = true }
51+
clap = { workspace = true, features = ["derive"], optional = true }
52+
url = { workspace = true, optional = true }
53+
env_logger = { workspace = true, optional = true }
54+
55+
[features]
56+
hydrate = ["leptos/hydrate"]
57+
ssr = [
58+
"leptos/ssr",
59+
"dep:indexer_service_rpc",
60+
"dep:jsonrpsee",
61+
"dep:tokio",
62+
"dep:axum",
63+
"dep:leptos_axum",
64+
"dep:clap",
65+
"dep:url",
66+
"dep:env_logger",
67+
]
68+
69+
[package.metadata.leptos]
70+
bin-features = ["ssr"]
71+
lib-features = ["hydrate"]
72+
assets-dir = "public"

explorer_service/Dockerfile

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
FROM rust:1.91.1-trixie AS builder
2+
3+
# Install cargo-binstall, which makes it easier to install other
4+
# cargo extensions like cargo-leptos
5+
RUN wget https://github.com/cargo-bins/cargo-binstall/releases/latest/download/cargo-binstall-x86_64-unknown-linux-musl.tgz
6+
RUN tar -xvf cargo-binstall-x86_64-unknown-linux-musl.tgz
7+
RUN cp cargo-binstall /usr/local/cargo/bin
8+
9+
# Install required tools
10+
RUN apt-get update -y \
11+
&& apt-get install -y --no-install-recommends clang
12+
13+
# Install cargo-leptos
14+
RUN cargo binstall cargo-leptos -y
15+
16+
# Add the WASM target
17+
RUN rustup target add wasm32-unknown-unknown
18+
19+
# Make an /explorer_service dir, which everything will eventually live in
20+
RUN mkdir -p /explorer_service
21+
WORKDIR /explorer_service
22+
COPY . .
23+
24+
# Build the app
25+
RUN cargo leptos build --release -vv
26+
27+
FROM debian:trixie-slim AS runtime
28+
WORKDIR /explorer_service
29+
RUN apt-get update -y \
30+
&& apt-get install -y --no-install-recommends openssl ca-certificates \
31+
&& apt-get autoremove -y \
32+
&& apt-get clean -y \
33+
&& rm -rf /var/lib/apt/lists/*
34+
35+
# Copy the server binary to the /explorer_service directory
36+
COPY --from=builder /explorer_service/target/release/explorer_service /explorer_service/
37+
38+
# /target/site contains our JS/WASM/CSS, etc.
39+
COPY --from=builder /explorer_service/target/site /explorer_service/site
40+
41+
# Copy Cargo.toml as it’s needed at runtime
42+
COPY --from=builder /explorer_service/Cargo.toml /explorer_service/
43+
44+
# Set any required env variables
45+
ENV RUST_LOG="info"
46+
ENV LEPTOS_SITE_ADDR="0.0.0.0:8080"
47+
ENV LEPTOS_SITE_ROOT="site"
48+
ENV INDEXER_RPC_URL="http://localhost:8779"
49+
EXPOSE 8080
50+
51+
# Run the server
52+
CMD ["/explorer_service/explorer_service"]

explorer_service/README.md

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
# LEE Blockchain Explorer
2+
3+
A web-based UI for exploring the blockchain state, built with Rust and Leptos framework.
4+
5+
## Features
6+
7+
- **Main Page**: Search for blocks, transactions, or accounts by hash/ID. View recent blocks.
8+
- **Block Page**: View detailed block information and all transactions within a block.
9+
- **Transaction Page**: View transaction details including type, accounts involved, and proofs.
10+
- **Account Page**: View account state and transaction history.
11+
12+
## Architecture
13+
14+
- **Framework**: Leptos 0.8 with SSR (Server-Side Rendering) and hydration
15+
- **Data Source**: Indexer Service JSON-RPC API
16+
- **Components**: Reusable BlockPreview, TransactionPreview, and AccountPreview components
17+
- **Styling**: Custom CSS with responsive design
18+
19+
## Development
20+
21+
### Prerequisites
22+
23+
- Rust (stable or nightly)
24+
- `cargo-leptos` tool: `cargo install cargo-leptos`
25+
- Running indexer service at `http://localhost:8080/rpc` (or configure via `INDEXER_RPC_URL`)
26+
27+
### Build and Run
28+
29+
```bash
30+
# Development mode (with hot-reload)
31+
cargo leptos watch
32+
33+
# Production build
34+
cargo leptos build --release
35+
36+
# Run production build
37+
cargo leptos serve --release
38+
```
39+
40+
The explorer will be available at `http://localhost:3000` by default.
41+
42+
### Configuration
43+
44+
Set the `INDEXER_RPC_URL` environment variable to point to your indexer service:
45+
46+
```bash
47+
export INDEXER_RPC_URL=http://localhost:8080/rpc
48+
cargo leptos watch
49+
```
50+
51+
## Features
52+
53+
### Search
54+
55+
The search bar supports:
56+
- Block IDs (numeric)
57+
- Block hashes (64-character hex)
58+
- Transaction hashes (64-character hex)
59+
- Account IDs (64-character hex)
60+
61+
### Real-time Updates
62+
63+
The main page loads recent blocks and can be extended to subscribe to new blocks via WebSocket.
64+
65+
### Responsive Design
66+
67+
The UI is mobile-friendly and adapts to different screen sizes.
68+
69+
## License
70+
71+
See LICENSE file in the repository root.
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
services:
2+
explorer_service:
3+
image: lssa/explorer_service
4+
build:
5+
context: ..
6+
dockerfile: explorer_service/Dockerfile
7+
container_name: explorer_service
8+
environment:
9+
INDEXER_RPC_URL: ${INDEXER_RPC_URL:-http://localhost:8779}
10+
ports:
11+
- "8080:8080"

0 commit comments

Comments
 (0)