Skip to content

Fix the four templates failing the automated health check - #441

Open
cxalem wants to merge 7 commits into
solana-foundation:mainfrom
cxalem:feat/template-health-fixes
Open

Fix the four templates failing the automated health check#441
cxalem wants to merge 7 commits into
solana-foundation:mainfrom
cxalem:feat/template-health-fixes

Conversation

@cxalem

@cxalem cxalem commented Jul 27, 2026

Copy link
Copy Markdown
Collaborator

What

Fixes the four templates that fail a clean npm install && npm run ci in a fresh checkout. Each fix is the smallest change that makes the template build again.

Fixes

community/commerce-kit-store
The commerce SDK expects @tanstack/react-query as a peer but the template never declared it, so the build failed with module not found. Declared it, and migrated lint to the flat ESLint setup since next lint no longer exists in Next 16.

community/drift-hello-world
Next 16 builds with Turbopack by default, but this template ships a webpack config (needed for the Drift SDK's node builtins), so the build hard errored. The build script now passes --webpack, matching the dev script. Also pinned a single @solana/web3.js across the tree because the Drift SDK pins an older exact version, which installed two incompatible copies of Connection.

community/zk-compression-airdrop
The page statically imports two JSON configs that are generated by the setup script and gitignored, so fresh checkouts could not build. Committed key free example configs and moved the RPC endpoint out of the config file entirely. The browser now calls a same-origin /api/rpc proxy that next.config.ts rewrites to RPC_ENDPOINT on the server, so a Helius api key never lands in a commit or in the browser bundle. The proxy tradeoff is documented in the README.

kit/pinocchio-counter
Client generation crashed because the 1.x line of @codama/renderers-js reads struct fields unguarded while newer @codama/nodes omits the key for empty structs, so every fresh install resolved a broken combination. We reported it upstream (codama-idl/renderers-js#168) and the maintainer released a patched 1.7.1 the same day. This PR bumps the renderer floor to ^1.7.1, no version pins needed.

Testing

Each template verified the same way the health check runs: copied to a fresh temp dir, clean install, npm run ci. All four pass, including codama client generation for pinocchio-counter on both the npm and pnpm install paths.

commerce-kit-store: declare the @tanstack/react-query peer the commerce
SDK needs and migrate lint to the Next 16 flat ESLint setup

drift-hello-world: build with webpack to match the template's webpack
config and pin a single @solana/web3.js across the Drift SDK tree

zk-compression-airdrop: commit key-free example configs so fresh
checkouts build, the app reads the RPC endpoint from env and the
setup script never writes secrets to tracked files

pinocchio-counter: pin the codama packages to the last versions that
work together, an upstream regression in @codama/nodes 1.5.0 breaks
client generation for empty instruction structs
@cxalem
cxalem requested a review from catmcgee as a code owner July 27, 2026 10:13
@greptile-apps

greptile-apps Bot commented Jul 27, 2026

Copy link
Copy Markdown

Greptile Summary

This PR repairs clean-install health checks for four templates.

  • Adds the missing React Query peer and migrates the commerce template to ESLint flat configuration.
  • Forces the Drift template to build with webpack and deduplicates its Solana web3 dependency.
  • Commits key-free airdrop examples and moves the Helius endpoint behind a same-origin rewrite.
  • Upgrades the Codama JavaScript renderer and permits its required pnpm build dependency.

Confidence Score: 3/5

The PR should not merge until the publicly accessible credentialed RPC proxy is protected from unauthorized quota consumption.

The original browser disclosure of RPC_ENDPOINT is fixed, but the replacement rewrite still forwards arbitrary unauthenticated requests through the deployment's Helius endpoint, allowing external callers to spend its quota.

Files Needing Attention: community/zk-compression-airdrop/next.config.ts

Important Files Changed

Filename Overview
community/zk-compression-airdrop/next.config.ts Removes browser inlining of the RPC credential and adds a server-side rewrite, while leaving the credentialed proxy publicly usable.
community/zk-compression-airdrop/src/features/airdrop/data-access/use-airdrop.ts Routes client RPC traffic through the same-origin proxy instead of embedding the endpoint in browser code.
community/commerce-kit-store/package.json Adds the required React Query peer and replaces the removed Next.js lint command.
community/drift-hello-world/package.json Selects webpack for production builds and overrides Solana web3 to one dependency version.
kit/pinocchio-counter/package.json Raises the Codama renderer version to the patched release.

Sequence Diagram

sequenceDiagram
  participant Browser
  participant Next as Next.js deployment
  participant RPC as Helius RPC
  Browser->>Next: POST /api/rpc (JSON-RPC)
  Next->>RPC: Forward request using RPC_ENDPOINT
  RPC-->>Next: JSON-RPC response
  Next-->>Browser: JSON-RPC response
Loading

Reviews (7): Last reviewed commit: "chore: regenerate lockfile for codama re..." | Re-trigger Greptile

Comment on lines +41 to +45
const rpcEndpoint = process.env.RPC_ENDPOINT
if (!rpcEndpoint) {
throw new Error('RPC_ENDPOINT environment variable not set. Add it to .env.local (see README).')
}
const rpc = createRpcConnection(rpcEndpoint)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 security RPC credential exposed to browsers

When a deployment sets RPC_ENDPOINT to a Helius URL containing its API key, this client hook consumes the value through the next.config.ts env mapping, which embeds the complete endpoint in browser-delivered JavaScript and lets every visitor extract and reuse the credential.

How this was verified: The client-marked hook reads process.env.RPC_ENDPOINT, and the existing Next configuration exports that variable through its client-inlined env mapping.

…xplicit

Regenerates the root pnpm lockfile for the commerce-kit-store
react-query addition so the frozen lockfile install in CI passes.
Renames the airdrop rpc variable to NEXT_PUBLIC_RPC_ENDPOINT so the
browser exposure is explicit per Next convention and documents that
this devnet demo embeds its credentials in the client bundle.
@greptile-apps

greptile-apps Bot commented Jul 27, 2026

Copy link
Copy Markdown

Want your agent to iterate on Greptile's feedback? Try greploops.

…sers

The airdrop client now calls a same-origin /api/rpc endpoint and a
rewrite in next.config.ts forwards it to RPC_ENDPOINT on the server.
Verified at runtime with a canary key: the proxy forwards requests
and the key appears in no client chunk. DEV_WALLET remains browser
embedded by design and the README now says so explicitly.
Comment on lines +16 to +17
source: '/api/rpc',
destination: process.env.RPC_ENDPOINT ?? 'https://api.devnet.solana.com',

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 security Public proxy exposes RPC quota

When an unauthenticated visitor sends arbitrary JSON-RPC requests to /api/rpc, this rewrite forwards them to the credential-bearing Helius endpoint without authentication, rate limiting, or method restrictions, allowing the visitor to consume the deployment's quota or exercise methods enabled for that credential while the key remains hidden.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

True, and it is inherent to any proxy in front of a keyed endpoint, including the Cloudflare proxy Helius themselves recommend. The tradeoff is deliberate: an open same-origin proxy is strictly better than the key in the browser bundle, abuse requires hitting the live deployment and stops when it goes down, while an extracted key is reusable anywhere forever. For a devnet demo on a free tier key the blast radius is the demo's own quota. The README now documents this explicitly and tells deployers to add rate limiting or auth before pointing the proxy at quota that matters

cxalem and others added 2 commits July 27, 2026 19:34
Upstream released @codama/renderers-js 1.7.1 with the optional
fields fix after our report (codama-idl/renderers-js#168), so the
version pins are no longer needed. Bumps the renderer floor to
^1.7.1 and drops the npm, yarn, and pnpm override blocks.
pnpm-lock.yaml was stale after bumping @codama/renderers-js to ^1.7.1
in kit/pinocchio-counter; regenerated with pnpm 10.5.2 (CI's pinned
version). Removed entries are the dropped old dependency chain.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Aug 4, 2026

Copy link
Copy Markdown

This pull request has been automatically marked as stale because it has not had any activity for 7 days.

It will be closed in 7 days if no further activity occurs.

If you believe this PR is still relevant, please add a comment or push new commits to keep it open.

Thank you for your contributions!

@github-actions github-actions Bot added the stale label Aug 4, 2026
@SrMessiSOL

Copy link
Copy Markdown
Collaborator

I reviewed the PR.

I would not approve it yet for two reasons:

  1. The branch is currently not mergeable against main; I reproduced conflicts in kit/pinocchio-counter/package.json and pnpm-lock.yaml.

  2. The /api/rpc rewrite avoids exposing the Helius key in the browser bundle, which is an improvement, but it still leaves a public unauthenticated proxy to the credentialed RPC endpoint. I understand the devnet-demo tradeoff, but I think this should either be protected or explicitly scoped in a way maintainers are comfortable merging.

Once the branch is rebased and the RPC proxy decision is resolved, I can re-review.

@github-actions github-actions Bot removed the stale label Aug 9, 2026
@github-actions

Copy link
Copy Markdown

This pull request has been automatically marked as stale because it has not had any activity for 7 days.

It will be closed in 7 days if no further activity occurs.

If you believe this PR is still relevant, please add a comment or push new commits to keep it open.

Thank you for your contributions!

@github-actions github-actions Bot added the stale label Aug 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants