From 89354b083bdcd6936fa95c80b032e150a5726c42 Mon Sep 17 00:00:00 2001 From: Oleksandr Sobol Date: Fri, 10 Jan 2020 21:54:59 +0200 Subject: [PATCH] CWA-153 | fixed validation for ada and nano --- .gitignore | 4 +--- lib/src/stores/address_book/address_book_store.dart | 6 +++--- lib/src/stores/exchange/exchange_store.dart | 6 +++--- lib/src/stores/send/send_store.dart | 6 +++--- .../stores/wallet_restoration/wallet_restoration_store.dart | 6 +++--- 5 files changed, 13 insertions(+), 15 deletions(-) diff --git a/.gitignore b/.gitignore index 870145a25..7a496dccf 100644 --- a/.gitignore +++ b/.gitignore @@ -87,6 +87,4 @@ cw_monero/cw_monero/android/.cxx/ android/key.properties **/tool/.secrets-prod.json -**/lib/.secrets.g.dart - -**/lib/generated/i18n.dart \ No newline at end of file +**/lib/.secrets.g.dart \ No newline at end of file diff --git a/lib/src/stores/address_book/address_book_store.dart b/lib/src/stores/address_book/address_book_store.dart index c36e7ea5e..803b9008d 100644 --- a/lib/src/stores/address_book/address_book_store.dart +++ b/lib/src/stores/address_book/address_book_store.dart @@ -45,9 +45,9 @@ abstract class AddressBookStoreBase with Store { } void validateAddress(String value, {CryptoCurrency cryptoCurrency}) { - // XMR (95), ADA (105), BCH (42), BNB (42), BTC (34, 42), DASH (34), EOS (42), + // XMR (95), ADA (59, 92, 105), BCH (42), BNB (42), BTC (34, 42), DASH (34), EOS (42), // ETH (42), LTC (34), NANO (64, 65), 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]{65}\$|^[0-9a-zA-Z]{105}\$'; + 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]{59}\$|^[0-9a-zA-Z]{64}\$|^[0-9a-zA-Z]{65}\$|^[0-9a-zA-Z]{92}\$|^[0-9a-zA-Z]{105}\$'; final regExp = RegExp(pattern); isValid = regExp.hasMatch(value); if (isValid && cryptoCurrency != null) { @@ -56,7 +56,7 @@ abstract class AddressBookStoreBase with Store { isValid = (value.length == 95); break; case CryptoCurrency.ada: - isValid = (value.length == 105); + isValid = (value.length == 59)||(value.length == 92)||(value.length == 105); break; case CryptoCurrency.bch: isValid = (value.length == 42); diff --git a/lib/src/stores/exchange/exchange_store.dart b/lib/src/stores/exchange/exchange_store.dart index 23cc7d0da..7e5e2ea3b 100644 --- a/lib/src/stores/exchange/exchange_store.dart +++ b/lib/src/stores/exchange/exchange_store.dart @@ -226,9 +226,9 @@ abstract class ExchangeStoreBase with Store { } void validateAddress(String value, {CryptoCurrency cryptoCurrency}) { - // XMR (95), ADA (105), BCH (42), BNB (42), BTC (34, 42), DASH (34), EOS (42), + // XMR (95), ADA (59, 92, 105), BCH (42), BNB (42), BTC (34, 42), DASH (34), EOS (42), // ETH (42), LTC (34), NANO (64, 65), 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]{65}\$|^[0-9a-zA-Z]{105}\$'; + 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]{59}\$|^[0-9a-zA-Z]{64}\$|^[0-9a-zA-Z]{65}\$|^[0-9a-zA-Z]{92}\$|^[0-9a-zA-Z]{105}\$'; final regExp = RegExp(pattern); isValid = regExp.hasMatch(value); if (isValid && cryptoCurrency != null) { @@ -237,7 +237,7 @@ abstract class ExchangeStoreBase with Store { isValid = (value.length == 95); break; case CryptoCurrency.ada: - isValid = (value.length == 105); + isValid = (value.length == 59)||(value.length == 92)||(value.length == 105); break; case CryptoCurrency.bch: isValid = (value.length == 42); diff --git a/lib/src/stores/send/send_store.dart b/lib/src/stores/send/send_store.dart index 75c369ea4..d3b31e5a9 100644 --- a/lib/src/stores/send/send_store.dart +++ b/lib/src/stores/send/send_store.dart @@ -159,9 +159,9 @@ abstract class SendStoreBase with Store { } void validateAddress(String value, {CryptoCurrency cryptoCurrency}) { - // XMR (95), ADA (105), BCH (42), BNB (42), BTC (34, 42), DASH (34), EOS (42), + // XMR (95), ADA (59, 92, 105), BCH (42), BNB (42), BTC (34, 42), DASH (34), EOS (42), // ETH (42), LTC (34), NANO (64, 65), 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]{65}\$|^[0-9a-zA-Z]{105}\$'; + 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]{59}\$|^[0-9a-zA-Z]{64}\$|^[0-9a-zA-Z]{65}\$|^[0-9a-zA-Z]{92}\$|^[0-9a-zA-Z]{105}\$'; final regExp = RegExp(pattern); isValid = regExp.hasMatch(value); if (isValid && cryptoCurrency != null) { @@ -170,7 +170,7 @@ abstract class SendStoreBase with Store { isValid = (value.length == 95); break; case CryptoCurrency.ada: - isValid = (value.length == 105); + isValid = (value.length == 59)||(value.length == 92)||(value.length == 105); break; case CryptoCurrency.bch: isValid = (value.length == 42); diff --git a/lib/src/stores/wallet_restoration/wallet_restoration_store.dart b/lib/src/stores/wallet_restoration/wallet_restoration_store.dart index e40a1539d..c81afdd8b 100644 --- a/lib/src/stores/wallet_restoration/wallet_restoration_store.dart +++ b/lib/src/stores/wallet_restoration/wallet_restoration_store.dart @@ -116,9 +116,9 @@ abstract class WalleRestorationStoreBase with Store { } void validateAddress(String value, {CryptoCurrency cryptoCurrency}) { - // XMR (95), ADA (105), BCH (42), BNB (42), BTC (34, 42), DASH (34), EOS (42), + // XMR (95), ADA (59, 92, 105), BCH (42), BNB (42), BTC (34, 42), DASH (34), EOS (42), // ETH (42), LTC (34), NANO (64, 65), 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]{65}\$|^[0-9a-zA-Z]{105}\$'; + 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]{59}\$|^[0-9a-zA-Z]{64}\$|^[0-9a-zA-Z]{65}\$|^[0-9a-zA-Z]{92}\$|^[0-9a-zA-Z]{105}\$'; final regExp = RegExp(pattern); isValid = regExp.hasMatch(value); if (isValid && cryptoCurrency != null) { @@ -127,7 +127,7 @@ abstract class WalleRestorationStoreBase with Store { isValid = (value.length == 95); break; case CryptoCurrency.ada: - isValid = (value.length == 105); + isValid = (value.length == 59)||(value.length == 92)||(value.length == 105); break; case CryptoCurrency.bch: isValid = (value.length == 42);