Skip to content

feat(arns): Pay for ArNS names with Turbo Credits (Phase 1, Model B) - #956

Open
vilenarios wants to merge 3 commits into
developfrom
feat/turbo-credits-arns
Open

feat(arns): Pay for ArNS names with Turbo Credits (Phase 1, Model B)#956
vilenarios wants to merge 3 commits into
developfrom
feat/turbo-credits-arns

Conversation

@vilenarios

Copy link
Copy Markdown
Contributor

What this does

Re-enables the Credits checkout tab, wired to the bundler payment-service
POST /v1/arns/purchase/:intent/:name. Credits are debited server-side and
the bundler fronts the ARIO + SOL; the browser never needs ARIO or SOL to
register a name.

  • Covers buy-name, extend-lease, increase-undername, and
    upgrade-name.
  • Model B (Solana user owns the ANT): the ANT is spawned client-side and its
    processId is passed to the bundler, so the user retains ownership.
  • @ar.io/sdk's fundFrom: 'turbo' turned out to be a no-op alias, so
    settlement was rerouted to the bundler REST API via the turbo-sdk ArNS-purchase
    methods.

⚠️ Blocked on (do before merge / marking ready)

  • (a) Publish the turbo-sdk alpha from
    ardriveapp/turbo-sdk#feat/arns-purchase-with-credits (est.
    @ardrive/turbo-sdk@1.43.0-alpha.1). This PR already updates the dependency
    pin to 1.43.0-alpha.1, but yarn.lock must be regenerated once the alpha
    is on npm (it is intentionally not included here — the local build used a
    file: tarball pin).
  • (b) Real-wallet devnet e2e sign-off.

Testing status

  • Unit: 12/12 Jest tests green (TurboArNSClient.test.ts).
  • The bundler credit-paid buy is PROVEN on devnet end-to-end — a real name
    was registered on-chain paying with Turbo Credits.
  • Browser render verified (0 console errors).
  • Build ✓, tsc ✓ (save 1 pre-existing unrelated error), Biome ✓.

Dep-blocker shim

@ardrive/turbo-sdk → @solana/spl-token-metadata@0.1.6 imports the renamed
getDataEnumCodec; a scoped Vite (rollup) + esbuild (dev) transform
rewrites it to getDiscriminatedUnionCodec so the browser build resolves.
Follow-up: fix turbo-sdk to not drag rc.1 codecs into the browser build,
which removes the shim.

Configurability

Payment / upload / gateway URLs are now env-configurable via
VITE_PAYMENT_SERVICE_URL, VITE_UPLOAD_SERVICE_URL, and VITE_GATEWAY_URL, so
the app can point at any bundler (e.g. *.services.perma.online).

Deferred

  • Phase 2: credit-paid ANT management (set/remove-record, transfer).
  • Model A: custodial flow for Arweave / ETH / keyless users. The seam is
    already present (custodyStrategy.ts).

🤖 Generated with Claude Code

- Re-enable the Credits checkout tab, wired to the bundler payment-service
  REST (POST /v1/arns/purchase/:intent/:name) via the turbo-sdk ArNS-purchase
  methods; credits are debited server-side and the bundler fronts ARIO + SOL.
- Cover buy-name / extend-lease / increase-undername / upgrade-name.
- Model B: the Solana user owns the ANT (spawned client-side; processId passed
  to the bundler). @ar.io/sdk fundFrom:'turbo' is a no-op alias, so settlement
  is rerouted to the bundler REST.
- Add nonce poll + resilience (arnsPurchaseResume) and a custody strategy seam
  (custodyStrategy.ts) for the future Model A path.
- Make upload/gateway/payment URLs env-configurable.
- Add an esbuild (dev) + rollup (build) codec shim rewriting the renamed
  getDataEnumCodec -> getDiscriminatedUnionCodec import dragged in by
  @solana/spl-token-metadata, so the browser build resolves.

