Repository navigation
004-04: Subscriptions UI (Plans → Wallet Sign → Status) - #38
Merged
Merged
Conversation
…004-04) New auth-gated /subscriptions route following the payments.tsx patterns: provider cards from subscriptionProviders, plan cards with period, NEAR range and validated stake-amount input, and a status panel per plan. Subscribe and lifecycle ops dispatch on SubscriptionAction.kind: - wallet_intent: chained near-kit functionCall actions signed through the better-near-auth session wallet (single receiver, multi-action), then a generic pollUntil helper (3s interval, 2min cap) waits for chain state - redirect: hosted checkout navigation (Stripe) - executed: query cache updated from the returned subscription Range validation blocks out-of-range stakes before the wallet opens; pending_unstake and cancel_at_period_end render distinctly; empty state covers zero registered providers. payerRef defaults server-side from the session NEAR account; email is the fallback for hosted providers. Closes #31 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FdKukDnRTrshKqkQ8JXwVj
This was referenced Jul 14, 2026
5 tasks
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.
Closes #31. Part of Epic 004 (#27). Depends on #36 + #37 (merged).
What
New auth-gated
/subscriptionsroute (TanStack file-based, patterns copied frompayments.tsx— react-query +useApiClient(), semantic Tailwind, kebab-case files):subscriptionProviders; plan cards fromsubscriptionPlansshowing period, NEAR range (or fixed card price), and a stake-amount input for range plans — validated against min/max with BigInt yocto math before the wallet ever opens.SubscriptionAction.kind— the single switch the epic's action union was designed for:wallet_intent→ signs via the better-near-auth session wallet:authClient.near.client.transaction(account)chaining one near-kitfunctionCallper intent action (multi-action, single receiver — sostorage_deposit+lockland in one transaction), then pollssubscriptionGet(3s / 2min cap) until the chain reflects the target state. Network mismatch (mainnet wallet vs testnet intent) fails with a clear error before signing.redirect→ hosted checkout navigation (Stripe);?checkout=successreturn shows a toast.executed→ the returned subscription lands straight in the query cache.cancel_at_period_endandpending_unstake(with the epoch-settlement hint), cancel/resume actions, and a "switch here from X" change-plan action when actively subscribed to a sibling plan.The polling helper is a generic
pollUntil(fetcher, predicate, {intervalMs, timeoutMs})inui/src/lib/poll.ts— the reusable pattern for any pull-verified provider. Yocto↔NEAR conversion is string/BigInt-safe (ui/src/lib/near-amount.ts), no float math on amounts.payerRefis never sent for NEAR-signed-in users — the API defaults it server-side from the session wallet (context.walletAddress, #37). Email is the explicit fallback for hosted providers.Verified
cd ui && bun run typecheckgreen (route tree regenerated); biome clean on the three new files; zero changes to existing files — payments flow untouched by construction.bos devwith all three plugins registered:GET /api/subscriptions/providersreturns only stake2pay (discovery correctly excludes one-time-only providers), plans render from the live HoS testnet catalog, andPOST /api/subscriptions/stake2payreturns the signable two-action intent (storage_deposit+lockwithduration_ns: null).Scope note (per epic discussion)
v1 targets in-page signing through the better-near-auth wallet connection. Redirect-style wallets (page navigation mid-flow) are an explicit follow-up. The one remaining manual verification — signing a real
lockon testnet — needs a funded testnet wallet in a browser session; the flow up to the wallet call is exercised end-to-end above.🤖 Generated with Claude Code
https://claude.ai/code/session_01FdKukDnRTrshKqkQ8JXwVj