mirror of
https://github.com/Such-Software/hash-wallet.git
synced 2026-10-22 06:28:39 +02:00
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:
@@ -17,39 +17,25 @@ class AddressValidator extends TextValidator {
|
||||
case CryptoCurrency.ada:
|
||||
return '^[0-9a-zA-Z]{59}\$|^[0-9a-zA-Z]{92}\$|^[0-9a-zA-Z]{104}\$'
|
||||
'|^[0-9a-zA-Z]{105}\$|^addr1[0-9a-zA-Z]{98}\$';
|
||||
case CryptoCurrency.ape:
|
||||
return '0x[0-9a-zA-Z]';
|
||||
case CryptoCurrency.avaxc:
|
||||
return '0x[0-9a-zA-Z]';
|
||||
case CryptoCurrency.bch:
|
||||
return '[0-9a-zA-Z]';
|
||||
case CryptoCurrency.bnb:
|
||||
return '[0-9a-zA-Z]';
|
||||
case CryptoCurrency.btc:
|
||||
return '^1[0-9a-zA-Z]{32}\$|^1[0-9a-zA-Z]{33}\$|^3[0-9a-zA-Z]{32}\$'
|
||||
'|^3[0-9a-zA-Z]{33}\$|^bc1[0-9a-zA-Z]{39}\$|^bc1[0-9a-zA-Z]{59}\$';
|
||||
case CryptoCurrency.dai:
|
||||
return '[0-9a-zA-Z]';
|
||||
case CryptoCurrency.dash:
|
||||
return '[0-9a-zA-Z]';
|
||||
case CryptoCurrency.eos:
|
||||
return '[0-9a-zA-Z]';
|
||||
case CryptoCurrency.eth:
|
||||
return '0x[0-9a-zA-Z]';
|
||||
case CryptoCurrency.ltc:
|
||||
return '[0-9a-zA-Z]';
|
||||
case CryptoCurrency.nano:
|
||||
return '[0-9a-zA-Z_]';
|
||||
case CryptoCurrency.trx:
|
||||
return '[0-9a-zA-Z]';
|
||||
case CryptoCurrency.usdc:
|
||||
case CryptoCurrency.usdcpoly:
|
||||
case CryptoCurrency.husd:
|
||||
case CryptoCurrency.ape:
|
||||
case CryptoCurrency.avaxc:
|
||||
case CryptoCurrency.eth:
|
||||
case CryptoCurrency.mana:
|
||||
case CryptoCurrency.matic:
|
||||
case CryptoCurrency.maticpoly:
|
||||
case CryptoCurrency.mkr:
|
||||
case CryptoCurrency.oxt:
|
||||
case CryptoCurrency.paxg:
|
||||
case CryptoCurrency.uni:
|
||||
return '0x[0-9a-zA-Z]';
|
||||
case CryptoCurrency.usdt:
|
||||
return '[0-9a-zA-Z]';
|
||||
case CryptoCurrency.usdterc20:
|
||||
return '[0-9a-zA-Z]';
|
||||
case CryptoCurrency.xlm:
|
||||
return '[0-9a-zA-Z]';
|
||||
case CryptoCurrency.xrp:
|
||||
return '^[0-9a-zA-Z]{34}\$|^X[0-9a-zA-Z]{46}\$';
|
||||
case CryptoCurrency.xhv:
|
||||
@@ -67,6 +53,16 @@ class AddressValidator extends TextValidator {
|
||||
case CryptoCurrency.xnok:
|
||||
case CryptoCurrency.xnzd:
|
||||
case CryptoCurrency.xusd:
|
||||
case CryptoCurrency.usdt:
|
||||
case CryptoCurrency.usdterc20:
|
||||
case CryptoCurrency.xlm:
|
||||
case CryptoCurrency.trx:
|
||||
case CryptoCurrency.dai:
|
||||
case CryptoCurrency.dash:
|
||||
case CryptoCurrency.eos:
|
||||
case CryptoCurrency.ltc:
|
||||
case CryptoCurrency.bch:
|
||||
case CryptoCurrency.bnb:
|
||||
return '[0-9a-zA-Z]';
|
||||
case CryptoCurrency.hbar:
|
||||
return '[0-9a-zA-Z.]';
|
||||
@@ -74,6 +70,22 @@ class AddressValidator extends TextValidator {
|
||||
return '^zs[0-9a-zA-Z]{75}';
|
||||
case CryptoCurrency.zec:
|
||||
return '^t1[0-9a-zA-Z]{33}\$|^t3[0-9a-zA-Z]{33}\$';
|
||||
case CryptoCurrency.dcr:
|
||||
return 'D[ksecS]([0-9a-zA-Z])+';
|
||||
case CryptoCurrency.rvn:
|
||||
return '[Rr]([1-9a-km-zA-HJ-NP-Z]){33}';
|
||||
case CryptoCurrency.near:
|
||||
return '[0-9a-f]{64}';
|
||||
case CryptoCurrency.rune:
|
||||
return 'thor1[0-9a-z]{38}';
|
||||
case CryptoCurrency.scrt:
|
||||
return 'secret1[0-9a-z]{38}';
|
||||
case CryptoCurrency.stx:
|
||||
return 'S[MP][0-9a-zA-Z]+';
|
||||
case CryptoCurrency.kmd:
|
||||
return 'R[0-9a-zA-Z]{33}';
|
||||
case CryptoCurrency.pivx:
|
||||
return 'D([1-9a-km-zA-HJ-NP-Z]){33}';
|
||||
default:
|
||||
return '[0-9a-zA-Z]';
|
||||
}
|
||||
@@ -160,6 +172,30 @@ class AddressValidator extends TextValidator {
|
||||
return null;
|
||||
case CryptoCurrency.zec:
|
||||
return null;
|
||||
case CryptoCurrency.kmd:
|
||||
case CryptoCurrency.pivx:
|
||||
case CryptoCurrency.rvn:
|
||||
return [34];
|
||||
case CryptoCurrency.dcr:
|
||||
return [35];
|
||||
case CryptoCurrency.stx:
|
||||
return [40, 41, 42];
|
||||
case CryptoCurrency.usdcpoly:
|
||||
case CryptoCurrency.husd:
|
||||
case CryptoCurrency.mana:
|
||||
case CryptoCurrency.matic:
|
||||
case CryptoCurrency.maticpoly:
|
||||
case CryptoCurrency.mkr:
|
||||
case CryptoCurrency.oxt:
|
||||
case CryptoCurrency.paxg:
|
||||
case CryptoCurrency.uni:
|
||||
return [42];
|
||||
case CryptoCurrency.rune:
|
||||
return [43];
|
||||
case CryptoCurrency.scrt:
|
||||
return [45];
|
||||
case CryptoCurrency.near:
|
||||
return [64];
|
||||
default:
|
||||
return [];
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user