Skip to content

fix(playground): standardize RPC env and post-rename demo/tooling fixes#195

Open
EfeDurmaz16 wants to merge 3 commits into
solana-foundation:mainfrom
EfeDurmaz16:fix/python-playground-rpc-env
Open

fix(playground): standardize RPC env and post-rename demo/tooling fixes#195
EfeDurmaz16 wants to merge 3 commits into
solana-foundation:mainfrom
EfeDurmaz16:fix/python-playground-rpc-env

Conversation

@EfeDurmaz16

@EfeDurmaz16 EfeDurmaz16 commented Jun 29, 2026

Copy link
Copy Markdown
Collaborator

What

Cross-language playground fixes, grouped because they all surfaced while getting the playground demo working end to end.

1. Standardize the RPC override on PAY_KIT_RPC_URL

Python and Ruby read PAY_KIT_RPC_URL; TS and Go read the bare RPC_URL. A generic RPC_URL set for another service could silently redirect the backend's RPC and settle on a different fork. Move the TS and Go backends (and the Go CI step) onto the namespaced PAY_KIT_RPC_URL so every backend reads one knob. Per @lgalabru's review.

2. Restore the session receipt route (post-#193 leftover)

flow.ts polled /__402/payment-channels/receipt/:id, but both servers serve /sessions/receipt/:id and the Vite proxy only forwarded /__402, so the session demo never surfaced its on-chain settle signature. Point the client back at /sessions/receipt and add the /sessions proxy entry.

3. Send a metered POST body so the upto demo shows real billing

The endpoint workbench sent no request body, so the x402 upto summarize gate always metered 0 bytes (summarizedBytes: 0) and settled the 1-token minimum, making upto look like a flat charge. Send a sample text body for POST endpoints (summarize is the only one), so the demo shows per-byte usage-based billing.

4. Fix the Python coverage target (post-#193 leftover)

python/Justfile ran pytest --cov=pay_kit after the package was renamed to solana_pay_kit, measuring 0% and tripping the 90% gate. Point it at solana_pay_kit.

Test

Go playground builds; Python tests green; the rest verified against the running playground.

Read order

  1. typescript/examples/playground-api/index.ts, the env rename at the reference implementation
  2. go/examples/playground-api/main.go, same rename mirrored in Go
  3. .github/workflows/go.yml, CI boot env renamed in lockstep
  4. the two playground-api READMEs, env tables following the code
  5. playground/app/src/lib/flow.ts, receipt poll repointed to the live /sessions/receipt/:channelId route
  6. playground/app/vite.config.ts, the dev proxy enabling that poll (scoped to ^/sessions/)
  7. playground/app/src/components/EndpointWorkbench.tsx, sample POST body so the summarize demo meters real bytes
  8. python/Justfile, coverage target renamed to the actual solana_pay_kit package

Generated vs handwritten

No generated files; ~30 handwritten changed lines across 10 files, all reviewable in one pass.

Reviewer note

Everything cross-checks against all three playground server implementations, and the response shape of the receipt route ({settledSignature, finalized}) was verified in TS, Go, and Python. The one place that bit us was the vite proxy: a bare /sessions prefix shadowed the SPA's own Sessions page on refresh; fixed in 050ca12 by scoping to ^/sessions/.

Fable 5 self-review

The env rename and receipt-route fix are done properly, CI updated in the same commit. But the first cut shipped a proxy rule that broke refresh on the very page whose poll it fixes, despite the ^/x402/ precedent on the adjacent line: a copy-the-pattern miss, caught in re-check and fixed (050ca12) along with the last stale RPC_URL row in playground/README.md. SAMPLE_POST_BODY quietly assumes every POST endpoint wants prose; true today across all three APIs, worth gating on the endpoint id if a JSON POST endpoint ever lands.

@greptile-apps

greptile-apps Bot commented Jun 29, 2026

Copy link
Copy Markdown

Greptile Summary

This PR fixes several playground demo and tooling issues.

  • Standardizes playground RPC overrides on PAY_KIT_RPC_URL.
  • Updates Go CI and playground docs for the renamed RPC setting.
  • Restores session receipt polling through the /sessions/receipt route.
  • Sends a sample POST body for the metered endpoint demo.
  • Points Python coverage at the renamed package.

Confidence Score: 5/5

This looks safe to merge.

  • No blocking issues found in the changed code.

Important Files Changed

Filename Overview
go/examples/playground-api/main.go The Go playground now reads the namespaced RPC setting.
typescript/examples/playground-api/index.ts The TypeScript playground now reads the namespaced RPC setting.
python/examples/playground_api/app.py The Python playground comment now matches the shared RPC setting.
.github/workflows/go.yml The Go workflow now passes the namespaced RPC setting to the playground server.
playground/app/src/lib/flow.ts Receipt polling now targets the session receipt route.
playground/app/vite.config.ts The dev proxy now forwards session receipt API calls.
playground/app/src/components/EndpointWorkbench.tsx POST endpoint runs now include a sample text body for metering.
python/Justfile Coverage now targets the renamed Python package.

Reviews (4): Last reviewed commit: "fix(playground): scope the sessions dev ..." | Re-trigger Greptile

Comment thread python/examples/playground_api/app.py Outdated
@lgalabru

Copy link
Copy Markdown
Collaborator

Hmm, let's do this the other way, and get rid of RPC_URL ?

The Python and Ruby playgrounds read PAY_KIT_RPC_URL, but the TS and Go
playgrounds read the bare RPC_URL. A generic RPC_URL set for an unrelated
service or cluster would silently redirect the backend's RPC and settle on a
different fork. Move the TS and Go backends (and the Go CI step that feeds
them) onto the namespaced PAY_KIT_RPC_URL so every language's playground reads
one knob and the ambient bare RPC_URL is gone.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@EfeDurmaz16
EfeDurmaz16 force-pushed the fix/python-playground-rpc-env branch from 24f18d9 to cbfe7cb Compare June 29, 2026 11:58
@EfeDurmaz16 EfeDurmaz16 changed the title fix(python): honor RPC_URL in the playground example backend fix(playgrounds): standardize the RPC override on PAY_KIT_RPC_URL Jun 29, 2026
@EfeDurmaz16

Copy link
Copy Markdown
Collaborator Author

Good call. Flipped it the other way: the TS and Go backends (and the Go CI step that fed RPC_URL) now read the namespaced PAY_KIT_RPC_URL, which Python and Ruby already used. The bare RPC_URL is gone, so an ambient value can no longer redirect the playground RPC.

…arget

Three issues found while testing the playground, all post-solana-foundation#193 leftovers or
demo gaps:

- flow.ts polled /__402/payment-channels/receipt/:id, but both servers serve
  /sessions/receipt/:id and the Vite proxy only forwarded /__402, so the
  session demo never surfaced its on-chain settle signature. Point the client
  back at /sessions/receipt and add the /sessions proxy entry.
- The endpoint workbench sent no request body, so the x402 upto summarize gate
  always metered 0 bytes and settled the 1-token minimum, hiding the usage-based
  billing. Send a sample text body for POST endpoints (summarize is the only
  one), so the demo shows real per-byte metering.
- python/Justfile ran pytest --cov=pay_kit after the package was renamed to
  solana_pay_kit, measuring 0% and tripping the 90% gate. Point it at
  solana_pay_kit.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@EfeDurmaz16 EfeDurmaz16 changed the title fix(playgrounds): standardize the RPC override on PAY_KIT_RPC_URL fix(playground): standardize RPC env and post-rename demo/tooling fixes Jun 29, 2026
@EfeDurmaz16
EfeDurmaz16 requested a review from lgalabru June 29, 2026 12:34
'/sessions' as a prefix proxy shadowed the SPA's own /sessions page: in vite
dev a refresh or deep-link on /sessions was forwarded to the API, which has no
GET /sessions handler, returning a 404 JSON blob instead of the page whose
receipt poll this branch fixes. Scope the rule to '^/sessions/' so only the
receipt poll (/sessions/receipt/:channelId) hits the API, matching the
'^/x402/' pattern above it. Also update the last stale RPC_URL row in
playground/README.md to PAY_KIT_RPC_URL.
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