Cw 178 additional accents for exchange (#526)

* Fix SimpleSwap create exchange (#522)

* Check for status code 201 instead of 200 to follow SimpleSwap API documentation

* allow 200 and 201 success status code

* Changed app version to 4.4.7 (1.1.1 for monero.com)

* Add new currencies
Separate a list for unsupported currencies for SideShift
Fix currencies normalization symbols

* Add new currencies

* Add Currencies validation and possible length

Co-authored-by: M <m@cakewallet.com>
This commit is contained in:
Omar Hatem
2022-10-20 13:23:36 -04:00
committed by GitHub
co-authored by M
parent d4b5ffd0d6
commit 6046385236
21 changed files with 221 additions and 46 deletions
@@ -16,16 +16,7 @@ import 'package:flutter/foundation.dart';
import 'package:http/http.dart';
class SideShiftExchangeProvider extends ExchangeProvider {
SideShiftExchangeProvider()
: super(
pairList: CryptoCurrency.all
.where((i) => i != CryptoCurrency.xhv)
.map((i) => CryptoCurrency.all
.where((i) => i != CryptoCurrency.xhv)
.map((k) => ExchangePair(from: i, to: k, reverse: true))
.where((c) => c != null))
.expand((i) => i)
.toList());
SideShiftExchangeProvider() : super(pairList: _supportedPairs());
static const affiliateId = secrets.sideShiftAffiliateId;
static const apiBaseUrl = 'https://sideshift.ai/api';
@@ -34,6 +25,35 @@ class SideShiftExchangeProvider extends ExchangeProvider {
static const quotePath = '/v1/quotes';
static const permissionPath = '/v1/permissions';
static const List<CryptoCurrency> _notSupported = [
CryptoCurrency.xhv,
CryptoCurrency.dcr,
CryptoCurrency.husd,
CryptoCurrency.kmd,
CryptoCurrency.mkr,
CryptoCurrency.near,
CryptoCurrency.oxt,
CryptoCurrency.paxg,
CryptoCurrency.pivx,
CryptoCurrency.rune,
CryptoCurrency.rvn,
CryptoCurrency.scrt,
CryptoCurrency.stx,
];
static List<ExchangePair> _supportedPairs() {
final supportedCurrencies = CryptoCurrency.all
.where((element) => !_notSupported.contains(element))
.toList();
return supportedCurrencies
.map((i) => supportedCurrencies
.map((k) => ExchangePair(from: i, to: k, reverse: true))
.where((c) => c != null))
.expand((i) => i)
.toList();
}
@override
ExchangeProviderDescription get description =>
ExchangeProviderDescription.sideShift;
@@ -270,6 +290,14 @@ class SideShiftExchangeProvider extends ExchangeProvider {
return currency.tag!.toLowerCase();
case CryptoCurrency.usdterc20:
return 'usdtErc20';
case CryptoCurrency.usdttrc20:
return 'usdtTrc20';
case CryptoCurrency.usdcpoly:
return 'usdcpolygon';
case CryptoCurrency.usdcsol:
return 'usdcsol';
case CryptoCurrency.maticpoly:
return 'polygon';
default:
return currency.title.toLowerCase();
}
@@ -93,7 +93,7 @@ class SimpleSwapExchangeProvider extends ExchangeProvider {
final response = await post(uri, headers: headers, body: json.encode(body));
if (response.statusCode != 200) {
if (response.statusCode != 200 && response.statusCode != 201) {
if (response.statusCode == 400) {
final responseJSON = json.decode(response.body) as Map<String, dynamic>;
final error = responseJSON['message'] as String;
@@ -217,7 +217,13 @@ class SimpleSwapExchangeProvider extends ExchangeProvider {
case CryptoCurrency.bnb:
return currency.tag!.toLowerCase();
case CryptoCurrency.usdterc20:
return 'usdterc';
return 'usdterc20';
case CryptoCurrency.usdttrc20:
return 'usdttrc20';
case CryptoCurrency.usdcpoly:
return 'usdcpoly';
case CryptoCurrency.usdcsol:
return 'usdcspl';
default:
return currency.title.toLowerCase();
}