diff --git a/assets/index.html b/assets/index.html
new file mode 100644
index 000000000..47da2714d
--- /dev/null
+++ b/assets/index.html
@@ -0,0 +1,12 @@
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/lib/di.dart b/lib/di.dart
index 0434f2d2f..fd49a8297 100644
--- a/lib/di.dart
+++ b/lib/di.dart
@@ -28,6 +28,7 @@ import 'package:cake_wallet/src/screens/dashboard/desktop_widgets/desktop_wallet
import 'package:cake_wallet/src/screens/dashboard/edit_token_page.dart';
import 'package:cake_wallet/src/screens/dashboard/home_settings_page.dart';
import 'package:cake_wallet/src/screens/dashboard/widgets/transactions_page.dart';
+import 'package:cake_wallet/src/screens/exchange/moonpay_exchange_web_view.dart';
import 'package:cake_wallet/src/screens/nano/nano_change_rep_page.dart';
import 'package:cake_wallet/src/screens/nano_accounts/nano_account_edit_or_create_page.dart';
import 'package:cake_wallet/src/screens/nano_accounts/nano_account_list_page.dart';
@@ -784,6 +785,8 @@ Future setup({
getIt.registerFactoryParam((title, uri) => WebViewPage(title, uri));
+ getIt.registerFactory(() => MoonpayExchangeWebView());
+
getIt.registerFactory(() => PayfuraBuyProvider(
settingsStore: getIt.get().settingsStore,
wallet: getIt.get().wallet!,
diff --git a/lib/router.dart b/lib/router.dart
index 26a37c900..9c4a3d327 100644
--- a/lib/router.dart
+++ b/lib/router.dart
@@ -12,6 +12,7 @@ import 'package:cake_wallet/src/screens/buy/buy_webview_page.dart';
import 'package:cake_wallet/src/screens/buy/webview_page.dart';
import 'package:cake_wallet/src/screens/dashboard/edit_token_page.dart';
import 'package:cake_wallet/src/screens/dashboard/home_settings_page.dart';
+import 'package:cake_wallet/src/screens/exchange/moonpay_exchange_web_view.dart';
import 'package:cake_wallet/src/screens/nano/nano_change_rep_page.dart';
import 'package:cake_wallet/src/screens/nano_accounts/nano_account_edit_or_create_page.dart';
import 'package:cake_wallet/src/screens/nodes/pow_node_create_or_edit_page.dart';
@@ -519,6 +520,9 @@ Route createRoute(RouteSettings settings) {
return CupertinoPageRoute(
builder: (_) => getIt.get(param1: title, param2: url));
+ case Routes.moonpayExchangeWebView:
+ return CupertinoPageRoute(builder: (_) => getIt.get());
+
case Routes.advancedPrivacySettings:
final type = settings.arguments as WalletType;
diff --git a/lib/routes.dart b/lib/routes.dart
index ec7ad8ae8..17b9311bb 100644
--- a/lib/routes.dart
+++ b/lib/routes.dart
@@ -78,6 +78,7 @@ class Routes {
static const ioniaMoreOptionsPage = '/ionia_more_options_page';
static const ioniaCustomRedeemPage = '/ionia_custom_redeem_page';
static const webViewPage = '/web_view_page';
+ static const moonpayExchangeWebView = '/moonpay_exchange_web_view';
static const connectionSync = '/connection_sync_page';
static const securityBackupPage = '/security_and_backup_page';
static const privacyPage = '/privacy_page';
diff --git a/lib/src/screens/exchange/moonpay_exchange_web_view.dart b/lib/src/screens/exchange/moonpay_exchange_web_view.dart
new file mode 100644
index 000000000..8d331d41d
--- /dev/null
+++ b/lib/src/screens/exchange/moonpay_exchange_web_view.dart
@@ -0,0 +1,58 @@
+import 'package:cake_wallet/generated/i18n.dart';
+import 'package:cake_wallet/src/screens/base_page.dart';
+import 'package:flutter/foundation.dart';
+import 'package:flutter/material.dart';
+import 'package:flutter_inappwebview/flutter_inappwebview.dart';
+import 'package:cake_wallet/.secrets.g.dart' as secrets;
+import 'package:permission_handler/permission_handler.dart';
+
+class MoonpayExchangeWebView extends BasePage {
+ @override
+ String get title => "Swap";
+
+ @override
+ Widget body(BuildContext context) {
+ return InAppWebView(
+ initialOptions: InAppWebViewGroupOptions(
+ crossPlatform: InAppWebViewOptions(transparentBackground: true),
+ ),
+ initialFile: "assets/index.html",
+ onLoadStop: (controller, uri) {
+ final String functionBody = """
+ const moonPay = window.MoonPayWebSdk.init;
+
+const moonPaySdk = moonPay({
+ flow: 'buy',
+ environment: 'production',
+ variant: 'newTab',
+ params: {
+ apiKey: '${secrets.moonPayApiKey}',
+ theme: 'dark',
+ baseCurrencyCode: 'usd',
+ baseCurrencyAmount: '100',
+ defaultCurrencyCode: 'eth'
+ },
+ debug: $kDebugMode
+});
+
+moonPaySdk.show();
+""";
+ controller.callAsyncJavaScript(functionBody: functionBody);
+ },
+ androidOnPermissionRequest: (_, __, List resources) async {
+ bool permissionGranted = await Permission.camera.status == PermissionStatus.granted;
+ if (!permissionGranted) {
+ final permissionStatus = await Permission.camera.request();
+ permissionGranted = await permissionStatus.isGranted;
+ }
+
+ return PermissionRequestResponse(
+ resources: resources,
+ action: permissionGranted
+ ? PermissionRequestResponseAction.GRANT
+ : PermissionRequestResponseAction.DENY,
+ );
+ },
+ );
+ }
+}
diff --git a/pubspec_base.yaml b/pubspec_base.yaml
index 6f8d51615..5926edf13 100644
--- a/pubspec_base.yaml
+++ b/pubspec_base.yaml
@@ -135,6 +135,7 @@ flutter:
- assets/text/
- assets/faq/
- assets/animation/
+ - assets/index.html
fonts:
- family: Lato