CWA-153 | added changenow cryptocurrencies

Oleksandr Sobol committed Jan 10, 2020 at 17:24 UTC a7773f914334d10e73e31d67968b35ca5f6c41fb
8 files changed +246 -66
.gitignore
+2
@@ -88,3 +88,5 @@ android/key.properties
88
89 **/tool/.secrets-prod.json
90 **/lib/.secrets.g.dart
91 +
92 +**/lib/generated/i18n.dart
\ No newline at end of file
lib/src/domain/common/crypto_currency.dart
+68 -20
@@ -10,33 +10,65 @@ class CryptoCurrency extends EnumerableItem<int> with Serializable<int> {
10
11 static const all = [
12 CryptoCurrency.xmr,
13 + CryptoCurrency.ada,
14 + CryptoCurrency.bch,
15 + CryptoCurrency.bnb,
16 CryptoCurrency.btc,
17 + CryptoCurrency.dash,
18 + CryptoCurrency.eos,
19 CryptoCurrency.eth,
20 CryptoCurrency.ltc,
16 - CryptoCurrency.bch,
17 - CryptoCurrency.dash
21 + CryptoCurrency.nano,
22 + CryptoCurrency.trx,
23 + CryptoCurrency.usdt,
24 + CryptoCurrency.xlm,
25 + CryptoCurrency.xrp
26 ];
27 static const xmr = CryptoCurrency(title: 'XMR', raw: 0);
20 - static const btc = CryptoCurrency(title: 'BTC', raw: 1);
21 - static const eth = CryptoCurrency(title: 'ETH', raw: 2);
22 - static const ltc = CryptoCurrency(title: 'LTC', raw: 3);
23 - static const bch = CryptoCurrency(title: 'BCH', raw: 4);
28 + static const ada = CryptoCurrency(title: 'ADA', raw: 1);
29 + static const bch = CryptoCurrency(title: 'BCH', raw: 2);
30 + static const bnb = CryptoCurrency(title: 'BNB', raw: 3);
31 + static const btc = CryptoCurrency(title: 'BTC', raw: 4);
32 static const dash = CryptoCurrency(title: 'DASH', raw: 5);
33 + static const eos = CryptoCurrency(title: 'EOS', raw: 6);
34 + static const eth = CryptoCurrency(title: 'ETH', raw: 7);
35 + static const ltc = CryptoCurrency(title: 'LTC', raw: 8);
36 + static const nano = CryptoCurrency(title: 'NANO', raw: 9);
37 + static const trx = CryptoCurrency(title: 'TRX', raw: 10);
38 + static const usdt = CryptoCurrency(title: 'USDT', raw: 11);
39 + static const xlm = CryptoCurrency(title: 'XLM', raw: 12);
40 + static const xrp = CryptoCurrency(title: 'XRP', raw: 13);
41
42 static CryptoCurrency deserialize({int raw}) {
43 switch (raw) {
44 case 0:
29 - return xmr;
45 + return CryptoCurrency.xmr;
46 case 1:
31 - return btc;
47 + return CryptoCurrency.ada;
48 case 2:
33 - return eth;
49 + return CryptoCurrency.bch;
50 case 3:
35 - return ltc;
51 + return CryptoCurrency.bnb;
52 case 4:
37 - return bch;
53 + return CryptoCurrency.btc;
54 case 5:
39 - return dash;
55 + return CryptoCurrency.dash;
56 + case 6:
57 + return CryptoCurrency.eos;
58 + case 7:
59 + return CryptoCurrency.eth;
60 + case 8:
61 + return CryptoCurrency.ltc;
62 + case 9:
63 + return CryptoCurrency.nano;
64 + case 10:
65 + return CryptoCurrency.trx;
66 + case 11:
67 + return CryptoCurrency.usdt;
68 + case 12:
69 + return CryptoCurrency.xlm;
70 + case 13:
71 + return CryptoCurrency.xrp;
72 default:
73 return null;
74 }
@@ -45,17 +77,33 @@ class CryptoCurrency extends EnumerableItem<int> with Serializable<int> {
77 static CryptoCurrency fromString(String raw) {
78 switch (raw.toLowerCase()) {
79 case 'xmr':
48 - return xmr;
80 + return CryptoCurrency.xmr;
81 + case 'ada':
82 + return CryptoCurrency.ada;
83 + case 'bch':
84 + return CryptoCurrency.bch;
85 + case 'bnb':
86 + return CryptoCurrency.bnb;
87 case 'btc':
50 - return btc;
88 + return CryptoCurrency.btc;
89 + case 'dash':
90 + return CryptoCurrency.dash;
91 + case 'eos':
92 + return CryptoCurrency.eos;
93 case 'eth':
52 - return eth;
94 + return CryptoCurrency.eth;
95 case 'ltc':
54 - return ltc;
55 - case 'bch':
56 - return bch;
57 - case 'dash':
58 - return dash;
96 + return CryptoCurrency.ltc;
97 + case 'nano':
98 + return CryptoCurrency.nano;
99 + case 'trx':
100 + return CryptoCurrency.trx;
101 + case 'usdt':
102 + return CryptoCurrency.usdt;
103 + case 'xlm':
104 + return CryptoCurrency.xlm;
105 + case 'xrp':
106 + return CryptoCurrency.xrp;
107 default:
108 return null;
109 }
lib/src/screens/address_book/address_book_page.dart
+34 -4
@@ -177,20 +177,44 @@ class AddressBookPage extends BasePage {
177 case CryptoCurrency.xmr:
178 color = Palette.cakeGreenWithOpacity;
179 break;
180 + case CryptoCurrency.ada:
181 + color = Colors.blueGrey[700];
182 + break;
183 + case CryptoCurrency.bch:
184 + color = Colors.orangeAccent;
185 + break;
186 + case CryptoCurrency.bnb:
187 + color = Colors.yellow;
188 + break;
189 case CryptoCurrency.btc:
190 color = Colors.orange;
191 break;
192 + case CryptoCurrency.dash:
193 + color = Colors.blue;
194 + break;
195 + case CryptoCurrency.eos:
196 + color = Colors.deepPurple;
197 + break;
198 case CryptoCurrency.eth:
199 color = Colors.black;
200 break;
201 case CryptoCurrency.ltc:
202 color = Colors.blue[200];
203 break;
189 - case CryptoCurrency.bch:
190 - color = Colors.orangeAccent;
204 + case CryptoCurrency.nano:
205 + color = Colors.blue[900];
206 break;
192 - case CryptoCurrency.dash:
193 - color = Colors.blue;
207 + case CryptoCurrency.trx:
208 + color = Colors.red;
209 + break;
210 + case CryptoCurrency.usdt:
211 + color = Colors.teal;
212 + break;
213 + case CryptoCurrency.xlm:
214 + color = Colors.grey[100];
215 + break;
216 + case CryptoCurrency.xrp:
217 + color = Colors.blueAccent;
218 break;
219 default:
220 color = Colors.white;
@@ -207,6 +231,12 @@ class AddressBookPage extends BasePage {
231 case CryptoCurrency.ltc:
232 color = Palette.lightBlue;
233 break;
234 + case CryptoCurrency.xlm:
235 + color = Colors.blueAccent;
236 + break;
237 + case CryptoCurrency.xrp:
238 + color = Colors.black;
239 + break;
240 default:
241 color = Colors.white;
242 }
lib/src/screens/exchange/widgets/exchange_card.dart
+1 -1
@@ -135,7 +135,7 @@ class ExchangeCardState extends State<ExchangeCard> {
135 children: <Widget>[
136 Container(
137 height: 52,
138 - width: 80,
138 + width: 90,
139 child: InkWell(
140 onTap: () => _presentPicker(context),
141 child: Column(
lib/src/stores/address_book/address_book_store.dart
+35 -10
@@ -45,30 +45,55 @@ abstract class AddressBookStoreBase with Store {
45 }
46
47 void validateAddress(String value, {CryptoCurrency cryptoCurrency}) {
48 - // XMR (95), BTC (34), ETH (42), LTC (34), BCH (42), DASH (34)
49 - const pattern = '^[0-9a-zA-Z]{95}\$|^[0-9a-zA-Z]{34}\$|^[0-9a-zA-Z]{42}\$';
48 + // XMR (95), ADA (105), BCH (42), BNB (42), BTC (34, 42), DASH (34), EOS (42),
49 + // ETH (42), LTC (34), NANO (64), TRX (34), USDT (42), XLM (56), XRP (34)
50 + const pattern = '^[0-9a-zA-Z]{95}\$|^[0-9a-zA-Z]{34}\$|^[0-9a-zA-Z]{42}\$|^[0-9a-zA-Z]{56}\$|^[0-9a-zA-Z]{64}\$|^[0-9a-zA-Z]{105}\$';
51 final regExp = RegExp(pattern);
52 isValid = regExp.hasMatch(value);
52 -
53 if (isValid && cryptoCurrency != null) {
54 - switch (cryptoCurrency.toString()) {
55 - case 'XMR':
54 + switch (cryptoCurrency) {
55 + case CryptoCurrency.xmr:
56 isValid = (value.length == 95);
57 break;
58 - case 'BTC':
58 + case CryptoCurrency.ada:
59 + isValid = (value.length == 105);
60 + break;
61 + case CryptoCurrency.bch:
62 + isValid = (value.length == 42);
63 + break;
64 + case CryptoCurrency.bnb:
65 + isValid = (value.length == 42);
66 + break;
67 + case CryptoCurrency.btc:
68 + isValid = (value.length == 34)||(value.length == 42);
69 + break;
70 + case CryptoCurrency.dash:
71 isValid = (value.length == 34);
72 break;
61 - case 'ETH':
73 + case CryptoCurrency.eos:
74 isValid = (value.length == 42);
75 break;
64 - case 'LTC':
76 + case CryptoCurrency.eth:
77 + isValid = (value.length == 42);
78 + break;
79 + case CryptoCurrency.ltc:
80 isValid = (value.length == 34);
81 break;
67 - case 'BCH':
82 + case CryptoCurrency.nano:
83 + isValid = (value.length == 64);
84 + break;
85 + case CryptoCurrency.trx:
86 + isValid = (value.length == 34);
87 + break;
88 + case CryptoCurrency.usdt:
89 isValid = (value.length == 42);
90 break;
70 - case 'DASH':
91 + case CryptoCurrency.xlm:
92 + isValid = (value.length == 56);
93 + break;
94 + case CryptoCurrency.xrp:
95 isValid = (value.length == 34);
96 + break;
97 }
98 }
99
lib/src/stores/exchange/exchange_store.dart
+35 -10
@@ -226,30 +226,55 @@ abstract class ExchangeStoreBase with Store {
226 }
227
228 void validateAddress(String value, {CryptoCurrency cryptoCurrency}) {
229 - // XMR (95), BTC (34), ETH (42), LTC (34), BCH (42), DASH (34)
230 - const pattern = '^[0-9a-zA-Z]{95}\$|^[0-9a-zA-Z]{34}\$|^[0-9a-zA-Z]{42}\$';
229 + // XMR (95), ADA (105), BCH (42), BNB (42), BTC (34, 42), DASH (34), EOS (42),
230 + // ETH (42), LTC (34), NANO (64), TRX (34), USDT (42), XLM (56), XRP (34)
231 + const pattern = '^[0-9a-zA-Z]{95}\$|^[0-9a-zA-Z]{34}\$|^[0-9a-zA-Z]{42}\$|^[0-9a-zA-Z]{56}\$|^[0-9a-zA-Z]{64}\$|^[0-9a-zA-Z]{105}\$';
232 final regExp = RegExp(pattern);
233 isValid = regExp.hasMatch(value);
233 -
234 if (isValid && cryptoCurrency != null) {
235 - switch (cryptoCurrency.toString()) {
236 - case 'XMR':
235 + switch (cryptoCurrency) {
236 + case CryptoCurrency.xmr:
237 isValid = (value.length == 95);
238 break;
239 - case 'BTC':
239 + case CryptoCurrency.ada:
240 + isValid = (value.length == 105);
241 + break;
242 + case CryptoCurrency.bch:
243 + isValid = (value.length == 42);
244 + break;
245 + case CryptoCurrency.bnb:
246 + isValid = (value.length == 42);
247 + break;
248 + case CryptoCurrency.btc:
249 + isValid = (value.length == 34)||(value.length == 42);
250 + break;
251 + case CryptoCurrency.dash:
252 isValid = (value.length == 34);
253 break;
242 - case 'ETH':
254 + case CryptoCurrency.eos:
255 isValid = (value.length == 42);
256 break;
245 - case 'LTC':
257 + case CryptoCurrency.eth:
258 + isValid = (value.length == 42);
259 + break;
260 + case CryptoCurrency.ltc:
261 isValid = (value.length == 34);
262 break;
248 - case 'BCH':
263 + case CryptoCurrency.nano:
264 + isValid = (value.length == 64);
265 + break;
266 + case CryptoCurrency.trx:
267 + isValid = (value.length == 34);
268 + break;
269 + case CryptoCurrency.usdt:
270 isValid = (value.length == 42);
271 break;
251 - case 'DASH':
272 + case CryptoCurrency.xlm:
273 + isValid = (value.length == 56);
274 + break;
275 + case CryptoCurrency.xrp:
276 isValid = (value.length == 34);
277 + break;
278 }
279 }
280
lib/src/stores/send/send_store.dart
+36 -11
@@ -159,30 +159,55 @@ abstract class SendStoreBase with Store {
159 }
160
161 void validateAddress(String value, {CryptoCurrency cryptoCurrency}) {
162 - // XMR (95), BTC (34), ETH (42), LTC (34), BCH (42), DASH (34)
163 - const pattern = '^[0-9a-zA-Z]{95}\$|^[0-9a-zA-Z]{34}\$|^[0-9a-zA-Z]{42}\$';
162 + // XMR (95), ADA (105), BCH (42), BNB (42), BTC (34, 42), DASH (34), EOS (42),
163 + // ETH (42), LTC (34), NANO (64), TRX (34), USDT (42), XLM (56), XRP (34)
164 + const pattern = '^[0-9a-zA-Z]{95}\$|^[0-9a-zA-Z]{34}\$|^[0-9a-zA-Z]{42}\$|^[0-9a-zA-Z]{56}\$|^[0-9a-zA-Z]{64}\$|^[0-9a-zA-Z]{105}\$';
165 final regExp = RegExp(pattern);
165 - isValid = value == null ? false : regExp.hasMatch(value);
166 -
166 + isValid = regExp.hasMatch(value);
167 if (isValid && cryptoCurrency != null) {
168 - switch (cryptoCurrency.toString()) {
169 - case 'XMR':
168 + switch (cryptoCurrency) {
169 + case CryptoCurrency.xmr:
170 isValid = (value.length == 95);
171 break;
172 - case 'BTC':
172 + case CryptoCurrency.ada:
173 + isValid = (value.length == 105);
174 + break;
175 + case CryptoCurrency.bch:
176 + isValid = (value.length == 42);
177 + break;
178 + case CryptoCurrency.bnb:
179 + isValid = (value.length == 42);
180 + break;
181 + case CryptoCurrency.btc:
182 + isValid = (value.length == 34)||(value.length == 42);
183 + break;
184 + case CryptoCurrency.dash:
185 isValid = (value.length == 34);
186 break;
175 - case 'ETH':
187 + case CryptoCurrency.eos:
188 isValid = (value.length == 42);
189 break;
178 - case 'LTC':
190 + case CryptoCurrency.eth:
191 + isValid = (value.length == 42);
192 + break;
193 + case CryptoCurrency.ltc:
194 isValid = (value.length == 34);
195 break;
181 - case 'BCH':
196 + case CryptoCurrency.nano:
197 + isValid = (value.length == 64);
198 + break;
199 + case CryptoCurrency.trx:
200 + isValid = (value.length == 34);
201 + break;
202 + case CryptoCurrency.usdt:
203 isValid = (value.length == 42);
204 break;
184 - case 'DASH':
205 + case CryptoCurrency.xlm:
206 + isValid = (value.length == 56);
207 + break;
208 + case CryptoCurrency.xrp:
209 isValid = (value.length == 34);
210 + break;
211 }
212 }
213
lib/src/stores/wallet_restoration/wallet_restoration_store.dart
+35 -10
@@ -116,30 +116,55 @@ abstract class WalleRestorationStoreBase with Store {
116 }
117
118 void validateAddress(String value, {CryptoCurrency cryptoCurrency}) {
119 - // XMR (95), BTC (34), ETH (42), LTC (34), BCH (42), DASH (34)
120 - const pattern = '^[0-9a-zA-Z]{95}\$|^[0-9a-zA-Z]{34}\$|^[0-9a-zA-Z]{42}\$';
119 + // XMR (95), ADA (105), BCH (42), BNB (42), BTC (34, 42), DASH (34), EOS (42),
120 + // ETH (42), LTC (34), NANO (64), TRX (34), USDT (42), XLM (56), XRP (34)
121 + const pattern = '^[0-9a-zA-Z]{95}\$|^[0-9a-zA-Z]{34}\$|^[0-9a-zA-Z]{42}\$|^[0-9a-zA-Z]{56}\$|^[0-9a-zA-Z]{64}\$|^[0-9a-zA-Z]{105}\$';
122 final regExp = RegExp(pattern);
123 isValid = regExp.hasMatch(value);
123 -
124 if (isValid && cryptoCurrency != null) {
125 - switch (cryptoCurrency.toString()) {
126 - case 'XMR':
125 + switch (cryptoCurrency) {
126 + case CryptoCurrency.xmr:
127 isValid = (value.length == 95);
128 break;
129 - case 'BTC':
129 + case CryptoCurrency.ada:
130 + isValid = (value.length == 105);
131 + break;
132 + case CryptoCurrency.bch:
133 + isValid = (value.length == 42);
134 + break;
135 + case CryptoCurrency.bnb:
136 + isValid = (value.length == 42);
137 + break;
138 + case CryptoCurrency.btc:
139 + isValid = (value.length == 34)||(value.length == 42);
140 + break;
141 + case CryptoCurrency.dash:
142 isValid = (value.length == 34);
143 break;
132 - case 'ETH':
144 + case CryptoCurrency.eos:
145 isValid = (value.length == 42);
146 break;
135 - case 'LTC':
147 + case CryptoCurrency.eth:
148 + isValid = (value.length == 42);
149 + break;
150 + case CryptoCurrency.ltc:
151 isValid = (value.length == 34);
152 break;
138 - case 'BCH':
153 + case CryptoCurrency.nano:
154 + isValid = (value.length == 64);
155 + break;
156 + case CryptoCurrency.trx:
157 + isValid = (value.length == 34);
158 + break;
159 + case CryptoCurrency.usdt:
160 isValid = (value.length == 42);
161 break;
141 - case 'DASH':
162 + case CryptoCurrency.xlm:
163 + isValid = (value.length == 56);
164 + break;
165 + case CryptoCurrency.xrp:
166 isValid = (value.length == 34);
167 + break;
168 }
169 }
170