-
Notifications
You must be signed in to change notification settings - Fork 1
Feature - Integrate MoonPay SDK for buy/sell functionality in web app #47
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Refactors MoonPay buy/sell integration to use the official MoonPay React SDK in the web app build while keeping a separate (extension-oriented) flow gated by a build-time flag.
Changes:
- Introduces
__IS_WEB_BUILD__as a Vite-defined build-time constant (and adds TypeScript typing for it). - Adds a new
MoonPaySDKWidget(MoonPay React SDK overlay) and refactorsMoonPayWidgetinto a build-aware wrapper. - Updates Deposit/Withdraw pages to render different UI/flows depending on web vs extension build.
Reviewed changes
Copilot reviewed 7 out of 9 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| vite.config.web.ts | Defines __IS_WEB_BUILD__ = true for web builds. |
| vite.config.js | Defines __IS_WEB_BUILD__ = false for extension builds. |
| src/vite-env.d.ts | Declares the __IS_WEB_BUILD__ global for TS. |
| src/popup/pages/Deposit.tsx | Splits Deposit into DepositWeb vs DepositExtension flows and wires MoonPay. |
| src/popup/pages/Withdraw.tsx | Splits Withdraw into WithdrawWeb vs WithdrawExtension flows and wires MoonPay. |
| src/popup/components/MoonPayWidget.tsx | Refactors MoonPay widget into SDK (web) vs iframe (extension) implementation with maintenance fallback. |
| src/popup/components/MoonPaySDKWidget.tsx | Adds MoonPay SDK overlay widget component for the web app build. |
| package.json | Adds @moonpay/moonpay-react dependency. |
| package-lock.json | Locks @moonpay/moonpay-react and captures engine metadata. |
Comments suppressed due to low confidence (2)
src/popup/pages/Deposit.tsx:225
- Extension flow builds and opens a MoonPay URL even when
VITE_MOONPAY_API_KEYis empty, which will produce an invalid MoonPay link. If an empty key is intended to disable MoonPay, the UI should reflect that (disable the CTA and/or show a maintenance/unavailable message) before callingbrowser.tabs.create.
const buildMoonPayUrl = () => {
const baseUrl = 'https://buy.moonpay.com';
const params = new URLSearchParams({
apiKey: MOONPAY_API_KEY,
currencyCode: cryptoCode,
walletAddress: walletAddress,
colorCode: '14B8A6',
theme: 'dark',
language: 'en',
});
return `${baseUrl}?${params.toString()}`;
};
const handleCopyAddress = () => {
if (walletAddress) {
navigator.clipboard.writeText(walletAddress);
toast({
title: 'Address copied',
status: 'success',
duration: 2000,
});
}
};
const handleOpenMoonPay = () => {
browser.tabs.create({ url: buildMoonPayUrl() });
};
src/popup/pages/Withdraw.tsx:196
- Extension flow builds and opens a MoonPay URL even when
VITE_MOONPAY_API_KEYis empty, which will produce an invalid MoonPay link. If an empty key is intended to disable MoonPay, the UI should reflect that (disable the CTA and/or show a maintenance/unavailable message) before callingbrowser.tabs.create.
const buildMoonPaySellUrl = () => {
const baseUrl = 'https://sell.moonpay.com';
const params = new URLSearchParams({
apiKey: MOONPAY_API_KEY,
baseCurrencyCode: cryptoCode,
refundWalletAddress: walletAddress,
colorCode: 'F97316',
theme: 'dark',
language: 'en',
});
return `${baseUrl}?${params.toString()}`;
};
const handleCopyAddress = () => {
if (walletAddress) {
navigator.clipboard.writeText(walletAddress);
toast({
title: 'Address copied',
status: 'success',
duration: 2000,
});
}
};
const handleOpenMoonPay = () => {
browser.tabs.create({ url: buildMoonPaySellUrl() });
};
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| /** | ||
| * Withdraw Page | ||
| * - Web App: Shows simplified MoonPay SDK widget with overlay popup | ||
| * - Extension: Shows network selection and opens MoonPay in new tab | ||
| */ |
Copilot
AI
Feb 1, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PR description says the extension build "retains the iframe-based approach", but this page explicitly describes (and implements) opening MoonPay in a new tab. Please reconcile: either update the PR description or adjust the extension implementation to actually use the iframe-based widget approach.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot Update doc. Current implementation is correct.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Deploying vidulum-app with
|
| Latest commit: |
34c5bd4
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://6129062e.vidulum-app.pages.dev |
| Branch Preview URL: | https://feature-moonpay-widget-web-a.vidulum-app.pages.dev |
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
|
@Corey-Code I've opened a new pull request, #48, to work on those changes. Once the pull request is ready, I'll request review from you. |
|
@Corey-Code I've opened a new pull request, #49, to work on those changes. Once the pull request is ready, I'll request review from you. |
…#48) * Initial plan * Update MoonPayWidget documentation to reflect new tab approach Co-authored-by: Corey-Code <37006206+Corey-Code@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: Corey-Code <37006206+Corey-Code@users.noreply.github.com>
* Initial plan * Update MoonPay integration documentation to reflect new tab behavior Co-authored-by: Corey-Code <37006206+Corey-Code@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: Corey-Code <37006206+Corey-Code@users.noreply.github.com>
…#47) (#50) * Feature - Integrate MoonPay SDK for buy/sell functionality in web app * Update src/popup/components/MoonPaySDKWidget.tsx * Update Withdraw.tsx * Fix MoonPay extension documentation to reflect new tab implementation (#48) * Initial plan * Update MoonPayWidget documentation to reflect new tab approach --------- * Fix MoonPay widget documentation to reflect new tab implementation (#49) * Initial plan * Update MoonPay integration documentation to reflect new tab behavior --------- --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com>
This pull request introduces a major refactor to how MoonPay buy/sell functionality is integrated, providing a more streamlined user experience by differentiating between the web app and browser extension builds. For the web app, a new MoonPay SDK widget is used for direct in-app crypto purchases and sales, while the extension retains the iframe-based approach due to Manifest V3 restrictions. Both the Deposit and Withdraw pages are updated to use this new architecture, with simplified flows for the web app and more detailed, network-selectable flows for the extension.
MoonPay Integration Refactor:
@moonpay/moonpay-reactas a new dependency to enable the official MoonPay SDK for the web app build.MoonPaySDKWidgetcomponent that uses the MoonPay React SDK to provide an overlay modal for buying and selling crypto in the web app.MoonPayWidgetto act as a universal wrapper: it lazy-loads the SDK widget for the web app and uses the iframe approach for the extension. Maintenance mode is shown if the API key is missing.Deposit Page Improvements:
Withdraw Page Improvements:
These changes ensure a modern, seamless MoonPay experience in the web app, while maintaining compatibility and compliance in the extension.