Skip to content

fix(tangle-cloud): chain-read fallback when Envio indexer is absent#3222

Merged
drewstone merged 2 commits into
developfrom
fix/blueprints-onchain-fallback
May 21, 2026
Merged

fix(tangle-cloud): chain-read fallback when Envio indexer is absent#3222
drewstone merged 2 commits into
developfrom
fix/blueprints-onchain-fallback

Conversation

@tangletools
Copy link
Copy Markdown
Contributor

The bug

The blueprints listing in tangle-cloud was empty on Base Sepolia even though 13 blueprints are registered on-chain — because both useBlueprints and useBlueprintsWithMetadata are GraphQL-only via the Envio indexer, and there is currently no hosted Envio indexer for Base Sepolia (VITE_ENVIO_TESTNET_ENDPOINT is 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 fetchBlueprintsOnChain helper that reads the registry directly from the Tangle contract: blueprintCount() followed by a batched getBlueprint(id) + getBlueprintDefinition(id) per entry. Wire both hooks to use it as a fallback when:

  1. the indexer call throws (endpoint missing / unreachable), OR
  2. the indexer returns 0 rows while the chain has live blueprints

The fallback is bounded by the existing limit arg (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 Blueprint shape 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.tools rebuilds, 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's metadata/blueprint-metadata.json.

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.

Test plan

  • yarn nx build tangle-cloud --skip-nx-cache clean
  • Manual: load develop.cloud.tangle.tools/blueprints after merge → see all 13 entries
  • Manual: load develop.cloud.tangle.tools/instances → RegisteredBlueprints section populated
  • Once a hosted Envio is configured, verify GraphQL becomes primary again

drewstone added 2 commits May 21, 2026 16:35
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.
@tangletools tangletools requested a review from AtelyPham as a code owner May 21, 2026 22:49
Copy link
Copy Markdown
Contributor

@drewstone drewstone left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved.

@drewstone drewstone merged commit ca7bc99 into develop May 21, 2026
3 of 7 checks passed
@drewstone drewstone deleted the fix/blueprints-onchain-fallback branch May 21, 2026 22:49
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.

2 participants