Cw 533 add the sell option from on ramper (#1251)

* add sell option from onramper * minor fix * fix default sell param

Serhii committed Jan 8, 2024 at 16:02 UTC 26cde6a1931e147f0bdbbec719a6977b6d821264
3 files changed +9 -7
lib/buy/dfx/dfx_buy_provider.dart
+1 -1
@@ -179,7 +179,7 @@ class DFXBuyProvider extends BuyProvider {
179 if (await canLaunchUrl(uri)) {
180 if (DeviceInfo.instance.isMobile) {
181 Navigator.of(context)
182 - .pushNamed(Routes.webViewPage, arguments: ["DFX Connect", uri]);
182 + .pushNamed(Routes.webViewPage, arguments: [title, uri]);
183 } else {
184 await launchUrl(uri, mode: LaunchMode.externalApplication);
185 }
lib/buy/onramper/onramper_buy_provider.dart
+6 -5
@@ -52,7 +52,7 @@ class OnRamperBuyProvider extends BuyProvider {
52 return color.value.toRadixString(16).replaceAll(RegExp(r'^ff'), "");
53 }
54
55 - Uri requestOnramperUrl(BuildContext context) {
55 + Uri requestOnramperUrl(BuildContext context, bool? isBuyAction) {
56 String primaryColor,
57 secondaryColor,
58 primaryTextColor,
@@ -79,23 +79,24 @@ class OnRamperBuyProvider extends BuyProvider {
79 return Uri.https(_baseUrl, '', <String, dynamic>{
80 'apiKey': _apiKey,
81 'defaultCrypto': _normalizeCryptoCurrency,
82 + 'sell_defaultCrypto': _normalizeCryptoCurrency,
83 'networkWallets': '${networkName}:${wallet.walletAddresses.address}',
83 - 'supportSell': "false",
84 'supportSwap': "false",
85 'primaryColor': primaryColor,
86 'secondaryColor': secondaryColor,
87 'primaryTextColor': primaryTextColor,
88 'secondaryTextColor': secondaryTextColor,
89 'containerColor': containerColor,
90 - 'cardColor': cardColor
90 + 'cardColor': cardColor,
91 + 'mode': isBuyAction == true ? 'buy' : 'sell',
92 });
93 }
94
95 Future<void> launchProvider(BuildContext context, bool? isBuyAction) async {
95 - final uri = requestOnramperUrl(context);
96 + final uri = requestOnramperUrl(context, isBuyAction);
97 if (DeviceInfo.instance.isMobile) {
98 Navigator.of(context)
98 - .pushNamed(Routes.webViewPage, arguments: [S.of(context).buy, uri]);
99 + .pushNamed(Routes.webViewPage, arguments: [title, uri]);
100 } else {
101 await launchUrl(uri);
102 }
lib/entities/provider_types.dart
+2 -1
@@ -78,7 +78,8 @@ class ProvidersHelper {
78 return [ProviderType.askEachTime, ProviderType.dfx];
79 case WalletType.bitcoin:
80 case WalletType.ethereum:
81 - return [ProviderType.askEachTime, ProviderType.moonpaySell, ProviderType.dfx];
81 + return [ProviderType.askEachTime, ProviderType.onramper,
82 + ProviderType.moonpaySell, ProviderType.dfx];
83 case WalletType.litecoin:
84 case WalletType.bitcoinCash:
85 return [ProviderType.askEachTime, ProviderType.moonpaySell];