Skip to content

86ahp2bjc: migrate token distribution to Kubb SDK#1947

Merged
pikonha merged 13 commits into
devfrom
claude/funny-wozniak-nCq4e
May 28, 2026
Merged

86ahp2bjc: migrate token distribution to Kubb SDK#1947
pikonha merged 13 commits into
devfrom
claude/funny-wozniak-nCq4e

Conversation

@pikonha
Copy link
Copy Markdown
Member

@pikonha pikonha commented May 27, 2026

Summary

  • Replace useGetProposalsQuery (GraphQL) with useProposals from @anticapture/client/hooks in the token-distribution feature hook
  • Replace useTokenMetricsLazyQuery (GraphQL) with the tokenMetrics REST SDK function in the shared useTimeSeriesData hook
  • Replace useHistoricalTokenDataQuery (GraphQL) with useHistoricalTokenData from @anticapture/client/hooks in useDaoTokenHistoricalData
  • Update useChartMetrics to use the new REST response shape (.items instead of .proposals.items, isLoading instead of loading)

Approach

Each GraphQL query is mapped to its REST equivalent from the Kubb-generated @anticapture/client package:

Old (GraphQL) New (REST SDK)
useGetProposalsQuery useProposals from @anticapture/client/hooks
useTokenMetricsLazyQuery tokenMetrics SDK function from @anticapture/client
useHistoricalTokenDataQuery useHistoricalTokenData from @anticapture/client/hooks

The DAO identifier moves from an Apollo context header (anticapture-dao-id) to a URL path parameter, which is the REST API pattern.

Files changed and why

  • features/token-distribution/hooks/useProposals.ts — the only file in token-distribution that directly imported graphql-client; replaced with the Kubb hook
  • features/token-distribution/hooks/useChartMetrics.tsx — updated to use new return types: isLoading (React Query) instead of loading (Apollo), and data.items instead of data.proposals.items
  • shared/hooks/useTimeSeriesData.ts — shared hook that powered the token-metrics timeseries; migrated to call the REST SDK function in a Promise.all preserving the existing manual state-machine pattern
  • features/attack-profitability/hooks/useDaoTokenHistoricalData.ts — shared hook used by token-distribution for the TOKEN_PRICE metric; migrated to useHistoricalTokenData; returns loading (mapped from isLoading) to preserve backward compatibility with attack-profitability and panel callers

Assumptions I made

  • The REST API returns TokenMetricItem.high and TokenMetricItem.volume as strings at runtime (despite the Kubb type saying bigint due to the EthereumGenerator). The mapping code uses String(item.high) and String(item.volume) to safely convert to the local TokenMetricItem type.
  • useDaoTokenHistoricalData is shared with attack-profitability and panel features; its external API (returning { data, loading, error }) is preserved to avoid touching those callers.

What I did NOT do

  • Did not change callers of useDaoTokenHistoricalData in attack-profitability or panel (backward-compatible)
  • Did not change the local TokenMetricItem type shape (kept as string to avoid cascading changes to mocked data and other consumers)
  • Did not migrate useTimeSeriesData to use useTokenMetrics React Query hook — kept the manual useCallback/useEffect pattern to preserve the refresh interval and parallel-fetch behaviour

Open questions for review

  1. Should the local TokenMetricItem type (high: string, volume: string) be updated to match the Kubb SDK type (high: bigint, volume: bigint)? This would allow removing the String() mapping in useTimeSeriesData.
  2. useTimeSeriesData might be a candidate for full React Query migration (useQueries) in a follow-up; this PR intentionally preserves the existing state machine.

Link

ClickUp task: https://app.clickup.com/t/86ahp2bjc


Generated by Claude Code

pikonha and others added 2 commits May 26, 2026 10:03
…T SDK

Replaces GraphQL client queries (useGetProposalsQuery, useTokenMetricsLazyQuery,
useHistoricalTokenDataQuery) with their REST equivalents from @anticapture/client.
Touches useProposals, useChartMetrics, useTimeSeriesData, and useDaoTokenHistoricalData.

