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

* add sell option from onramper

* minor fix

* fix default sell param
This commit is contained in:
Serhii 2024-01-08 16:02:12 +02:00 committed by GitHub
parent 133fa2987a
commit 26cde6a193
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 7 deletions

View file

@ -179,7 +179,7 @@ class DFXBuyProvider extends BuyProvider {
if (await canLaunchUrl(uri)) { if (await canLaunchUrl(uri)) {
if (DeviceInfo.instance.isMobile) { if (DeviceInfo.instance.isMobile) {
Navigator.of(context) Navigator.of(context)
.pushNamed(Routes.webViewPage, arguments: ["DFX Connect", uri]); .pushNamed(Routes.webViewPage, arguments: [title, uri]);
} else { } else {
await launchUrl(uri, mode: LaunchMode.externalApplication); await launchUrl(uri, mode: LaunchMode.externalApplication);
} }

View file

@ -52,7 +52,7 @@ class OnRamperBuyProvider extends BuyProvider {
return color.value.toRadixString(16).replaceAll(RegExp(r'^ff'), ""); return color.value.toRadixString(16).replaceAll(RegExp(r'^ff'), "");
} }
Uri requestOnramperUrl(BuildContext context) { Uri requestOnramperUrl(BuildContext context, bool? isBuyAction) {
String primaryColor, String primaryColor,
secondaryColor, secondaryColor,
primaryTextColor, primaryTextColor,
@ -79,23 +79,24 @@ class OnRamperBuyProvider extends BuyProvider {
return Uri.https(_baseUrl, '', <String, dynamic>{ return Uri.https(_baseUrl, '', <String, dynamic>{
'apiKey': _apiKey, 'apiKey': _apiKey,
'defaultCrypto': _normalizeCryptoCurrency, 'defaultCrypto': _normalizeCryptoCurrency,
'sell_defaultCrypto': _normalizeCryptoCurrency,
'networkWallets': '${networkName}:${wallet.walletAddresses.address}', 'networkWallets': '${networkName}:${wallet.walletAddresses.address}',
'supportSell': "false",
'supportSwap': "false", 'supportSwap': "false",
'primaryColor': primaryColor, 'primaryColor': primaryColor,
'secondaryColor': secondaryColor, 'secondaryColor': secondaryColor,
'primaryTextColor': primaryTextColor, 'primaryTextColor': primaryTextColor,
'secondaryTextColor': secondaryTextColor, 'secondaryTextColor': secondaryTextColor,
'containerColor': containerColor, 'containerColor': containerColor,
'cardColor': cardColor 'cardColor': cardColor,
'mode': isBuyAction == true ? 'buy' : 'sell',
}); });
} }
Future<void> launchProvider(BuildContext context, bool? isBuyAction) async { Future<void> launchProvider(BuildContext context, bool? isBuyAction) async {
final uri = requestOnramperUrl(context); final uri = requestOnramperUrl(context, isBuyAction);
if (DeviceInfo.instance.isMobile) { if (DeviceInfo.instance.isMobile) {
Navigator.of(context) Navigator.of(context)
.pushNamed(Routes.webViewPage, arguments: [S.of(context).buy, uri]); .pushNamed(Routes.webViewPage, arguments: [title, uri]);
} else { } else {
await launchUrl(uri); await launchUrl(uri);
} }

View file

@ -78,7 +78,8 @@ class ProvidersHelper {
return [ProviderType.askEachTime, ProviderType.dfx]; return [ProviderType.askEachTime, ProviderType.dfx];
case WalletType.bitcoin: case WalletType.bitcoin:
case WalletType.ethereum: case WalletType.ethereum:
return [ProviderType.askEachTime, ProviderType.moonpaySell, ProviderType.dfx]; return [ProviderType.askEachTime, ProviderType.onramper,
ProviderType.moonpaySell, ProviderType.dfx];
case WalletType.litecoin: case WalletType.litecoin:
case WalletType.bitcoinCash: case WalletType.bitcoinCash:
return [ProviderType.askEachTime, ProviderType.moonpaySell]; return [ProviderType.askEachTime, ProviderType.moonpaySell];