🤖 Generated with [Claude Code](https://claude.com/claude-code)
@coderabbitai

coderabbitai Bot commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

@vilenarios, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 10 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: ae261250-b81d-41ed-a74c-34243008bcb5

📥 Commits

Reviewing files that changed from the base of the PR and between 907a935 and ec05026.

⛔ Files ignored due to path filters (1)
  • yarn.lock is excluded by !**/yarn.lock, !**/*.lock
📒 Files selected for processing (15)
  • package.json
  • src/components/forms/PaymentOptionsForm/PaymentOptionsForm.tsx
  • src/components/modals/PrimaryNameModal/PrimaryNameModal.tsx
  • src/components/pages/Register/Checkout.tsx
  • src/services/turbo/TurboArNSClient.test.ts
  • src/services/turbo/TurboArNSClient.ts
  • src/services/turbo/arnsPurchaseResume.test.ts
  • src/services/turbo/arnsPurchaseResume.ts
  • src/services/turbo/custodyStrategy.ts
  • src/state/actions/dispatchArNSPurchaseWithCredits.test.ts
  • src/state/actions/dispatchArNSPurchaseWithCredits.ts
  • src/utils/checkInsufficientSolForGas.test.ts
  • src/utils/checkInsufficientSolForGas.ts
  • src/utils/constants.ts
  • vite.config.ts
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/turbo-credits-arns

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

The ArNS-purchase methods are now published on the @Alpha dist-tag
(ardriveapp/turbo-sdk#435 merged). Replaces the local-tarball / placeholder
pin so CI installs a real, resolvable version and the build is reproducible.

🤖 Generated with [Claude Code](https://claude.com/claude-code)
@github-actions

github-actions Bot commented Jul 15, 2026

Copy link
Copy Markdown

Permaweb Preview Deployed

Your preview is available at: https://arns-react-pr-956_arns.ar.io

Property Value
Transaction ID 32mKZip80NBY_Ng3reLc6WLiDRosJhvb39JBcjidKq4
ArNS Name arns
Undername arns-react-pr-956

This preview will be available permanently on Arweave via the AR.IO Network.

@vilenarios
vilenarios marked this pull request as ready for review July 15, 2026 18:57
@vilenarios

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@vilenarios
vilenarios requested a review from a team as a code owner July 15, 2026 18:57
@coderabbitai

coderabbitai Bot commented Jul 15, 2026

Copy link
Copy Markdown
Contributor
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

…aid BUY

The Model B credits BUY flow spawns a user-owned ANT client-side (real SOL)
before a server-fronted, credit-funded buy. Several P0 gaps let a user lose
SOL, hit dead-end errors, or misread what they were paying:

- SOL pre-flight gate now covers the credits path, not just crypto. Paying
  with credits still needs ~0.02 SOL for the ANT spawn, so a credits-rich /
  SOL-empty wallet is blocked + the "Pay now" button relabels to
  "Insufficient SOL" BEFORE clicking. Extracted the predicate into a pure,
  unit-tested checkInsufficientSolForGas() and added copy on the Credits tab.
- Runtime 402 (InsufficientCreditsError) now opens the TurboTopUpModal instead
  of a dead-end error toast.
- Orphan-ANT / SOL-bleed fix: persist the spawned ANT processId into the resume
  store BEFORE the buy; a retry REUSES it instead of spawning (and paying for)
  another. A non-402 failure after spawn surfaces an honest "your ANT was
  created, retrying reuses it, credits weren't charged" message.
- Removed the stale "temporarily disabled" tooltip on the now-live Credits tab.
- Added USD + ARIO real-world anchors next to the "Total due: X Credits" figure.
- Invalidate turbo-credit-balance after a purchase so the debit shows at once.
- PrimaryNameModal: documented that set-primary-name is ARIO-only (the credit
  path type excludes Primary-Name-Request); it never presented a credits option,
  so no user is misled — added a guard comment against a future fundFrom:'turbo'.

Tests: new unit suites for the SOL gate, resume store (processId persistence),
and the dispatch reuse-on-retry / honest-message / 402-passthrough behavior.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CFu1gpBLo6pe5kBFNw5NF9
@vilenarios

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 15, 2026

Copy link
Copy Markdown
Contributor
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

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.

1 participant