https://claude.ai/code/session_01Wr71Qt1BvADmKo8ZycQDar
@vercel
Copy link
Copy Markdown

vercel Bot commented May 27, 2026

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

Project Deployment Actions Updated (UTC)
anticapture Ready Ready Preview, Comment May 28, 2026 7:44pm
anticapture-storybook Ready Ready Preview, Comment May 28, 2026 7:44pm

Request Review

@railway-app
Copy link
Copy Markdown

railway-app Bot commented May 27, 2026

🚅 Deployed to the anticapture-pr-1947 environment in anticapture-infra

Service Status Web Updated (UTC)
gateful ⏭️ Skipped (View Logs) Web May 28, 2026 at 7:48 pm
grafana ✅ Success (View Logs) Web May 28, 2026 at 7:43 pm
otelcol ✅ Success (View Logs) May 28, 2026 at 7:43 pm
alertmanager ✅ Success (View Logs) Web May 28, 2026 at 7:43 pm
prometheus ✅ Success (View Logs) Web May 28, 2026 at 7:43 pm
anticapture-mcp-server ✅ Success (View Logs) Web May 28, 2026 at 7:43 pm
loki ✅ Success (View Logs) Web May 28, 2026 at 7:43 pm
tempo ✅ Success (View Logs) May 28, 2026 at 7:43 pm
api-gateway ⏭️ Skipped (View Logs) Web May 28, 2026 at 7:42 pm
ens-relayer ✅ Success (View Logs) May 28, 2026 at 4:35 pm
address-enrichment ✅ Success (View Logs) Web May 28, 2026 at 4:34 pm
fluid-indexer ✅ Success (View Logs) May 28, 2026 at 4:16 pm
compound-indexer-offchain ✅ Success (View Logs) May 28, 2026 at 4:16 pm
fluid-api ✅ Success (View Logs) May 28, 2026 at 4:15 pm
uniswap-indexer-offchain ✅ Success (View Logs) May 28, 2026 at 4:15 pm
ens-indexer-offchain ✅ Success (View Logs) May 28, 2026 at 4:15 pm
lil-nouns-indexer ✅ Success (View Logs) May 28, 2026 at 4:15 pm
ens-api ✅ Success (View Logs) May 28, 2026 at 4:15 pm
gitcoin-indexer-offchain ✅ Success (View Logs) May 28, 2026 at 4:15 pm
compound-api ✅ Success (View Logs) May 28, 2026 at 4:15 pm
scroll-indexer ✅ Success (View Logs) May 28, 2026 at 4:15 pm
uniswap-api ✅ Success (View Logs) May 28, 2026 at 4:15 pm
aave-indexer ✅ Success (View Logs) May 28, 2026 at 4:15 pm
compound-indexer ✅ Success (View Logs) May 28, 2026 at 4:15 pm
obol-api ✅ Success (View Logs) May 28, 2026 at 4:15 pm
ens-indexer ✅ Success (View Logs) May 28, 2026 at 4:14 pm
gitcoin-api ✅ Success (View Logs) May 28, 2026 at 4:14 pm
obol-indexer ✅ Success (View Logs) May 28, 2026 at 4:14 pm
shutter-api ✅ Success (View Logs) May 28, 2026 at 4:14 pm
nouns-api ✅ Success (View Logs) May 28, 2026 at 4:14 pm
nouns-indexer ✅ Success (View Logs) May 28, 2026 at 4:14 pm
scroll-api ✅ Success (View Logs) May 28, 2026 at 4:13 pm
lil-nouns-api ✅ Success (View Logs) May 28, 2026 at 4:13 pm
gitcoin-indexer ✅ Success (View Logs) May 28, 2026 at 4:13 pm
uniswap-indexer ✅ Success (View Logs) May 28, 2026 at 4:12 pm
shutter-indexer ✅ Success (View Logs) May 28, 2026 at 4:12 pm
aave-api ✅ Success (View Logs) May 28, 2026 at 4:12 pm
erpc ✅ Success (View Logs) Web May 27, 2026 at 6:12 pm
nodeful ✅ Success (View Logs) May 27, 2026 at 6:12 pm
14 services not affected by this PR
  • RabbitMQ
  • RabbitMQ Web UI
  • tailscale-entrance
  • consumer
  • caddy-zero-trust
  • s3manager
  • hyperindex-erpc
  • hyperindex-database
  • hyperindex-sync
  • hyperindex-sync-database
  • hyperindex-hyperrpc-database
  • hyperindex-hyperrpc
  • logic-system
  • dispatcher

