From 26cde6a1931e147f0bdbbec719a6977b6d821264 Mon Sep 17 00:00:00 2001 From: Serhii Date: Mon, 8 Jan 2024 16:02:12 +0200 Subject: [PATCH] Cw 533 add the sell option from on ramper (#1251) * add sell option from onramper * minor fix * fix default sell param --- lib/buy/dfx/dfx_buy_provider.dart | 2 +- lib/buy/onramper/onramper_buy_provider.dart | 11 ++++++----- lib/entities/provider_types.dart | 3 ++- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/lib/buy/dfx/dfx_buy_provider.dart b/lib/buy/dfx/dfx_buy_provider.dart index f74039caa..384b7d504 100644 --- a/lib/buy/dfx/dfx_buy_provider.dart +++ b/lib/buy/dfx/dfx_buy_provider.dart @@ -179,7 +179,7 @@ class DFXBuyProvider extends BuyProvider { if (await canLaunchUrl(uri)) { if (DeviceInfo.instance.isMobile) { Navigator.of(context) - .pushNamed(Routes.webViewPage, arguments: ["DFX Connect", uri]); + .pushNamed(Routes.webViewPage, arguments: [title, uri]); } else { await launchUrl(uri, mode: LaunchMode.externalApplication); } diff --git a/lib/buy/onramper/onramper_buy_provider.dart b/lib/buy/onramper/onramper_buy_provider.dart index 014edb813..3819f074d 100644 --- a/lib/buy/onramper/onramper_buy_provider.dart +++ b/lib/buy/onramper/onramper_buy_provider.dart @@ -52,7 +52,7 @@ class OnRamperBuyProvider extends BuyProvider { return color.value.toRadixString(16).replaceAll(RegExp(r'^ff'), ""); } - Uri requestOnramperUrl(BuildContext context) { + Uri requestOnramperUrl(BuildContext context, bool? isBuyAction) { String primaryColor, secondaryColor, primaryTextColor, @@ -79,23 +79,24 @@ class OnRamperBuyProvider extends BuyProvider { return Uri.https(_baseUrl, '', { 'apiKey': _apiKey, 'defaultCrypto': _normalizeCryptoCurrency, + 'sell_defaultCrypto': _normalizeCryptoCurrency, 'networkWallets': '${networkName}:${wallet.walletAddresses.address}', - 'supportSell': "false", 'supportSwap': "false", 'primaryColor': primaryColor, 'secondaryColor': secondaryColor, 'primaryTextColor': primaryTextColor, 'secondaryTextColor': secondaryTextColor, 'containerColor': containerColor, - 'cardColor': cardColor + 'cardColor': cardColor, + 'mode': isBuyAction == true ? 'buy' : 'sell', }); } Future launchProvider(BuildContext context, bool? isBuyAction) async { - final uri = requestOnramperUrl(context); + final uri = requestOnramperUrl(context, isBuyAction); if (DeviceInfo.instance.isMobile) { Navigator.of(context) - .pushNamed(Routes.webViewPage, arguments: [S.of(context).buy, uri]); + .pushNamed(Routes.webViewPage, arguments: [title, uri]); } else { await launchUrl(uri); } diff --git a/lib/entities/provider_types.dart b/lib/entities/provider_types.dart index 4cb9a934f..ced79eae7 100644 --- a/lib/entities/provider_types.dart +++ b/lib/entities/provider_types.dart @@ -78,7 +78,8 @@ class ProvidersHelper { return [ProviderType.askEachTime, ProviderType.dfx]; case WalletType.bitcoin: case WalletType.ethereum: - return [ProviderType.askEachTime, ProviderType.moonpaySell, ProviderType.dfx]; + return [ProviderType.askEachTime, ProviderType.onramper, + ProviderType.moonpaySell, ProviderType.dfx]; case WalletType.litecoin: case WalletType.bitcoinCash: return [ProviderType.askEachTime, ProviderType.moonpaySell];