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 (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);
}

View file

@ -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, '', <String, dynamic>{
'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<void> 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);
}

View file

@ -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];