docs(ts): surface session channel reuse next to client.fetch#213
Open
EfeDurmaz16 wants to merge 2 commits into
Open
docs(ts): surface session channel reuse next to client.fetch#213EfeDurmaz16 wants to merge 2 commits into
EfeDurmaz16 wants to merge 2 commits into
Conversation
A production consumer (pay-kit#212) paid a full payment-channel open/settle/ finalize per call on an upto endpoint and had to reverse-engineer the client.fetch throw to discover createSessionFetch. Add a 'Reusing a channel across calls' section to the client docs that states upto is single-settlement by spec and points repeated-call workloads at the MPP session scheme (open once, cumulative voucher per call, close once). Also make the session-challenge ConfigurationError name the import path so it is directly actionable.
Comment on lines
+248
to
+250
| ```ts | ||
| import { createSessionFetch } from '@solana/mpp/client' | ||
| ``` |
There was a problem hiding this comment.
The snippet only imports
createSessionFetch, but the working constructor (shown in typescript/docs/snippets/session.client.ts) requires createPaymentChannelSessionOpener as the opener argument — without it, createSessionFetch({}) has no way to know how to open the channel. A reader following only this section will be stuck at the call site. Including the co-import (and ideally the two-liner instantiation) closes the gap the section is meant to close.
Suggested change
| ```ts | |
| import { createSessionFetch } from '@solana/mpp/client' | |
| ``` | |
| ```ts | |
| import { createSessionFetch, createPaymentChannelSessionOpener } from '@solana/mpp/client' | |
| const client = createSessionFetch({ | |
| opener: createPaymentChannelSessionOpener({ signer, rpcUrl }), | |
| }) |
Collaborator
Author
There was a problem hiding this comment.
Fixed in caaa7cd: the snippet now constructs the client with createPaymentChannelSessionOpener as the opener, so it is copy-runnable, matching docs/snippets/session.client.ts.
Greptile note on #213: the snippet imported only createSessionFetch, but the constructor needs a SessionOpener. Show createPaymentChannelSessionOpener so a reader can copy the block and get a working client, matching docs/snippets/session.client.ts.
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.
Summary
Surface the
sessionscheme (channel reuse) right where consumers look, prompted by #212. A production consumer paid a full payment-channel open/settle/finalize per call against anuptoendpoint, then had to reverse-engineer theclient.fetchthrow to findcreateSessionFetch. Nothing was wrong with the code; the reusable-channel path just was not discoverable.Two small, docs-and-message-only changes:
typescript/README.md: a "Reusing a channel across calls" section after the Client section. It states thatuptois single-settlement by spec (open/settle/finalize per call) and points repeated-call workloads at the MPPsessionscheme (open once, cumulative voucher per call, close once), with thecreateSessionFetchimport and the one dependency (the server must advertise asessionchallenge).packages/pay-kit/src/client/index.ts: the session-challengeConfigurationErrornow names the import path (createSessionFetchfrom@solana/mpp/client) so it is directly actionable.Read order
typescript/README.md(the Client section) — the new subsection.packages/pay-kit/src/client/index.ts— the one-line error-message change.Generated vs handwritten
No generated files. ~25 handwritten lines, docs and one string.
Test plan
pnpm --dir typescript lintandformat:check(prettier clean on both files).session-intent path, only the message text is longer. No test asserts the message.Reviewer note
This deliberately does not touch
uptoor add any channel-management API. Per the canonical x402uptospec,uptois single-settlement and reuse is out of scope; channel reuse is thesessionscheme, which already ships (createSessionFetch). The end-to-end gap for #212 is on the gateway (it must advertise asessionchallenge), tracked separately in solana-foundation/pay#394.Fable 5 self-review
Verdict: correct and minimal. This is a discoverability fix, not a feature, and it resists the tempting-but-wrong move of adding settle-without-close to
upto, which would break x402 spec conformance. What I would flag as a stranger: it is docs plus one string, so its value depends on people reading the README; a follow-up worth considering is a runnable session example underexamples/, which I left out to keep this small. The error-message change is safe (no test pins the text) but does lengthen a user-facing string.Closes part of #212 (client discoverability). The gateway session route is solana-foundation/pay#394.