Skip to content
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
d8db6e3
fix: replace edge middleware with route handler for explorer API proxy
danieljrc888 Mar 11, 2026
70d96b4
feat: enhance explorer with value formatting, search, syntax highligh…
danieljrc888 Mar 11, 2026
fe48614
revert: remove route handler, restore middleware from PR #1522
danieljrc888 Mar 11, 2026
9870d93
fix: address PR review feedback
danieljrc888 Mar 11, 2026
6fa96f3
fix: address remaining PR review comments
danieljrc888 Mar 12, 2026
38a7103
feat(simulator): allow disconnecting external wallets
danieljrc888 Mar 12, 2026
7552b8a
feat(explorer): add unified address page with contract/validator/acco…
danieljrc888 Mar 12, 2026
b501a70
feat(explorer): enhance dashboard with TPS stat and 14-day volume chart
danieljrc888 Mar 12, 2026
f9902e8
feat(explorer): replace status dropdown with tab-based transaction fi…
danieljrc888 Mar 12, 2026
3955ee8
feat(explorer): enhance global search with validators and quick links
danieljrc888 Mar 12, 2026
a786a8f
refactor(explorer): remove PATCH/DELETE tx endpoints, rename /state t…
danieljrc888 Mar 12, 2026
b3f6672
test(explorer): add comprehensive tests for explorer query layer
danieljrc888 Mar 12, 2026
c3b2a00
refactor(explorer): move transaction journey from monitoring to overv…
danieljrc888 Mar 12, 2026
b7cfaee
fix(explorer): move transaction journey to bottom of overview tab
danieljrc888 Mar 12, 2026
4f6c2e9
fix(explorer): fill 14-day volume chart with zeros up to current date
danieljrc888 Mar 12, 2026
487cdf6
perf(explorer): convert pages to server components and optimize data …
danieljrc888 Mar 12, 2026
a763a5e
fix(explorer): disable server-side caching to prevent stale data
danieljrc888 Mar 12, 2026
357267e
fix(explorer): address PR review comments
danieljrc888 Mar 12, 2026
1294237
Merge remote-tracking branch 'origin/main' into feat/explorer-phase2-…
danieljrc888 Mar 12, 2026
4c96c2c
style: format Python files with Black
danieljrc888 Mar 12, 2026
cbb111e
perf(explorer): render dashboard sections async with Suspense streaming
danieljrc888 Mar 13, 2026
3733326
fix(explorer): pass icon names as strings to avoid Server→Client seri…
danieljrc888 Mar 13, 2026
5c634c7
Merge remote-tracking branch 'origin/main' into feat/explorer-phase2-…
danieljrc888 Mar 13, 2026
b1926f7
feat(explorer): rebrand header with GenLayer logo and Switzer font
danieljrc888 Mar 13, 2026
49ca18b
feat(explorer): migrate middleware to proxy convention
danieljrc888 Mar 13, 2026
9252af7
fix(explorer): resolve SSR hydration and undefined property errors
danieljrc888 Mar 13, 2026
7cafc87
feat(explorer): add calldata decoding and InputDataPanel for transact…
danieljrc888 Mar 13, 2026
170abf1
feat(explorer): add Method column to transaction tables
danieljrc888 Mar 13, 2026
2973015
feat(explorer): add Code/Read/Write Contract tabs using genlayer-js SDK
danieljrc888 Mar 13, 2026
f27268a
fix(explorer): address PR review issues
danieljrc888 Mar 13, 2026
2ac4a9d
refactor(explorer): extract reusable hooks for SRP and DRY
danieljrc888 Mar 13, 2026
355e1f0
refactor(explorer): extract AddressDisplay component to eliminate dup…
danieljrc888 Mar 13, 2026
f752eb4
refactor(explorer): split MonitoringTab into focused sub-components
danieljrc888 Mar 13, 2026
20c25a7
refactor(explorer): extract MethodForm and StatItem as shared components
danieljrc888 Mar 13, 2026
f3896e2
Revert "feat(simulator): allow disconnecting external wallets"
danieljrc888 Mar 15, 2026
3477d76
Merge branch 'main' into feat/explorer-phase2-enhancements
cristiam86 Mar 16, 2026
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
334 changes: 292 additions & 42 deletions backend/protocol_rpc/explorer/queries.py

Large diffs are not rendered by default.

100 changes: 28 additions & 72 deletions backend/protocol_rpc/explorer/router.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
"""FastAPI router for the explorer API."""

from typing import Annotated, Optional
from typing import Annotated, Literal, Optional

from fastapi import APIRouter, Depends, HTTPException, Query
from pydantic import BaseModel
from sqlalchemy import text
from sqlalchemy.orm import Session

from backend.database_handler.models import Transactions, TransactionStatus, Validators
from backend.protocol_rpc.dependencies import get_db_session