Copy link
Copy Markdown
Member Author

pikonha commented May 27, 2026

Dashboard E2E — investigation findings

The E2E check has failed twice (consistently, not a flake). I've traced what changed but cannot see the Playwright output to confirm the exact error. Here's what I found:

What this PR changes at the network level:
Before this migration, useTimeSeriesData, useDaoTokenHistoricalData, and the token-distribution useProposals fetched data via Apollo GraphQL → NEXT_PUBLIC_BASE_URL (external URL, never through localhost).

After this migration those same hooks make REST calls through the Next.js proxy → http://localhost:3000/api/gateful/ens/token-metrics, …/ens/token/historical-data.

Why that matters for E2E: The watch5xxErrors fixture in e2e/helpers/network.ts throws on any localhost response with status ≥ 500. Since GraphQL calls went to an external URL they were never monitored. The new REST calls DO go through localhost and will trigger this watcher if the upstream returns a 5xx.

What to check:

  1. Download the Playwright report artifact from the failing CI run (Actions → playwright-report artifact) to get the actual error message — is it a 5xx response: 500 http://localhost:3000/api/gateful/ens/… or a timeout/assertion failure?
  2. If it's a 5xx: verify that the E2E Gateful environment (E2E_NEXT_PUBLIC_GATEFUL_URL) responds correctly to GET /ens/token-metrics?metricType=DELEGATED_SUPPLY&… and GET /ens/token/historical-data.
  3. If it's a timeout/assertion: something in rendering is broken — the static text "TOKEN DISTRIBUTION SUPPLY" should always be visible regardless of API state, so a timeout there would indicate a React crash.

All other CI checks (typecheck, lint, changeset, codegen) pass.


Generated by Claude Code

Comment thread apps/dashboard/features/attack-profitability/hooks/useDaoTokenHistoricalData.ts Outdated
Comment thread apps/dashboard/features/token-distribution/hooks/useProposals.ts
Remove identity map() in useDaoTokenHistoricalData since the schema
already matches. Add lean: true to useProposals to omit descriptions.

https://claude.ai/code/session_01Wr71Qt1BvADmKo8ZycQDar
@railway-app railway-app Bot temporarily deployed to anticapture-infra / anticapture-pr-1947 May 28, 2026 19:22 Destroyed
claude added 2 commits May 28, 2026 19:23
…hangesets

Update sitemap.test.ts assertions to expect lean:true in proposal fetches
after collaborator added lean parameter to getAllProposalPages. Add
changesets for @anticapture/gateful and @anticapture/api-gateway as
required by the api-contract-updates CI check.

https://claude.ai/code/session_01Wr71Qt1BvADmKo8ZycQDar
@railway-app railway-app Bot temporarily deployed to anticapture-infra / anticapture-pr-1947 May 28, 2026 19:24 Destroyed
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 8ffc325c76

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread .github/workflows/api-contract-updates.yaml
…to token historical hook

Restore sitemap.test.ts with lean:true assertions to cover the lean param
added to getAllProposalPages. Adds refetch to useDaoTokenHistoricalData
to align with the same hook in dev (PR #1941).

https://claude.ai/code/session_01Wr71Qt1BvADmKo8ZycQDar
@railway-app railway-app Bot temporarily deployed to anticapture-infra / anticapture-pr-1947 May 28, 2026 19:42 Destroyed
@pikonha pikonha merged commit ab5ab47 into dev May 28, 2026
49 of 50 checks passed
@pikonha pikonha deleted the claude/funny-wozniak-nCq4e branch May 28, 2026 19:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants