CWA-153 | added changenow cryptocurrencies

This commit is contained in:
Oleksandr Sobol
2020-01-10 17:24:44 +02:00
parent 9b76880e82
commit a7773f9143
8 changed files with 259 additions and 79 deletions
@@ -45,30 +45,55 @@ abstract class AddressBookStoreBase with Store {
}
void validateAddress(String value, {CryptoCurrency cryptoCurrency}) {
// XMR (95), BTC (34), ETH (42), LTC (34), BCH (42), DASH (34)
const pattern = '^[0-9a-zA-Z]{95}\$|^[0-9a-zA-Z]{34}\$|^[0-9a-zA-Z]{42}\$';
// XMR (95), ADA (105), BCH (42), BNB (42), BTC (34, 42), DASH (34), EOS (42),
// ETH (42), LTC (34), NANO (64), TRX (34), USDT (42), XLM (56), XRP (34)
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}\$';
final regExp = RegExp(pattern);
isValid = regExp.hasMatch(value);
if (isValid && cryptoCurrency != null) {
switch (cryptoCurrency.toString()) {
case 'XMR':
switch (cryptoCurrency) {
case CryptoCurrency.xmr:
isValid = (value.length == 95);
break;
case 'BTC':
isValid = (value.length == 34);
case CryptoCurrency.ada:
isValid = (value.length == 105);
break;
case 'ETH':
case CryptoCurrency.bch:
isValid = (value.length == 42);
break;
case 'LTC':
isValid = (value.length == 34);
break;
case 'BCH':
case CryptoCurrency.bnb:
isValid = (value.length == 42);
break;
case 'DASH':
case CryptoCurrency.btc:
isValid = (value.length == 34)||(value.length == 42);
break;
case CryptoCurrency.dash:
isValid = (value.length == 34);
break;
case CryptoCurrency.eos:
isValid = (value.length == 42);
break;
case CryptoCurrency.eth:
isValid = (value.length == 42);
break;
case CryptoCurrency.ltc:
isValid = (value.length == 34);
break;
case CryptoCurrency.nano:
isValid = (value.length == 64);
break;
case CryptoCurrency.trx:
isValid = (value.length == 34);
break;
case CryptoCurrency.usdt:
isValid = (value.length == 42);
break;
case CryptoCurrency.xlm:
isValid = (value.length == 56);
break;
case CryptoCurrency.xrp:
isValid = (value.length == 34);
break;
}
}
+38 -13
View File
@@ -226,30 +226,55 @@ abstract class ExchangeStoreBase with Store {
}
void validateAddress(String value, {CryptoCurrency cryptoCurrency}) {
// XMR (95), BTC (34), ETH (42), LTC (34), BCH (42), DASH (34)
const pattern = '^[0-9a-zA-Z]{95}\$|^[0-9a-zA-Z]{34}\$|^[0-9a-zA-Z]{42}\$';
// XMR (95), ADA (105), BCH (42), BNB (42), BTC (34, 42), DASH (34), EOS (42),
// ETH (42), LTC (34), NANO (64), TRX (34), USDT (42), XLM (56), XRP (34)
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}\$';
final regExp = RegExp(pattern);
isValid = regExp.hasMatch(value);
if (isValid && cryptoCurrency != null) {
switch (cryptoCurrency.toString()) {
case 'XMR':
switch (cryptoCurrency) {
case CryptoCurrency.xmr:
isValid = (value.length == 95);
break;
case 'BTC':
isValid = (value.length == 34);
case CryptoCurrency.ada:
isValid = (value.length == 105);
break;
case 'ETH':
case CryptoCurrency.bch:
isValid = (value.length == 42);
break;
case 'LTC':
isValid = (value.length == 34);
break;
case 'BCH':
case CryptoCurrency.bnb:
isValid = (value.length == 42);
break;
case 'DASH':
case CryptoCurrency.btc:
isValid = (value.length == 34)||(value.length == 42);
break;
case CryptoCurrency.dash:
isValid = (value.length == 34);
break;
case CryptoCurrency.eos:
isValid = (value.length == 42);
break;
case CryptoCurrency.eth:
isValid = (value.length == 42);
break;
case CryptoCurrency.ltc:
isValid = (value.length == 34);
break;
case CryptoCurrency.nano:
isValid = (value.length == 64);
break;
case CryptoCurrency.trx:
isValid = (value.length == 34);
break;
case CryptoCurrency.usdt:
isValid = (value.length == 42);
break;
case CryptoCurrency.xlm:
isValid = (value.length == 56);
break;
case CryptoCurrency.xrp:
isValid = (value.length == 34);
break;
}
}
+39 -14
View File
@@ -159,30 +159,55 @@ abstract class SendStoreBase with Store {
}
void validateAddress(String value, {CryptoCurrency cryptoCurrency}) {
// XMR (95), BTC (34), ETH (42), LTC (34), BCH (42), DASH (34)
const pattern = '^[0-9a-zA-Z]{95}\$|^[0-9a-zA-Z]{34}\$|^[0-9a-zA-Z]{42}\$';
// XMR (95), ADA (105), BCH (42), BNB (42), BTC (34, 42), DASH (34), EOS (42),
// ETH (42), LTC (34), NANO (64), TRX (34), USDT (42), XLM (56), XRP (34)
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}\$';
final regExp = RegExp(pattern);
isValid = value == null ? false : regExp.hasMatch(value);
isValid = regExp.hasMatch(value);
if (isValid && cryptoCurrency != null) {
switch (cryptoCurrency.toString()) {
case 'XMR':
switch (cryptoCurrency) {
case CryptoCurrency.xmr:
isValid = (value.length == 95);
break;
case 'BTC':
isValid = (value.length == 34);
case CryptoCurrency.ada:
isValid = (value.length == 105);
break;
case 'ETH':
case CryptoCurrency.bch:
isValid = (value.length == 42);
break;
case 'LTC':
isValid = (value.length == 34);
break;
case 'BCH':
case CryptoCurrency.bnb:
isValid = (value.length == 42);
break;
case 'DASH':
case CryptoCurrency.btc:
isValid = (value.length == 34)||(value.length == 42);
break;
case CryptoCurrency.dash:
isValid = (value.length == 34);
break;
case CryptoCurrency.eos:
isValid = (value.length == 42);
break;
case CryptoCurrency.eth:
isValid = (value.length == 42);
break;
case CryptoCurrency.ltc:
isValid = (value.length == 34);
break;
case CryptoCurrency.nano:
isValid = (value.length == 64);
break;
case CryptoCurrency.trx:
isValid = (value.length == 34);
break;
case CryptoCurrency.usdt:
isValid = (value.length == 42);
break;
case CryptoCurrency.xlm:
isValid = (value.length == 56);
break;
case CryptoCurrency.xrp:
isValid = (value.length == 34);
break;
}
}
@@ -116,30 +116,55 @@ abstract class WalleRestorationStoreBase with Store {
}
void validateAddress(String value, {CryptoCurrency cryptoCurrency}) {
// XMR (95), BTC (34), ETH (42), LTC (34), BCH (42), DASH (34)
const pattern = '^[0-9a-zA-Z]{95}\$|^[0-9a-zA-Z]{34}\$|^[0-9a-zA-Z]{42}\$';
// XMR (95), ADA (105), BCH (42), BNB (42), BTC (34, 42), DASH (34), EOS (42),
// ETH (42), LTC (34), NANO (64), TRX (34), USDT (42), XLM (56), XRP (34)
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}\$';
final regExp = RegExp(pattern);
isValid = regExp.hasMatch(value);
if (isValid && cryptoCurrency != null) {
switch (cryptoCurrency.toString()) {
case 'XMR':
switch (cryptoCurrency) {
case CryptoCurrency.xmr:
isValid = (value.length == 95);
break;
case 'BTC':
isValid = (value.length == 34);
case CryptoCurrency.ada:
isValid = (value.length == 105);
break;
case 'ETH':
case CryptoCurrency.bch:
isValid = (value.length == 42);
break;
case 'LTC':
isValid = (value.length == 34);
break;
case 'BCH':
case CryptoCurrency.bnb:
isValid = (value.length == 42);
break;
case 'DASH':
case CryptoCurrency.btc:
isValid = (value.length == 34)||(value.length == 42);
break;
case CryptoCurrency.dash:
isValid = (value.length == 34);
break;
case CryptoCurrency.eos:
isValid = (value.length == 42);
break;
case CryptoCurrency.eth:
isValid = (value.length == 42);
break;
case CryptoCurrency.ltc:
isValid = (value.length == 34);
break;
case CryptoCurrency.nano:
isValid = (value.length == 64);
break;
case CryptoCurrency.trx:
isValid = (value.length == 34);
break;
case CryptoCurrency.usdt:
isValid = (value.length == 42);
break;
case CryptoCurrency.xlm:
isValid = (value.length == 56);
break;
case CryptoCurrency.xrp:
isValid = (value.length == 34);
break;
}
}