from . import queries
Expand Down Expand Up @@ -42,8 +39,12 @@ def get_transactions(
limit: int = Query(20, ge=1, le=100),
status: Optional[str] = None,
search: Optional[str] = None,
from_date: Optional[str] = None,
to_date: Optional[str] = None,
):
return queries.get_all_transactions_paginated(session, page, limit, status, search)
return queries.get_all_transactions_paginated(
session, page, limit, status, search, from_date, to_date
)


@explorer_router.get("/transactions/{tx_hash}")
Expand All @@ -57,96 +58,51 @@ def get_transaction(
return result


class _UpdateStatusBody(BaseModel):
status: str
# ---------------------------------------------------------------------------
# Validators
# ---------------------------------------------------------------------------


@explorer_router.patch("/transactions/{tx_hash}")
def update_transaction(
tx_hash: str,
body: _UpdateStatusBody,
@explorer_router.get("/validators")
def get_validators(
session: Annotated[Session, Depends(get_db_session)],
search: Optional[str] = None,
limit: Optional[int] = Query(None, ge=1, le=100),
):
# Validate status enum
try:
new_status = TransactionStatus(body.status)
except ValueError:
valid = [s.value for s in TransactionStatus]
raise HTTPException(
status_code=400,
detail=f"Invalid status. Must be one of: {', '.join(valid)}",
) from None

# Simple status update (matches current explorer PATCH behaviour)
result = session.execute(
text(
"UPDATE transactions SET status = CAST(:new_status AS transaction_status) WHERE hash = :hash"
),
{"hash": tx_hash, "new_status": new_status.value},
)

if result.rowcount == 0:
raise HTTPException(status_code=404, detail="Transaction not found")
return queries.get_all_validators(session, search=search, limit=limit)

session.flush()

# Return the updated transaction
tx = session.query(Transactions).filter(Transactions.hash == tx_hash).first()
return {
"success": True,
"message": "Transaction status updated successfully",
"transaction": queries._serialize_tx(tx),
}
# ---------------------------------------------------------------------------
# Address (unified lookup)
# ---------------------------------------------------------------------------


@explorer_router.delete("/transactions/{tx_hash}")
def delete_transaction(
tx_hash: str,
@explorer_router.get("/address/{address}")
def get_address(
address: str,
session: Annotated[Session, Depends(get_db_session)],
):
result = queries.delete_transaction(session, tx_hash)
result = queries.get_address_info(session, address)
if result is None:
raise HTTPException(status_code=404, detail="Transaction not found")
raise HTTPException(status_code=404, detail="Address not found")
return result


# ---------------------------------------------------------------------------
# Validators
# ---------------------------------------------------------------------------


@explorer_router.get("/validators")
def get_validators(session: Annotated[Session, Depends(get_db_session)]):
validators = session.query(Validators).order_by(Validators.id).all()
return {
"validators": [queries._serialize_validator(v) for v in validators],
}


# ---------------------------------------------------------------------------
# State
# Contracts
# ---------------------------------------------------------------------------


@explorer_router.get("/state")
def get_states(
@explorer_router.get("/contracts")
def get_contracts(
session: Annotated[Session, Depends(get_db_session)],
search: Optional[str] = None,
page: int = Query(1, ge=1),
limit: int = Query(20, ge=1, le=100),
sort_by: Optional[Literal["tx_count", "created_at", "updated_at"]] = None,
sort_order: Literal["asc", "desc"] = "desc",
):
return queries.get_all_states(session, search, page, limit)


@explorer_router.get("/state/{state_id}")
def get_state(
state_id: str,
session: Annotated[Session, Depends(get_db_session)],
):
result = queries.get_state_with_transactions(session, state_id)
if result is None:
raise HTTPException(status_code=404, detail="State not found")
return result
return queries.get_all_states(session, search, page, limit, sort_by, sort_order)


# ---------------------------------------------------------------------------
Expand Down
3 changes: 3 additions & 0 deletions explorer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"@radix-ui/react-collapsible": "^1.1.12",
"@radix-ui/react-dialog": "^1.1.15",
"@radix-ui/react-dropdown-menu": "^2.1.16",
"@radix-ui/react-popover": "^1.1.15",
"@radix-ui/react-select": "^2.2.6",
"@radix-ui/react-separator": "^1.1.8",
"@radix-ui/react-slot": "^1.2.4",
Expand All @@ -25,7 +26,9 @@
"next": "16.1.6",
"next-themes": "^0.4.6",
"react": "19.2.4",
"react-day-picker": "^9.14.0",
"react-dom": "19.2.4",
"shiki": "^4.0.2",
"tailwind-merge": "^3.5.0"
},
"devDependencies": {
Expand Down
Loading