fix(openclaw): repair mainnet stream/workspace lookups + hardening#9
Merged
Conversation
…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.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
getStream/getDaopassedresult.valueto their parsers, butcvToJSONnests an(optional (tuple ...))one level deeper (result.value.value), soraw.senderwasundefinedand threw. Bare-uintoptionals (get-stream-status) were unaffected, which is why the failure looked selective.data.id; API returnsstreamId.getTokenBalancehardcoded the::mock-sbtcasset key (testnet leftover); now matches the balance entry by contract-id prefix, so any SIP-010 asset resolves./apilimited to 60 req/min per IP (every endpoint proxies to Hiro);trust proxyset for Railway;/healthleft unthrottled.BLOCKS_PER_DAY144→17_280, etc.) andblocksToTimeString10min→5s/block.Testing
parseStreamData), applied fix, re-verified/api/streams/1returns full data.npm start) against mainnet: stream lookup, status, block height, and token balance (live USDA holder →0.028204, non-zero) all correct; zero server errors./healthstays 200.Deploy
Merging updates
main→ Railway rebuilds the service and Vercel redeploys the frontend.