Skip to content

feat: routes and transaction status APIs#180

Merged
filo87 merged 11 commits intomainfrom
routes-api
Apr 9, 2026
Merged

feat: routes and transaction status APIs#180
filo87 merged 11 commits intomainfrom
routes-api

Conversation

@hieronx
Copy link
Copy Markdown
Collaborator

@hieronx hieronx commented Nov 6, 2025

Implements API routes that match the interface from https://docs.glacislabs.com/architecture-overview/off-chain-interface

@hieronx hieronx marked this pull request as draft November 6, 2025 20:54
@filo87
Copy link
Copy Markdown
Collaborator

filo87 commented Apr 9, 2026

Glacis-style routes API and HTTP refactor

Summary

This PR adds JSON endpoints for cross-chain route discovery, transaction lookup, and quotes, and splits the Ponder HTTP app so token and stats handlers live in dedicated modules. Indexing and services are extended just enough to support those flows (including GasService on v3.1 and safer contract address resolution).

Motivation

  • Expose bridge-oriented data (routes, quotes, tx correlation) for integrators without cramming everything into src/api/index.ts.
  • Validate query parameters with a small, explicit stack (zod + @hono/standard-validator).
  • Align the indexer with contracts needed for gas / messaging estimates where applicable.

Changes

HTTP API

  • src/api/index.ts — Keeps GraphQL and /sql/* mounts; composes three Hono sub-apps: /tokens, / (Glacis-style routes mounted at root), and /stats.
  • src/api/tokens.tsGET /tokens/:address/total-issuance and GET /tokens/:address/price (unchanged behavior, moved out of the monolith).
  • src/api/stats.tsGET /stats (unchanged behavior, moved out of the monolith).
  • src/api/glacis.ts — New:
    • GET /routes — Lists bridge-relevant token instance / token data with validated query params.
    • GET /transactions/:txHash — Resolves cross-chain payload context by source preparation tx hash.
    • POST /quote — Quote handler; parameters validated from the query string.
  • src/api/types.ts, src/api/shared.ts, src/api/helpers/contracts.ts — Shared context typing and registry/contract helpers for the new endpoints.

Dependencies

  • @hono/standard-validator, zod — Request validation for Glacis routes.

Indexer & services

  • ponder.config.ts — Registers GasService for v3.1 deployments.
  • src/contracts.ts — Ignores null contract addresses when mapping an address to contract name/version (avoids bad matches when a deployment is absent).
  • src/helpers/messaging.tsMessageType and emptyMessage() for minimal encoded payloads (e.g. gas estimates).
  • src/helpers/tokenId.tspoolId, centrifugeId derived from token IDs.
  • BlockchainServicegetCentrifugeIdFromChainId, networkNameFromChainId for human-readable chain labels in API output.
  • CrosschainPayloadServicegetByPreparedAtTxHash for transaction-centric lookups.
  • TokenInstanceServicelistAllJoinedWithToken and TokenInstanceWithTokenRow for route listing / SQL-style joins.

Tooling

  • scripts/fetch-registry.mjs — Registry fetch fixes/robustness.
  • pnpm-lock.yaml — Lockfile updated for new dependencies.

How to test

  1. Run the indexer/API as you normally would for this repo.
  2. Hit existing /tokens/... and /stats — responses should match pre-refactor behavior (paths unchanged).
  3. Exercise GET /routes, GET /transactions/:txHash, and POST /quote with valid and invalid query parameters; invalid input should return validation errors, not opaque 500s.
  4. Confirm v3.1 indexing still starts cleanly with GasService in the contract set (per your env and registry).

@filo87 filo87 marked this pull request as ready for review April 9, 2026 16:52
@filo87 filo87 merged commit 2158450 into main Apr 9, 2026
6 of 7 checks passed
@filo87 filo87 deleted the routes-api branch April 9, 2026 16:54
@api-gitops api-gitops bot mentioned this pull request Apr 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants