mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2025-01-18 16:55:58 +00:00
CAKE-306 | fixed onEnabled() method in the moonpay_buy_provider.dart
This commit is contained in:
parent
ee6b8767d6
commit
6ac8dabf87
3 changed files with 13 additions and 25 deletions
|
@ -23,7 +23,7 @@ class MoonPayBuyProvider extends BuyProvider {
|
||||||
static const _currenciesSuffix = '/v3/currencies';
|
static const _currenciesSuffix = '/v3/currencies';
|
||||||
static const _quoteSuffix = '/buy_quote';
|
static const _quoteSuffix = '/buy_quote';
|
||||||
static const _transactionsSuffix = '/v1/transactions';
|
static const _transactionsSuffix = '/v1/transactions';
|
||||||
static const _countrySuffix = '/v3/countries';
|
static const _ipAddressSuffix = '/v4/ip_address';
|
||||||
static const _apiKey = secrets.moonPayApiKey;
|
static const _apiKey = secrets.moonPayApiKey;
|
||||||
static const _secretKey = secrets.moonPaySecretKey;
|
static const _secretKey = secrets.moonPaySecretKey;
|
||||||
|
|
||||||
|
@ -125,23 +125,15 @@ class MoonPayBuyProvider extends BuyProvider {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
static Future<bool> onEnabled(String deviceCountryCode) async {
|
static Future<bool> onEnabled() async {
|
||||||
final url = _apiUrl + _countrySuffix;
|
final url = _apiUrl + _ipAddressSuffix + '?apiKey=' + _apiKey;
|
||||||
var isBuyEnable = false;
|
var isBuyEnable = false;
|
||||||
|
|
||||||
final response = await get(url);
|
final response = await get(url);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
final responseJSON = json.decode(response.body) as List<dynamic>;
|
final responseJSON = json.decode(response.body) as Map<String, dynamic>;
|
||||||
|
isBuyEnable = responseJSON['isBuyAllowed'] as bool;
|
||||||
for (var element in responseJSON) {
|
|
||||||
final countryMap = element as Map<String, dynamic>;
|
|
||||||
final countryCode = countryMap['alpha2'] as String;
|
|
||||||
if (countryCode == deviceCountryCode) {
|
|
||||||
isBuyEnable = countryMap['isBuyAllowed'] as bool;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
isBuyEnable = false;
|
isBuyEnable = false;
|
||||||
print(e.toString());
|
print(e.toString());
|
||||||
|
|
10
lib/di.dart
10
lib/di.dart
|
@ -155,19 +155,17 @@ Future setup(
|
||||||
(secrets.wyreApiKey?.isNotEmpty ?? false) &&
|
(secrets.wyreApiKey?.isNotEmpty ?? false) &&
|
||||||
(secrets.wyreAccountId?.isNotEmpty ?? false);
|
(secrets.wyreAccountId?.isNotEmpty ?? false);
|
||||||
|
|
||||||
/*var isMoonPayEnabled = false;
|
var isMoonPayEnabled = false;
|
||||||
try {
|
try {
|
||||||
final locale = await Devicelocale.currentLocale;
|
isMoonPayEnabled = await MoonPayBuyProvider.onEnabled();
|
||||||
final deviceCountryCode = locale.split('_').last;
|
|
||||||
isMoonPayEnabled = await MoonPayBuyProvider.onEnabled(deviceCountryCode);
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
isMoonPayEnabled = false;
|
isMoonPayEnabled = false;
|
||||||
print(e.toString());
|
print(e.toString());
|
||||||
}*/
|
}
|
||||||
|
|
||||||
final settingsStore = await SettingsStoreBase.load(
|
final settingsStore = await SettingsStoreBase.load(
|
||||||
nodeSource: _nodeSource, isBitcoinBuyEnabled: isBitcoinBuyEnabled,
|
nodeSource: _nodeSource, isBitcoinBuyEnabled: isBitcoinBuyEnabled,
|
||||||
isMoonPayEnabled: true);
|
isMoonPayEnabled: isMoonPayEnabled);
|
||||||
|
|
||||||
if (_isSetupFinished) {
|
if (_isSetupFinished) {
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -253,20 +253,18 @@ abstract class SettingsStoreBase with Store {
|
||||||
(secrets.wyreApiKey?.isNotEmpty ?? false) &&
|
(secrets.wyreApiKey?.isNotEmpty ?? false) &&
|
||||||
(secrets.wyreAccountId?.isNotEmpty ?? false);
|
(secrets.wyreAccountId?.isNotEmpty ?? false);
|
||||||
|
|
||||||
/*var isMoonPayEnabled = false;
|
var isMoonPayEnabled = false;
|
||||||
try {
|
try {
|
||||||
final locale = await Devicelocale.currentLocale;
|
isMoonPayEnabled = await MoonPayBuyProvider.onEnabled();
|
||||||
final deviceCountryCode = locale.split('_').last;
|
|
||||||
isMoonPayEnabled = await MoonPayBuyProvider.onEnabled(deviceCountryCode);
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
isMoonPayEnabled = false;
|
isMoonPayEnabled = false;
|
||||||
print(e.toString());
|
print(e.toString());
|
||||||
}*/
|
}
|
||||||
|
|
||||||
final settings = await SettingsStoreBase.load(
|
final settings = await SettingsStoreBase.load(
|
||||||
nodeSource: nodeSource,
|
nodeSource: nodeSource,
|
||||||
isBitcoinBuyEnabled: isBitcoinBuyEnabled,
|
isBitcoinBuyEnabled: isBitcoinBuyEnabled,
|
||||||
isMoonPayEnabled: true,
|
isMoonPayEnabled: isMoonPayEnabled,
|
||||||
initialBalanceDisplayMode: initialBalanceDisplayMode,
|
initialBalanceDisplayMode: initialBalanceDisplayMode,
|
||||||
initialFiatCurrency: initialFiatCurrency,
|
initialFiatCurrency: initialFiatCurrency,
|
||||||
initialMoneroTransactionPriority: initialMoneroTransactionPriority,
|
initialMoneroTransactionPriority: initialMoneroTransactionPriority,
|
||||||
|
|
Loading…
Reference in a new issue