fix(tangle-cloud): chain-read fallback when Envio indexer is absent#3222
Merged
Conversation
Three small but visible UX fixes from a staging walkthrough. None of
these touch layout or data — they remove three sources of visual
friction without any behavior change.
## 1. Scroll-to-top on route change
`<BrowserRouter>` is scroll-naive: navigating from a long blueprints
listing to /rewards lands the next page already scrolled to wherever
the previous page was. New `ScrollToTop` component mounts inside the
router tree, listens to `pathname` changes, and `window.scrollTo({top:
0, behavior: 'instant'})` so the new page paints at the top.
Pathname-only dependency is deliberate — we don't scroll on search
params or hash changes (those drive in-page tab state).
## 2. Claim history "Could not load" → empty state
When `VITE_ENVIO_TESTNET_ENDPOINT` is unset (current staging case —
there is no hosted Envio indexer for Base Sepolia yet), the rewards
page rendered a red `<ErrorMessage>Could not load claim history.`
banner on every load. That's the UX equivalent of a 500, but the
actual cause is "no historical data source configured", which is a
legitimate empty state, not a failure.
Replace the error branch with a neutral `<EmptyState>` titled "Claim
history unavailable on this network" — same code path, gentler tone,
keeps the page usable instead of alarming.
(Restoring real history requires standing up Envio against the new
Base Sepolia deployment — tracked separately. Pending-rewards via
direct contract reads is unaffected and continues to render.)
## 3. Sidebar: "Payments" → "Private Payments"
The shielded-credits / RLN-settlement surface lives there. "Payments"
on its own reads as a generic ledger; the shielded-billing aspect is
the distinguishing feature, so surface it in the label.
The blueprints listing in tangle-cloud was empty on Base Sepolia even though 13 blueprints are registered on-chain — because both `useBlueprints` and `useBlueprintsWithMetadata` were GraphQL-only via the Envio indexer, and there is currently no hosted Envio indexer configured for Base Sepolia (`VITE_ENVIO_TESTNET_ENDPOINT` is unset on staging). Add a `fetchBlueprintsOnChain` helper that reads the registry directly from the Tangle contract — `blueprintCount()` then a batched `getBlueprint(id)` + `getBlueprintDefinition(id)` per entry — and wire both hooks to use it as a fallback when: (a) the indexer call throws (endpoint missing / unreachable), OR (b) the indexer returns 0 rows while the chain has live blueprints The fallback is bounded by the existing `limit` arg (default 100) so it stays well-behaved at the current scale of 13 entries and remains safe up to the next couple orders of magnitude on testnet. At production scale (1000s of blueprints) we'd want a proper indexer; for testnet visibility today this lets the cloud surface render what's actually on-chain without waiting on Envio infrastructure. The chain-read path populates the same `Blueprint` shape the GraphQL path returns, so consumers don't branch on data source. Fields the indexer tracks but the chain doesn't expose (`updatedAt`) get a sensible default (= `createdAt`) so sort order stays predictable. Verified `yarn nx build tangle-cloud` clean. Once Envio is stood up against the deployed Base Sepolia contracts and `VITE_ENVIO_TESTNET_ENDPOINT` is set in Netlify env, the GraphQL path becomes primary again automatically and the chain-read fallback quietly disengages.
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.
The bug
The blueprints listing in tangle-cloud was empty on Base Sepolia even though 13 blueprints are registered on-chain — because both
useBlueprintsanduseBlueprintsWithMetadataare GraphQL-only via the Envio indexer, and there is currently no hosted Envio indexer for Base Sepolia (VITE_ENVIO_TESTNET_ENDPOINTis unset on staging).User-visible symptom: navigated to /blueprints, saw "0 Catalog", didn't know any of the 13 registered blueprints existed.
The fix
Add a
fetchBlueprintsOnChainhelper that reads the registry directly from the Tangle contract:blueprintCount()followed by a batchedgetBlueprint(id)+getBlueprintDefinition(id)per entry. Wire both hooks to use it as a fallback when:The fallback is bounded by the existing
limitarg (default 100). At the current scale of 13 entries it's tiny; safe up to the next couple orders of magnitude on testnet. Production-scale (1000s of blueprints) still wants a real indexer.The chain-read path populates the same
Blueprintshape the GraphQL path returns, so downstream consumers don't branch on data source. Fields the indexer tracks but the chain doesn't expose (updatedAt) get a sensible default (= createdAt) so sort order stays predictable.After this lands
develop.cloud.tangle.toolsrebuilds, the blueprints listing fills with the 13 registered entries, and (with the GitHub-URL metadata resolver from #3219/#3220 already shipped) each one renders with its metadata from the repo'smetadata/blueprint-metadata.json.Once Envio is stood up against the deployed Base Sepolia contracts and
VITE_ENVIO_TESTNET_ENDPOINTis set in Netlify env, the GraphQL path becomes primary again automatically and the chain-read fallback quietly disengages.Test plan
yarn nx build tangle-cloud --skip-nx-cachecleandevelop.cloud.tangle.tools/blueprintsafter merge → see all 13 entriesdevelop.cloud.tangle.tools/instances→ RegisteredBlueprints section populated