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>
Omar Hatem committed
Oct 20, 2022 at 19:23 UTC
604638523607d0cba9ee4e841992398e859df0e7
21 files changed
+221
-46
assets/images/dcr_icon.png
Binary files /dev/null and b/assets/images/dcr_icon.png differ
assets/images/husd_icon.png
Binary files /dev/null and b/assets/images/husd_icon.png differ
assets/images/kmd_icon.png
Binary files /dev/null and b/assets/images/kmd_icon.png differ
assets/images/mana_icon.png
Binary files /dev/null and b/assets/images/mana_icon.png differ
assets/images/matic_icon.png
Binary files /dev/null and b/assets/images/matic_icon.png differ
assets/images/mkr_icon.png
Binary files /dev/null and b/assets/images/mkr_icon.png differ
assets/images/near_icon.png
Binary files /dev/null and b/assets/images/near_icon.png differ
assets/images/oxt_icon.png
Binary files /dev/null and b/assets/images/oxt_icon.png differ
assets/images/paxg_icon.png
Binary files /dev/null and b/assets/images/paxg_icon.png differ
assets/images/pivx_icon.png
Binary files /dev/null and b/assets/images/pivx_icon.png differ
assets/images/rune_icon.png
Binary files /dev/null and b/assets/images/rune_icon.png differ
assets/images/rvn_icon.png
Binary files /dev/null and b/assets/images/rvn_icon.png differ
assets/images/scrt_icon.png
Binary files /dev/null and b/assets/images/scrt_icon.png differ
assets/images/stx_icon.png
Binary files /dev/null and b/assets/images/stx_icon.png differ
assets/images/uni_icon.png
Binary files /dev/null and b/assets/images/uni_icon.png differ
cw_core/lib/crypto_currency.dart
+105
@@ -51,6 +51,23 @@ class CryptoCurrency extends EnumerableItem<int> with Serializable<int> {
51
CryptoCurrency.zec,
52
CryptoCurrency.zen,
53
CryptoCurrency.xvg,
54
+ CryptoCurrency.usdcpoly,
55
+ CryptoCurrency.dcr,
56
+ CryptoCurrency.husd,
57
+ CryptoCurrency.kmd,
58
+ CryptoCurrency.mana,
59
+ CryptoCurrency.maticpoly,
60
+ CryptoCurrency.matic,
61
+ CryptoCurrency.mkr,
62
+ CryptoCurrency.near,
63
+ CryptoCurrency.oxt,
64
+ CryptoCurrency.paxg,
65
+ CryptoCurrency.pivx,
66
+ CryptoCurrency.rune,
67
+ CryptoCurrency.rvn,
68
+ CryptoCurrency.scrt,
69
+ CryptoCurrency.uni,
70
+ CryptoCurrency.stx,
71
];
72
73
static const xmr = CryptoCurrency(title: 'XMR', iconPath: 'assets/images/monero_icon.png', name: 'Monero', raw: 0);
@@ -102,6 +119,26 @@ class CryptoCurrency extends EnumerableItem<int> with Serializable<int> {
119
static const zen = CryptoCurrency(title: 'ZEN', iconPath: 'assets/images/zen_icon.png', raw: 44);
120
static const xvg = CryptoCurrency(title: 'XVG', name: 'Verge', iconPath: 'assets/images/xvg_icon.png', raw: 45);
121
122
+ static const usdcpoly = CryptoCurrency(title: 'USDC', iconPath: 'assets/images/usdc_icon.png', tag: 'POLY', raw: 46);
123
+ static const dcr = CryptoCurrency(title: 'DCR', iconPath: 'assets/images/dcr_icon.png', raw: 47);
124
+ static const husd = CryptoCurrency(title: 'HUSD', iconPath: 'assets/images/husd_icon.png', tag: 'ETH', raw: 48);
125
+ static const kmd = CryptoCurrency(title: 'KMD', iconPath: 'assets/images/kmd_icon.png', raw: 49);
126
+ static const mana = CryptoCurrency(title: 'MANA', iconPath: 'assets/images/mana_icon.png', tag: 'ETH', raw: 50);
127
+ static const maticpoly = CryptoCurrency(title: 'MATIC', iconPath: 'assets/images/matic_icon.png', tag: 'POLY', raw: 51);
128
+ static const matic = CryptoCurrency(title: 'MATIC', iconPath: 'assets/images/matic_icon.png', tag: 'ETH', raw: 52);
129
+ static const mkr = CryptoCurrency(title: 'MKR', iconPath: 'assets/images/mkr_icon.png', tag: 'ETH', raw: 53);
130
+ static const near = CryptoCurrency(title: 'NEAR', iconPath: 'assets/images/near_icon.png', raw: 54);
131
+ static const oxt = CryptoCurrency(title: 'OXT', iconPath: 'assets/images/oxt_icon.png', tag: 'ETH', raw: 55);
132
+ static const paxg = CryptoCurrency(title: 'PAXG', iconPath: 'assets/images/paxg_icon.png', tag: 'ETH', raw: 56);
133
+ static const pivx = CryptoCurrency(title: 'PIVX', iconPath: 'assets/images/pivx_icon.png', raw: 57);
134
+ static const rune = CryptoCurrency(title: 'RUNE', iconPath: 'assets/images/rune_icon.png', raw: 58);
135
+ static const rvn = CryptoCurrency(title: 'RVN', iconPath: 'assets/images/rvn_icon.png', raw: 59);
136
+ static const scrt = CryptoCurrency(title: 'SCRT', iconPath: 'assets/images/scrt_icon.png', raw: 60);
137
+ static const uni = CryptoCurrency(title: 'UNI', iconPath: 'assets/images/uni_icon.png', tag: 'ETH', raw: 61);
138
+ static const stx = CryptoCurrency(title: 'STX', iconPath: 'assets/images/stx_icon.png', raw: 62);
139
+
140
+
141
+
142
static CryptoCurrency deserialize({required int raw}) {
143
switch (raw) {
144
case 0:
@@ -196,6 +233,40 @@ class CryptoCurrency extends EnumerableItem<int> with Serializable<int> {
233
return CryptoCurrency.zen;
234
case 45:
235
return CryptoCurrency.xvg;
236
+ case 46:
237
+ return CryptoCurrency.usdcpoly;
238
+ case 47:
239
+ return CryptoCurrency.dcr;
240
+ case 48:
241
+ return CryptoCurrency.husd;
242
+ case 49:
243
+ return CryptoCurrency.kmd;
244
+ case 50:
245
+ return CryptoCurrency.mana;
246
+ case 51:
247
+ return CryptoCurrency.maticpoly;
248
+ case 52:
249
+ return CryptoCurrency.matic;
250
+ case 53:
251
+ return CryptoCurrency.mkr;
252
+ case 54:
253
+ return CryptoCurrency.near;
254
+ case 55:
255
+ return CryptoCurrency.oxt;
256
+ case 56:
257
+ return CryptoCurrency.paxg;
258
+ case 57:
259
+ return CryptoCurrency.pivx;
260
+ case 58:
261
+ return CryptoCurrency.rune;
262
+ case 59:
263
+ return CryptoCurrency.rvn;
264
+ case 60:
265
+ return CryptoCurrency.scrt;
266
+ case 61:
267
+ return CryptoCurrency.uni;
268
+ case 62:
269
+ return CryptoCurrency.stx;
270
default:
271
throw Exception('Unexpected token: $raw for CryptoCurrency deserialize');
272
}
@@ -295,6 +366,40 @@ class CryptoCurrency extends EnumerableItem<int> with Serializable<int> {
366
return CryptoCurrency.zen;
367
case 'xvg':
368
return CryptoCurrency.xvg;
369
+ case 'usdcpoly':
370
+ return CryptoCurrency.usdcpoly;
371
+ case 'dcr':
372
+ return CryptoCurrency.dcr;
373
+ case 'husd':
374
+ return CryptoCurrency.husd;
375
+ case 'kmd':
376
+ return CryptoCurrency.kmd;
377
+ case 'mana':
378
+ return CryptoCurrency.mana;
379
+ case 'maticpoly':
380
+ return CryptoCurrency.maticpoly;
381
+ case 'matic':
382
+ return CryptoCurrency.matic;
383
+ case 'mkr':
384
+ return CryptoCurrency.mkr;
385
+ case 'near':
386
+ return CryptoCurrency.near;
387
+ case 'oxt':
388
+ return CryptoCurrency.oxt;
389
+ case 'paxg':
390
+ return CryptoCurrency.paxg;
391
+ case 'pivx':
392
+ return CryptoCurrency.pivx;
393
+ case 'rune':
394
+ return CryptoCurrency.rune;
395
+ case 'rvn':
396
+ return CryptoCurrency.rvn;
397
+ case 'scrt':
398
+ return CryptoCurrency.scrt;
399
+ case 'uni':
400
+ return CryptoCurrency.uni;
401
+ case 'stx':
402
+ return CryptoCurrency.stx;
403
default:
404
throw Exception('Unexpected token: $raw for CryptoCurrency fromString');
405
}
lib/core/address_validator.dart
+62
-26
@@ -17,39 +17,25 @@ class AddressValidator extends TextValidator {
17
case CryptoCurrency.ada:
18
return '^[0-9a-zA-Z]{59}\$|^[0-9a-zA-Z]{92}\$|^[0-9a-zA-Z]{104}\$'
19
'|^[0-9a-zA-Z]{105}\$|^addr1[0-9a-zA-Z]{98}\$';
20
- case CryptoCurrency.ape:
21
- return '0x[0-9a-zA-Z]';
22
- case CryptoCurrency.avaxc:
23
- return '0x[0-9a-zA-Z]';
24
- case CryptoCurrency.bch:
25
- return '[0-9a-zA-Z]';
26
- case CryptoCurrency.bnb:
27
- return '[0-9a-zA-Z]';
20
case CryptoCurrency.btc:
21
return '^1[0-9a-zA-Z]{32}\$|^1[0-9a-zA-Z]{33}\$|^3[0-9a-zA-Z]{32}\$'
22
'|^3[0-9a-zA-Z]{33}\$|^bc1[0-9a-zA-Z]{39}\$|^bc1[0-9a-zA-Z]{59}\$';
31
- case CryptoCurrency.dai:
32
- return '[0-9a-zA-Z]';
33
- case CryptoCurrency.dash:
34
- return '[0-9a-zA-Z]';
35
- case CryptoCurrency.eos:
36
- return '[0-9a-zA-Z]';
37
- case CryptoCurrency.eth:
38
- return '0x[0-9a-zA-Z]';
39
- case CryptoCurrency.ltc:
40
- return '[0-9a-zA-Z]';
23
case CryptoCurrency.nano:
24
return '[0-9a-zA-Z_]';
43
- case CryptoCurrency.trx:
44
- return '[0-9a-zA-Z]';
25
case CryptoCurrency.usdc:
26
+ case CryptoCurrency.usdcpoly:
27
+ case CryptoCurrency.husd:
28
+ case CryptoCurrency.ape:
29
+ case CryptoCurrency.avaxc:
30
+ case CryptoCurrency.eth:
31
+ case CryptoCurrency.mana:
32
+ case CryptoCurrency.matic:
33
+ case CryptoCurrency.maticpoly:
34
+ case CryptoCurrency.mkr:
35
+ case CryptoCurrency.oxt:
36
+ case CryptoCurrency.paxg:
37
+ case CryptoCurrency.uni:
38
return '0x[0-9a-zA-Z]';
47
- case CryptoCurrency.usdt:
48
- return '[0-9a-zA-Z]';
49
- case CryptoCurrency.usdterc20:
50
- return '[0-9a-zA-Z]';
51
- case CryptoCurrency.xlm:
52
- return '[0-9a-zA-Z]';
39
case CryptoCurrency.xrp:
40
return '^[0-9a-zA-Z]{34}\$|^X[0-9a-zA-Z]{46}\$';
41
case CryptoCurrency.xhv:
@@ -67,6 +53,16 @@ class AddressValidator extends TextValidator {
53
case CryptoCurrency.xnok:
54
case CryptoCurrency.xnzd:
55
case CryptoCurrency.xusd:
56
+ case CryptoCurrency.usdt:
57
+ case CryptoCurrency.usdterc20:
58
+ case CryptoCurrency.xlm:
59
+ case CryptoCurrency.trx:
60
+ case CryptoCurrency.dai:
61
+ case CryptoCurrency.dash:
62
+ case CryptoCurrency.eos:
63
+ case CryptoCurrency.ltc:
64
+ case CryptoCurrency.bch:
65
+ case CryptoCurrency.bnb:
66
return '[0-9a-zA-Z]';
67
case CryptoCurrency.hbar:
68
return '[0-9a-zA-Z.]';
@@ -74,6 +70,22 @@ class AddressValidator extends TextValidator {
70
return '^zs[0-9a-zA-Z]{75}';
71
case CryptoCurrency.zec:
72
return '^t1[0-9a-zA-Z]{33}\$|^t3[0-9a-zA-Z]{33}\$';
73
+ case CryptoCurrency.dcr:
74
+ return 'D[ksecS]([0-9a-zA-Z])+';
75
+ case CryptoCurrency.rvn:
76
+ return '[Rr]([1-9a-km-zA-HJ-NP-Z]){33}';
77
+ case CryptoCurrency.near:
78
+ return '[0-9a-f]{64}';
79
+ case CryptoCurrency.rune:
80
+ return 'thor1[0-9a-z]{38}';
81
+ case CryptoCurrency.scrt:
82
+ return 'secret1[0-9a-z]{38}';
83
+ case CryptoCurrency.stx:
84
+ return 'S[MP][0-9a-zA-Z]+';
85
+ case CryptoCurrency.kmd:
86
+ return 'R[0-9a-zA-Z]{33}';
87
+ case CryptoCurrency.pivx:
88
+ return 'D([1-9a-km-zA-HJ-NP-Z]){33}';
89
default:
90
return '[0-9a-zA-Z]';
91
}
@@ -160,6 +172,30 @@ class AddressValidator extends TextValidator {
172
return null;
173
case CryptoCurrency.zec:
174
return null;
175
+ case CryptoCurrency.kmd:
176
+ case CryptoCurrency.pivx:
177
+ case CryptoCurrency.rvn:
178
+ return [34];
179
+ case CryptoCurrency.dcr:
180
+ return [35];
181
+ case CryptoCurrency.stx:
182
+ return [40, 41, 42];
183
+ case CryptoCurrency.usdcpoly:
184
+ case CryptoCurrency.husd:
185
+ case CryptoCurrency.mana:
186
+ case CryptoCurrency.matic:
187
+ case CryptoCurrency.maticpoly:
188
+ case CryptoCurrency.mkr:
189
+ case CryptoCurrency.oxt:
190
+ case CryptoCurrency.paxg:
191
+ case CryptoCurrency.uni:
192
+ return [42];
193
+ case CryptoCurrency.rune:
194
+ return [43];
195
+ case CryptoCurrency.scrt:
196
+ return [45];
197
+ case CryptoCurrency.near:
198
+ return [64];
199
default:
200
return [];
201
}
lib/exchange/sideshift/sideshift_exchange_provider.dart
+38
-10
@@ -16,16 +16,7 @@ import 'package:flutter/foundation.dart';
16
import 'package:http/http.dart';
17
18
class SideShiftExchangeProvider extends ExchangeProvider {
19
- SideShiftExchangeProvider()
20
- : super(
21
- pairList: CryptoCurrency.all
22
- .where((i) => i != CryptoCurrency.xhv)
23
- .map((i) => CryptoCurrency.all
24
- .where((i) => i != CryptoCurrency.xhv)
25
- .map((k) => ExchangePair(from: i, to: k, reverse: true))
26
- .where((c) => c != null))
27
- .expand((i) => i)
28
- .toList());
19
+ SideShiftExchangeProvider() : super(pairList: _supportedPairs());
20
21
static const affiliateId = secrets.sideShiftAffiliateId;
22
static const apiBaseUrl = 'https://sideshift.ai/api';
@@ -34,6 +25,35 @@ class SideShiftExchangeProvider extends ExchangeProvider {
25
static const quotePath = '/v1/quotes';
26
static const permissionPath = '/v1/permissions';
27
28
+ static const List<CryptoCurrency> _notSupported = [
29
+ CryptoCurrency.xhv,
30
+ CryptoCurrency.dcr,
31
+ CryptoCurrency.husd,
32
+ CryptoCurrency.kmd,
33
+ CryptoCurrency.mkr,
34
+ CryptoCurrency.near,
35
+ CryptoCurrency.oxt,
36
+ CryptoCurrency.paxg,
37
+ CryptoCurrency.pivx,
38
+ CryptoCurrency.rune,
39
+ CryptoCurrency.rvn,
40
+ CryptoCurrency.scrt,
41
+ CryptoCurrency.stx,
42
+ ];
43
+
44
+ static List<ExchangePair> _supportedPairs() {
45
+ final supportedCurrencies = CryptoCurrency.all
46
+ .where((element) => !_notSupported.contains(element))
47
+ .toList();
48
+
49
+ return supportedCurrencies
50
+ .map((i) => supportedCurrencies
51
+ .map((k) => ExchangePair(from: i, to: k, reverse: true))
52
+ .where((c) => c != null))
53
+ .expand((i) => i)
54
+ .toList();
55
+ }
56
+
57
@override
58
ExchangeProviderDescription get description =>
59
ExchangeProviderDescription.sideShift;
@@ -270,6 +290,14 @@ class SideShiftExchangeProvider extends ExchangeProvider {
290
return currency.tag!.toLowerCase();
291
case CryptoCurrency.usdterc20:
292
return 'usdtErc20';
293
+ case CryptoCurrency.usdttrc20:
294
+ return 'usdtTrc20';
295
+ case CryptoCurrency.usdcpoly:
296
+ return 'usdcpolygon';
297
+ case CryptoCurrency.usdcsol:
298
+ return 'usdcsol';
299
+ case CryptoCurrency.maticpoly:
300
+ return 'polygon';
301
default:
302
return currency.title.toLowerCase();
303
}
lib/exchange/simpleswap/simpleswap_exchange_provider.dart
+8
-2
@@ -93,7 +93,7 @@ class SimpleSwapExchangeProvider extends ExchangeProvider {
93
94
final response = await post(uri, headers: headers, body: json.encode(body));
95
96
- if (response.statusCode != 200) {
96
+ if (response.statusCode != 200 && response.statusCode != 201) {
97
if (response.statusCode == 400) {
98
final responseJSON = json.decode(response.body) as Map<String, dynamic>;
99
final error = responseJSON['message'] as String;
@@ -217,7 +217,13 @@ class SimpleSwapExchangeProvider extends ExchangeProvider {
217
case CryptoCurrency.bnb:
218
return currency.tag!.toLowerCase();
219
case CryptoCurrency.usdterc20:
220
- return 'usdterc';
220
+ return 'usdterc20';
221
+ case CryptoCurrency.usdttrc20:
222
+ return 'usdttrc20';
223
+ case CryptoCurrency.usdcpoly:
224
+ return 'usdcpoly';
225
+ case CryptoCurrency.usdcsol:
226
+ return 'usdcspl';
227
default:
228
return currency.title.toLowerCase();
229
}
scripts/android/app_env.sh
+4
-4
@@ -14,14 +14,14 @@ TYPES=($MONERO_COM $CAKEWALLET $HAVEN)
14
APP_ANDROID_TYPE=$1
15
16
MONERO_COM_NAME="Monero.com"
17
-MONERO_COM_VERSION="1.1.0"
18
-MONERO_COM_BUILD_NUMBER=19
17
+MONERO_COM_VERSION="1.1.1"
18
+MONERO_COM_BUILD_NUMBER=20
19
MONERO_COM_BUNDLE_ID="com.monero.app"
20
MONERO_COM_PACKAGE="com.monero.app"
21
22
CAKEWALLET_NAME="Cake Wallet"
23
-CAKEWALLET_VERSION="4.4.6"
24
-CAKEWALLET_BUILD_NUMBER=118
23
+CAKEWALLET_VERSION="4.4.7"
24
+CAKEWALLET_BUILD_NUMBER=119
25
CAKEWALLET_BUNDLE_ID="com.cakewallet.cake_wallet"
26
CAKEWALLET_PACKAGE="com.cakewallet.cake_wallet"
27
scripts/ios/app_env.sh
+4
-4
@@ -13,13 +13,13 @@ TYPES=($MONERO_COM $CAKEWALLET $HAVEN)
13
APP_IOS_TYPE=$1
14
15
MONERO_COM_NAME="Monero.com"
16
-MONERO_COM_VERSION="1.1.0"
17
-MONERO_COM_BUILD_NUMBER=21
16
+MONERO_COM_VERSION="1.1.1"
17
+MONERO_COM_BUILD_NUMBER=22
18
MONERO_COM_BUNDLE_ID="com.cakewallet.monero"
19
20
CAKEWALLET_NAME="Cake Wallet"
21
-CAKEWALLET_VERSION="4.4.6"
22
-CAKEWALLET_BUILD_NUMBER=117
21
+CAKEWALLET_VERSION="4.4.7"
22
+CAKEWALLET_BUILD_NUMBER=118
23
CAKEWALLET_BUNDLE_ID="com.fotolockr.cakewallet"
24
25
HAVEN_NAME="Haven"