CAKE-314 | changed bnb crypto currency to bnb bep2; removed bnb bep2 from receive currency list on exchange page

This commit is contained in:
OleksandrSobol 2021-04-30 12:46:15 +03:00
parent d23228ac01
commit 3675350452
3 changed files with 29 additions and 14 deletions

View file

@ -29,7 +29,7 @@ class CryptoCurrency extends EnumerableItem<int> with Serializable<int> {
static const xmr = CryptoCurrency(title: 'XMR', raw: 0); static const xmr = CryptoCurrency(title: 'XMR', raw: 0);
static const ada = CryptoCurrency(title: 'ADA', raw: 1); static const ada = CryptoCurrency(title: 'ADA', raw: 1);
static const bch = CryptoCurrency(title: 'BCH', raw: 2); static const bch = CryptoCurrency(title: 'BCH', raw: 2);
static const bnb = CryptoCurrency(title: 'BNB', raw: 3); static const bnb = CryptoCurrency(title: 'BNB BEP2', raw: 3);
static const btc = CryptoCurrency(title: 'BTC', raw: 4); static const btc = CryptoCurrency(title: 'BTC', raw: 4);
static const dai = CryptoCurrency(title: 'DAI', raw: 5); static const dai = CryptoCurrency(title: 'DAI', raw: 5);
static const dash = CryptoCurrency(title: 'DASH', raw: 6); static const dash = CryptoCurrency(title: 'DASH', raw: 6);
@ -90,7 +90,7 @@ class CryptoCurrency extends EnumerableItem<int> with Serializable<int> {
return CryptoCurrency.ada; return CryptoCurrency.ada;
case 'bch': case 'bch':
return CryptoCurrency.bch; return CryptoCurrency.bch;
case 'bnb': case 'bnbmainnet':
return CryptoCurrency.bnb; return CryptoCurrency.bnb;
case 'btc': case 'btc':
return CryptoCurrency.btc; return CryptoCurrency.btc;

View file

@ -48,7 +48,9 @@ class ChangeNowExchangeProvider extends ExchangeProvider {
@override @override
Future<Limits> fetchLimits({CryptoCurrency from, CryptoCurrency to, Future<Limits> fetchLimits({CryptoCurrency from, CryptoCurrency to,
bool isFixedRateMode}) async { bool isFixedRateMode}) async {
final symbol = from.toString() + '_' + to.toString(); final fromTitle = defineCurrencyTitle(from);
final toTitle = defineCurrencyTitle(to);
final symbol = fromTitle + '_' + toTitle;
final url = isFixedRateMode final url = isFixedRateMode
? apiUri + _marketInfoUriSufix + _fixedRateUriSufix + apiKey ? apiUri + _marketInfoUriSufix + _fixedRateUriSufix + apiKey
: apiUri + _minAmountUriSufix + symbol; : apiUri + _minAmountUriSufix + symbol;
@ -61,8 +63,7 @@ class ChangeNowExchangeProvider extends ExchangeProvider {
final elemFrom = elem["from"] as String; final elemFrom = elem["from"] as String;
final elemTo = elem["to"] as String; final elemTo = elem["to"] as String;
if ((elemFrom == from.toString().toLowerCase()) && if ((elemFrom == fromTitle) && (elemTo == toTitle)) {
(elemTo == to.toString().toLowerCase())) {
final min = elem["min"] as double; final min = elem["min"] as double;
final max = elem["max"] as double; final max = elem["max"] as double;
@ -84,9 +85,11 @@ class ChangeNowExchangeProvider extends ExchangeProvider {
? apiUri + _transactionsUriSufix + _fixedRateUriSufix + apiKey ? apiUri + _transactionsUriSufix + _fixedRateUriSufix + apiKey
: apiUri + _transactionsUriSufix + apiKey; : apiUri + _transactionsUriSufix + apiKey;
final _request = request as ChangeNowRequest; final _request = request as ChangeNowRequest;
final fromTitle = defineCurrencyTitle(_request.from);
final toTitle = defineCurrencyTitle(_request.to);
final body = { final body = {
'from': _request.from.toString(), 'from': fromTitle,
'to': _request.to.toString(), 'to': toTitle,
'address': _request.address, 'address': _request.address,
'amount': _request.amount, 'amount': _request.amount,
'refundAddress': _request.refundAddress 'refundAddress': _request.refundAddress
@ -182,6 +185,8 @@ class ChangeNowExchangeProvider extends ExchangeProvider {
final url = apiUri + _marketInfoUriSufix + _fixedRateUriSufix + apiKey; final url = apiUri + _marketInfoUriSufix + _fixedRateUriSufix + apiKey;
final response = await get(url); final response = await get(url);
final responseJSON = json.decode(response.body) as List<dynamic>; final responseJSON = json.decode(response.body) as List<dynamic>;
final fromTitle = defineCurrencyTitle(from);
final toTitle = defineCurrencyTitle(to);
var rate = 0.0; var rate = 0.0;
var fee = 0.0; var fee = 0.0;
@ -189,8 +194,7 @@ class ChangeNowExchangeProvider extends ExchangeProvider {
final elemFrom = elem["from"] as String; final elemFrom = elem["from"] as String;
final elemTo = elem["to"] as String; final elemTo = elem["to"] as String;
if ((elemFrom == to.toString().toLowerCase()) && if ((elemFrom == toTitle) && (elemTo == fromTitle)) {
(elemTo == from.toString().toLowerCase())) {
rate = elem["rate"] as double; rate = elem["rate"] as double;
fee = elem["minerFee"] as double; fee = elem["minerFee"] as double;
break; break;
@ -216,22 +220,32 @@ class ChangeNowExchangeProvider extends ExchangeProvider {
CryptoCurrency to, CryptoCurrency to,
double amount, double amount,
bool isFixedRateMode) { bool isFixedRateMode) {
final fromTitle = defineCurrencyTitle(from);
final toTitle = defineCurrencyTitle(to);
return isFixedRateMode return isFixedRateMode
? apiUri + ? apiUri +
_exchangeAmountUriSufix + _exchangeAmountUriSufix +
_fixedRateUriSufix + _fixedRateUriSufix +
amount.toString() + amount.toString() +
'/' + '/' +
from.toString() + fromTitle +
'_' + '_' +
to.toString() + toTitle +
'?api_key=' + apiKey '?api_key=' + apiKey
: apiUri + : apiUri +
_exchangeAmountUriSufix + _exchangeAmountUriSufix +
amount.toString() + amount.toString() +
'/' + '/' +
from.toString() + fromTitle +
'_' + '_' +
to.toString(); toTitle;
}
static String defineCurrencyTitle(CryptoCurrency currency) {
const bnbTitle = 'bnbmainnet';
final currencyTitle = currency == CryptoCurrency.bnb
? bnbTitle : currency.title.toLowerCase();
return currencyTitle;
} }
} }

View file

@ -59,7 +59,8 @@ abstract class ExchangeViewModelBase with Store {
}); });
receiveCurrencies = CryptoCurrency.all.where((cryptoCurrency) => receiveCurrencies = CryptoCurrency.all.where((cryptoCurrency) =>
(cryptoCurrency != CryptoCurrency.xlm)&& (cryptoCurrency != CryptoCurrency.xlm)&&
(cryptoCurrency != CryptoCurrency.xrp)).toList(); (cryptoCurrency != CryptoCurrency.xrp)&&
(cryptoCurrency != CryptoCurrency.bnb)).toList();
_defineIsReceiveAmountEditable(); _defineIsReceiveAmountEditable();
isFixedRateMode = false; isFixedRateMode = false;
isReceiveAmountEntered = false; isReceiveAmountEntered = false;