diff --git a/lib/src/domain/common/crypto_currency.dart b/lib/src/domain/common/crypto_currency.dart index 2c04262fc..2032f167a 100644 --- a/lib/src/domain/common/crypto_currency.dart +++ b/lib/src/domain/common/crypto_currency.dart @@ -10,33 +10,65 @@ class CryptoCurrency extends EnumerableItem with Serializable { static const all = [ CryptoCurrency.xmr, + CryptoCurrency.ada, + CryptoCurrency.bch, + CryptoCurrency.bnb, CryptoCurrency.btc, + CryptoCurrency.dash, + CryptoCurrency.eos, CryptoCurrency.eth, CryptoCurrency.ltc, - CryptoCurrency.bch, - CryptoCurrency.dash + CryptoCurrency.nano, + CryptoCurrency.trx, + CryptoCurrency.usdt, + CryptoCurrency.xlm, + CryptoCurrency.xrp ]; static const xmr = CryptoCurrency(title: 'XMR', raw: 0); - static const btc = CryptoCurrency(title: 'BTC', raw: 1); - static const eth = CryptoCurrency(title: 'ETH', raw: 2); - static const ltc = CryptoCurrency(title: 'LTC', raw: 3); - static const bch = CryptoCurrency(title: 'BCH', raw: 4); + static const ada = CryptoCurrency(title: 'ADA', raw: 1); + static const bch = CryptoCurrency(title: 'BCH', raw: 2); + static const bnb = CryptoCurrency(title: 'BNB', raw: 3); + static const btc = CryptoCurrency(title: 'BTC', raw: 4); static const dash = CryptoCurrency(title: 'DASH', raw: 5); + static const eos = CryptoCurrency(title: 'EOS', raw: 6); + static const eth = CryptoCurrency(title: 'ETH', raw: 7); + static const ltc = CryptoCurrency(title: 'LTC', raw: 8); + static const nano = CryptoCurrency(title: 'NANO', raw: 9); + static const trx = CryptoCurrency(title: 'TRX', raw: 10); + static const usdt = CryptoCurrency(title: 'USDT', raw: 11); + static const xlm = CryptoCurrency(title: 'XLM', raw: 12); + static const xrp = CryptoCurrency(title: 'XRP', raw: 13); static CryptoCurrency deserialize({int raw}) { switch (raw) { case 0: - return xmr; + return CryptoCurrency.xmr; case 1: - return btc; + return CryptoCurrency.ada; case 2: - return eth; + return CryptoCurrency.bch; case 3: - return ltc; + return CryptoCurrency.bnb; case 4: - return bch; + return CryptoCurrency.btc; case 5: - return dash; + return CryptoCurrency.dash; + case 6: + return CryptoCurrency.eos; + case 7: + return CryptoCurrency.eth; + case 8: + return CryptoCurrency.ltc; + case 9: + return CryptoCurrency.nano; + case 10: + return CryptoCurrency.trx; + case 11: + return CryptoCurrency.usdt; + case 12: + return CryptoCurrency.xlm; + case 13: + return CryptoCurrency.xrp; default: return null; } @@ -45,17 +77,33 @@ class CryptoCurrency extends EnumerableItem with Serializable { static CryptoCurrency fromString(String raw) { switch (raw.toLowerCase()) { case 'xmr': - return xmr; - case 'btc': - return btc; - case 'eth': - return eth; - case 'ltc': - return ltc; + return CryptoCurrency.xmr; + case 'ada': + return CryptoCurrency.ada; case 'bch': - return bch; + return CryptoCurrency.bch; + case 'bnb': + return CryptoCurrency.bnb; + case 'btc': + return CryptoCurrency.btc; case 'dash': - return dash; + return CryptoCurrency.dash; + case 'eos': + return CryptoCurrency.eos; + case 'eth': + return CryptoCurrency.eth; + case 'ltc': + return CryptoCurrency.ltc; + case 'nano': + return CryptoCurrency.nano; + case 'trx': + return CryptoCurrency.trx; + case 'usdt': + return CryptoCurrency.usdt; + case 'xlm': + return CryptoCurrency.xlm; + case 'xrp': + return CryptoCurrency.xrp; default: return null; } diff --git a/lib/src/screens/address_book/address_book_page.dart b/lib/src/screens/address_book/address_book_page.dart index 002c4d939..4f4146a47 100644 --- a/lib/src/screens/address_book/address_book_page.dart +++ b/lib/src/screens/address_book/address_book_page.dart @@ -177,20 +177,44 @@ class AddressBookPage extends BasePage { case CryptoCurrency.xmr: color = Palette.cakeGreenWithOpacity; break; + case CryptoCurrency.ada: + color = Colors.blueGrey[700]; + break; + case CryptoCurrency.bch: + color = Colors.orangeAccent; + break; + case CryptoCurrency.bnb: + color = Colors.yellow; + break; case CryptoCurrency.btc: color = Colors.orange; break; + case CryptoCurrency.dash: + color = Colors.blue; + break; + case CryptoCurrency.eos: + color = Colors.deepPurple; + break; case CryptoCurrency.eth: color = Colors.black; break; case CryptoCurrency.ltc: color = Colors.blue[200]; break; - case CryptoCurrency.bch: - color = Colors.orangeAccent; + case CryptoCurrency.nano: + color = Colors.blue[900]; break; - case CryptoCurrency.dash: - color = Colors.blue; + case CryptoCurrency.trx: + color = Colors.red; + break; + case CryptoCurrency.usdt: + color = Colors.teal; + break; + case CryptoCurrency.xlm: + color = Colors.grey[100]; + break; + case CryptoCurrency.xrp: + color = Colors.blueAccent; break; default: color = Colors.white; @@ -207,6 +231,12 @@ class AddressBookPage extends BasePage { case CryptoCurrency.ltc: color = Palette.lightBlue; break; + case CryptoCurrency.xlm: + color = Colors.blueAccent; + break; + case CryptoCurrency.xrp: + color = Colors.black; + break; default: color = Colors.white; } diff --git a/lib/src/screens/exchange/widgets/exchange_card.dart b/lib/src/screens/exchange/widgets/exchange_card.dart index 51a16588d..3791ecb90 100644 --- a/lib/src/screens/exchange/widgets/exchange_card.dart +++ b/lib/src/screens/exchange/widgets/exchange_card.dart @@ -135,7 +135,7 @@ class ExchangeCardState extends State { children: [ Container( height: 52, - width: 80, + width: 90, child: InkWell( onTap: () => _presentPicker(context), child: Column( diff --git a/lib/src/stores/address_book/address_book_store.dart b/lib/src/stores/address_book/address_book_store.dart index 8cb1b9ca6..13bd8f591 100644 --- a/lib/src/stores/address_book/address_book_store.dart +++ b/lib/src/stores/address_book/address_book_store.dart @@ -45,30 +45,55 @@ abstract class AddressBookStoreBase with Store { } void validateAddress(String value, {CryptoCurrency cryptoCurrency}) { - // XMR (95), BTC (34, 42), 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 (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]{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) { - switch (cryptoCurrency.toString()) { - case 'XMR': + switch (cryptoCurrency) { + case CryptoCurrency.xmr: isValid = (value.length == 95); break; - case 'BTC': + case CryptoCurrency.ada: + isValid = (value.length == 59)||(value.length == 92)||(value.length == 105); + break; + case CryptoCurrency.bch: + isValid = (value.length == 42); + break; + case CryptoCurrency.bnb: + isValid = (value.length == 42); + break; + case CryptoCurrency.btc: isValid = (value.length == 34)||(value.length == 42); break; - case 'ETH': - isValid = (value.length == 42); - break; - case 'LTC': + case CryptoCurrency.dash: isValid = (value.length == 34); break; - case 'BCH': + case CryptoCurrency.eos: isValid = (value.length == 42); break; - case 'DASH': + case CryptoCurrency.eth: + isValid = (value.length == 42); + break; + case CryptoCurrency.ltc: isValid = (value.length == 34); + break; + case CryptoCurrency.nano: + isValid = (value.length == 64)||(value.length == 65); + 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; } } diff --git a/lib/src/stores/exchange/exchange_store.dart b/lib/src/stores/exchange/exchange_store.dart index 5f625fbb9..7d20fd6c8 100644 --- a/lib/src/stores/exchange/exchange_store.dart +++ b/lib/src/stores/exchange/exchange_store.dart @@ -226,30 +226,55 @@ abstract class ExchangeStoreBase with Store { } void validateAddress(String value, {CryptoCurrency cryptoCurrency}) { - // XMR (95), BTC (34, 42), 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 (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]{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) { - switch (cryptoCurrency.toString()) { - case 'XMR': + switch (cryptoCurrency) { + case CryptoCurrency.xmr: isValid = (value.length == 95); break; - case 'BTC': + case CryptoCurrency.ada: + isValid = (value.length == 59)||(value.length == 92)||(value.length == 105); + break; + case CryptoCurrency.bch: + isValid = (value.length == 42); + break; + case CryptoCurrency.bnb: + isValid = (value.length == 42); + break; + case CryptoCurrency.btc: isValid = (value.length == 34)||(value.length == 42); break; - case 'ETH': - isValid = (value.length == 42); - break; - case 'LTC': + case CryptoCurrency.dash: isValid = (value.length == 34); break; - case 'BCH': + case CryptoCurrency.eos: isValid = (value.length == 42); break; - case 'DASH': + case CryptoCurrency.eth: + isValid = (value.length == 42); + break; + case CryptoCurrency.ltc: isValid = (value.length == 34); + break; + case CryptoCurrency.nano: + isValid = (value.length == 64)||(value.length == 65); + 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; } } diff --git a/lib/src/stores/send/send_store.dart b/lib/src/stores/send/send_store.dart index f5d3229ba..bc9972b62 100644 --- a/lib/src/stores/send/send_store.dart +++ b/lib/src/stores/send/send_store.dart @@ -159,30 +159,55 @@ abstract class SendStoreBase with Store { } void validateAddress(String value, {CryptoCurrency cryptoCurrency}) { - // XMR (95), BTC (34, 42), 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 (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]{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 = 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': + case CryptoCurrency.ada: + isValid = (value.length == 59)||(value.length == 92)||(value.length == 105); + break; + case CryptoCurrency.bch: + isValid = (value.length == 42); + break; + case CryptoCurrency.bnb: + isValid = (value.length == 42); + break; + case CryptoCurrency.btc: isValid = (value.length == 34)||(value.length == 42); break; - case 'ETH': - isValid = (value.length == 42); - break; - case 'LTC': + case CryptoCurrency.dash: isValid = (value.length == 34); break; - case 'BCH': + case CryptoCurrency.eos: isValid = (value.length == 42); break; - case 'DASH': + case CryptoCurrency.eth: + isValid = (value.length == 42); + break; + case CryptoCurrency.ltc: isValid = (value.length == 34); + break; + case CryptoCurrency.nano: + isValid = (value.length == 64)||(value.length == 65); + 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; } } diff --git a/lib/src/stores/wallet_restoration/wallet_restoration_store.dart b/lib/src/stores/wallet_restoration/wallet_restoration_store.dart index ac2e986a0..2565bfc24 100644 --- a/lib/src/stores/wallet_restoration/wallet_restoration_store.dart +++ b/lib/src/stores/wallet_restoration/wallet_restoration_store.dart @@ -116,30 +116,55 @@ abstract class WalleRestorationStoreBase with Store { } void validateAddress(String value, {CryptoCurrency cryptoCurrency}) { - // XMR (95), BTC (34, 42), 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 (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]{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) { - switch (cryptoCurrency.toString()) { - case 'XMR': + switch (cryptoCurrency) { + case CryptoCurrency.xmr: isValid = (value.length == 95); break; - case 'BTC': + case CryptoCurrency.ada: + isValid = (value.length == 59)||(value.length == 92)||(value.length == 105); + break; + case CryptoCurrency.bch: + isValid = (value.length == 42); + break; + case CryptoCurrency.bnb: + isValid = (value.length == 42); + break; + case CryptoCurrency.btc: isValid = (value.length == 34)||(value.length == 42); break; - case 'ETH': - isValid = (value.length == 42); - break; - case 'LTC': + case CryptoCurrency.dash: isValid = (value.length == 34); break; - case 'BCH': + case CryptoCurrency.eos: isValid = (value.length == 42); break; - case 'DASH': + case CryptoCurrency.eth: + isValid = (value.length == 42); + break; + case CryptoCurrency.ltc: isValid = (value.length == 34); + break; + case CryptoCurrency.nano: + isValid = (value.length == 64)||(value.length == 65); + 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; } }