Skip to content

feat(next-template): route production onramp through vechain/onramp-proxy - #654

Merged
victhorbi merged 1 commit into
mainfrom
feat/onramp-proxy-adapter
Aug 6, 2026
Merged

feat(next-template): route production onramp through vechain/onramp-proxy#654
victhorbi merged 1 commit into
mainfrom
feat/onramp-proxy-adapter

Conversation

@Vombato

@Vombato Vombato commented Aug 6, 2026

Copy link
Copy Markdown
Collaborator

Converges the production fiat onramp on vechain/onramp-proxy (shared VeChain backend, see vechain/onramp-proxy#29) while the preview env keeps the current vechain-kit-infra proxy.

Changes

  • widgetUrlBuilder in the example wrapper branches on NEXT_PUBLIC_TRANSAK_ENVIRONMENT:
    • productionGET {API_URL}/?provider=transak&address=…&os=web&theme=LIGHT&currency=…&referrerDomain=…&fiatAmount=…{url} (onramp-proxy contract)
    • staging (preview) → existing POST contract, unchanged
  • deploy-cloudfront.yaml reads the URL from a new secret NEXT_PUBLIC_TRANSAK_API_URL_PROD (→ https://onramp-proxy.vechain.org); deploy-preview.yaml untouched.

Requires

  • vechain/onramp-proxy#29 merged and deployed (multi-origin CORS + parametric referrerDomain)
  • repo secret NEXT_PUBLIC_TRANSAK_API_URL_PROD
  • kit-site / marketplace domains allow-listed as referrerDomain on the Transak production dashboard

Summary by CodeRabbit

  • New Features
    • Added production-specific Transak widget URL handling.
    • Production requests now use a GET-based flow with improved error reporting.
  • Bug Fixes
    • Production deployments now use the correct Transak API endpoint configuration.
    • Non-production environments continue using the existing widget creation flow.

…roxy

- widgetUrlBuilder speaks both contracts: production uses onramp-proxy
  (GET, shared VeChain backend), staging keeps the vechain-kit-infra
  proxy (POST) so the preview env is unchanged
- deploy-cloudfront reads NEXT_PUBLIC_TRANSAK_API_URL_PROD
Comment thread .github/workflows/deploy-cloudfront.yaml
@coderabbitai

coderabbitai Bot commented Aug 6, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The production deployment now uses a production Transak API secret. The widget URL builder uses a GET request with query parameters in production and keeps the existing POST flow for other environments.

Changes

Transak production flow

Layer / File(s) Summary
Production API configuration
.github/workflows/deploy-cloudfront.yaml
The deployment workflow uses NEXT_PUBLIC_TRANSAK_API_URL_PROD for the production Transak API URL.
Production widget URL creation
examples/next-template/src/app/providers/VechainKitProviderWrapper.tsx
Production builds a GET request with Transak query parameters, returns json.url for valid responses, and throws an error for invalid responses. Other environments retain the POST flow.

Estimated code review effort: 2 (Simple) | ~10 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Client
  participant widgetUrlBuilder
  participant TransakAPI
  Client->>widgetUrlBuilder: Request widget URL
  widgetUrlBuilder->>TransakAPI: GET apiUrl with Transak query parameters
  TransakAPI-->>widgetUrlBuilder: JSON response with url or error
  widgetUrlBuilder-->>Client: Return url or throw error
Loading

Possibly related PRs

Suggested reviewers: davidecarpini, agilulfo1820

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes routing the production Next.js template onramp through the Vechain onramp proxy.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/onramp-proxy-adapter

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

ESLint install failed. For unrecoverable errors, disable the tool in CodeRabbit configuration.


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.

@victhorbi victhorbi left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM

@github-actions

github-actions Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Size Change: 0 B

Total Size: 9.02 MB

ℹ️ View Unchanged
Filename Size
packages/vechain-kit/dist/assets 4.1 kB
packages/vechain-kit/dist/assets-BpQtJMK4.mjs 51.4 kB
packages/vechain-kit/dist/assets-BpQtJMK4.mjs.map 74.7 kB
packages/vechain-kit/dist/assets-qmvJ4lSm.cjs 59 kB
packages/vechain-kit/dist/assets-qmvJ4lSm.cjs.map 76.2 kB
packages/vechain-kit/dist/assets/index.cjs 717 B
packages/vechain-kit/dist/assets/index.d.cts 973 B
packages/vechain-kit/dist/assets/index.d.mts 973 B
packages/vechain-kit/dist/assets/index.mjs 719 B
packages/vechain-kit/dist/index-BmZpdzZn.d.mts 5.63 kB
packages/vechain-kit/dist/index-BmZpdzZn.d.mts.map 2.99 kB
packages/vechain-kit/dist/index-BY43DAqG.d.cts 190 kB
packages/vechain-kit/dist/index-BY43DAqG.d.cts.map 51.6 kB
packages/vechain-kit/dist/index-Ca9W2EQY.d.mts 190 kB
packages/vechain-kit/dist/index-Ca9W2EQY.d.mts.map 50.4 kB
packages/vechain-kit/dist/index-DksqLJEA.d.cts 5.63 kB
packages/vechain-kit/dist/index-DksqLJEA.d.cts.map 2.99 kB
packages/vechain-kit/dist/index.cjs 1.16 MB
packages/vechain-kit/dist/index.cjs.map 2.9 MB
packages/vechain-kit/dist/index.d.cts 25 kB
packages/vechain-kit/dist/index.d.mts 25 kB
packages/vechain-kit/dist/index.mjs 1.11 MB
packages/vechain-kit/dist/index.mjs.map 2.83 MB
packages/vechain-kit/dist/utils 4.1 kB
packages/vechain-kit/dist/utils-Bf4wG_2j.cjs 27.4 kB
packages/vechain-kit/dist/utils-Bf4wG_2j.cjs.map 69.8 kB
packages/vechain-kit/dist/utils-Y7vw7K0X.mjs 22.2 kB
packages/vechain-kit/dist/utils-Y7vw7K0X.mjs.map 69 kB
packages/vechain-kit/dist/utils/index.cjs 2.02 kB
packages/vechain-kit/dist/utils/index.d.cts 3.1 kB
packages/vechain-kit/dist/utils/index.d.mts 3.1 kB
packages/vechain-kit/dist/utils/index.mjs 2.04 kB

compressed-size-action

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
examples/next-template/src/app/providers/VechainKitProviderWrapper.tsx (1)

148-161: 🗄️ Data Integrity & Integration | 🔵 Trivial | ⚡ Quick win

Don’t rely on query parameters in the production Transak onramp flow.

Transak direct widget URL query parameters are deprecated; cryptoCurrencyCode and network belong in the server-side widgetParams. If this production URL still works, it is an undocumented workaround and can drift from Transak’s supported flow.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@examples/next-template/src/app/providers/VechainKitProviderWrapper.tsx`
around lines 148 - 161, Update the production Transak onramp flow around
VechainKitProviderWrapper’s URLSearchParams construction to stop passing widget
configuration through the direct widget URL. Move cryptoCurrencyCode and network
into Transak’s server-side widgetParams mechanism, and retain only parameters
supported by the production flow, including the existing fiatAmount handling.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@examples/next-template/src/app/providers/VechainKitProviderWrapper.tsx`:
- Around line 148-161: Update the production Transak onramp flow around
VechainKitProviderWrapper’s URLSearchParams construction to stop passing widget
configuration through the direct widget URL. Move cryptoCurrencyCode and network
into Transak’s server-side widgetParams mechanism, and retain only parameters
supported by the production flow, including the existing fiatAmount handling.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: d8f99ff5-ff6b-460c-b536-31d3a336b9b0

📥 Commits

Reviewing files that changed from the base of the PR and between 8718d6e and 63f8e0d.

📒 Files selected for processing (2)
  • .github/workflows/deploy-cloudfront.yaml
  • examples/next-template/src/app/providers/VechainKitProviderWrapper.tsx

@victhorbi
victhorbi merged commit dab7335 into main Aug 6, 2026
6 checks passed
@victhorbi
victhorbi deleted the feat/onramp-proxy-adapter branch August 6, 2026 14:54
victhorbi added a commit that referenced this pull request Aug 7, 2026
…655)

* fix(homepage): route production onramp through vechain/onramp-proxy

#654 repointed deploy-cloudfront's NEXT_PUBLIC_TRANSAK_API_URL_PROD secret
at vechain/onramp-proxy (GET contract) and fixed the next-template example's
widgetUrlBuilder to match, but the actual production build (examples/homepage,
deployed to vechainkit.vechain.org) was left on the old vechain-kit-infra
POST/JSON contract — so the deployed widgetUrlBuilder now POSTs JSON to a
GET-only endpoint and every production onramp call 405s. Ports the same
production/staging branch already working in next-template.

* fix(transak): widen the widget container to Transak's own 80dvh guidance

Reported: the "Add card details" step rendered clipped/overlapping the
quote screen underneath it inside the embedded widget.

Root cause (confirmed against @transak/ui-js-sdk@1.0.0's actual runtime):
in containerId mode the SDK always renders the iframe at width:100%;
height:100% of its container — widgetWidth/widgetHeight config options are
silently ignored in that mode (they only apply to the SDK's own standalone
overlay, used when no containerId is passed). So the container's own CSS
is what bounds the widget, and both copies of it (TransakCheckoutModal,
TransakOnrampContent) capped it at maxH="620px" — well under Transak's own
documented single-embed sizing of `height: 80dvh`
(docs.transak.com/integration/web/iframe), which is closer to what the
deeper flow steps (KYC, add-card-details) actually need. Raises both
containers to 80dvh (560-900px clamp) to match.

* fix(transak): widen the modal, add a loading spinner for the widget iframe

Reported on the preview deploy: opening the widget showed a blank white
container for a few seconds (the iframe loading Transak's remote app),
and the whole flow felt cramped -- the modal wasn't using the available
screen space.

- useTransakCheckout: track `widgetReady`, flipped by the SDK's
  TRANSAK_WIDGET_INITIALISED event (previously unused). False from the
  moment the widget opens until the iframe has actually rendered.
- TransakCheckoutModal / TransakOnrampContent: render a centered Spinner
  as a sibling overlay while `!widgetReady` -- never as a child of the
  SDK's own container div, since the SDK appends/removes the iframe via
  direct DOM calls (containerId mode) that would fight React for that
  node's children.
- TransakCheckoutModal: BaseModal size 'sm' -> 'lg' (Transak's own
  single-embed sample uses a 500px-wide container; 'sm' was 384px).
- AccountModal: the 'transak-onramp' content type now gets its own
  larger size/height ('lg', up to 90dvh) instead of the fixed 485px/'sm'
  every other AccountModal screen uses -- that fixed cap was squeezing
  an embedded external payment app (quote, KYC, add-card-details) into
  a size tuned for simple menu/settings screens.

* feat(playground): add Payments example, total-balance-in-USD demo

- New "Payments" page (mirrors the "Transactions" page's structure):
  PayWithTransakButton for the drop-in Buy VET button, plus a
  useTransakCheckout demo for a fully custom trigger. Added to the
  sidebar nav under Build, status NEW.
- "Reading Data" page: new DemoSection for useTotalBalance -- one USD
  figure across liquid tokens + staking positions, the same total the
  AccountModal shows.
- Wired transak config into the playground's VechainKitProviderWrapper
  (same dual-contract widgetUrlBuilder as the homepage example: prod ->
  vechain/onramp-proxy, staging -> vechain-kit-infra), gated on the new
  NEXT_PUBLIC_TRANSAK_* env vars (added to .env.example, all optional --
  the Payments page degrades to the hook's built-in "not configured"
  error when unset, same as every other example integration here).
@davidecarpini davidecarpini mentioned this pull request Aug 28, 2026
3 tasks
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