Skip to content

fix(openclaw): repair mainnet stream/workspace lookups + hardening#9

Merged
jayteemoney merged 3 commits into
mainfrom
fix/openclaw-stream-lookup
Jul 1, 2026
Merged

fix(openclaw): repair mainnet stream/workspace lookups + hardening#9
jayteemoney merged 3 commits into
mainfrom
fix/openclaw-stream-lookup

Conversation

@jayteemoney

Copy link
Copy Markdown
Owner

Summary

OpenClaw's two headline queries — stream lookup and workspace lookup — were returning 500 on mainnet. Root-caused, fixed, and verified end-to-end against live mainnet data, plus folded in the other issues found while reviewing the service.

Fixes

  1. Critical — optional-tuple parse (500 on every stream/workspace lookup). getStream/getDao passed result.value to their parsers, but cvToJSON nests an (optional (tuple ...)) one level deeper (result.value.value), so raw.sender was undefined and threw. Bare-uint optionals (get-stream-status) were unaffected, which is why the failure looked selective.
  2. Frontend — "Stream #undefined". Widget read data.id; API returns streamId.
  3. Mainnet token balances always 0. getTokenBalance hardcoded the ::mock-sbtc asset key (testnet leftover); now matches the balance entry by contract-id prefix, so any SIP-010 asset resolves.
  4. Rate limiting. /api limited to 60 req/min per IP (every endpoint proxies to Hiro); trust proxy set for Railway; /health left unthrottled.
  5. Stale block cadence. Pre-Nakamoto constants corrected (BLOCKS_PER_DAY 144→17_280, etc.) and blocksToTimeString 10min→5s/block.

Testing

  • Reproduced the 500 locally (real stack trace at parseStreamData), applied fix, re-verified /api/streams/1 returns full data.
  • Ran the compiled service (npm start) against mainnet: stream lookup, status, block height, and token balance (live USDA holder → 0.028204, non-zero) all correct; zero server errors.
  • Rate limiter verified: 60×200 then 429; /health stays 200.
  • Frontend production build passes (all 12 routes).

Deploy

Merging updates main → Railway rebuilds the service and Vercel redeploys the frontend.

…limit

get-stream and get-dao return (optional (tuple ...)), which cvToJSON nests
one level deeper than the code assumed. getStream/getDao passed result.value
to their parsers instead of result.value.value, so raw.sender was undefined
and every stream and workspace lookup 500'd on mainnet. Reproduced against
mainnet and verified the fix returns full stream data.

Also rate-limit /api (60 req/min per IP) since every endpoint proxies to Hiro
read-only calls, and set trust proxy so the limiter sees real client IPs
behind Railway's proxy. /health stays unthrottled for the healthcheck.
The OpenClaw API returns streamId, but the widget read data.id, so stream
results showed "Stream #undefined". Read streamId with an id fallback.
getTokenBalance hardcoded the ::mock-sbtc asset key, so on mainnet it always
returned 0 for real tokens. Match the balance entry by contract-id prefix so
any SIP-010 asset name resolves. Verified against a live USDA holder.

Also correct the pre-Nakamoto block constants (BLOCKS_PER_DAY 144 -> 17_280,
BLOCKS_PER_MONTH 4320 -> 518_400) and blocksToTimeString (10min -> 5s/block)
to match the frontend and current chain cadence.
@vercel

vercel Bot commented Jul 1, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
stackstream Ready Ready Preview, Comment Jul 1, 2026 8:16pm

@jayteemoney jayteemoney merged commit 565a639 into main Jul 1, 2026
2 of 4 checks passed
@jayteemoney jayteemoney deleted the fix/openclaw-stream-lookup branch July 1, 2026 20:22
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.

1 participant