Merge pull request #16 from cake-tech/CWA-153-changenow-cryptocurrencies

Cwa 153 changenow cryptocurrencies
This commit is contained in:
M 2020-01-10 22:29:44 +02:00
commit 8c15dded7f
7 changed files with 253 additions and 75 deletions

View file

@ -10,33 +10,65 @@ class CryptoCurrency extends EnumerableItem<int> with Serializable<int> {
static const all = [ static const all = [
CryptoCurrency.xmr, CryptoCurrency.xmr,
CryptoCurrency.ada,
CryptoCurrency.bch,
CryptoCurrency.bnb,
CryptoCurrency.btc, CryptoCurrency.btc,
CryptoCurrency.dash,
CryptoCurrency.eos,
CryptoCurrency.eth, CryptoCurrency.eth,
CryptoCurrency.ltc, CryptoCurrency.ltc,
CryptoCurrency.bch, CryptoCurrency.nano,
CryptoCurrency.dash CryptoCurrency.trx,
CryptoCurrency.usdt,
CryptoCurrency.xlm,
CryptoCurrency.xrp
]; ];
static const xmr = CryptoCurrency(title: 'XMR', raw: 0); static const xmr = CryptoCurrency(title: 'XMR', raw: 0);
static const btc = CryptoCurrency(title: 'BTC', raw: 1); static const ada = CryptoCurrency(title: 'ADA', raw: 1);
static const eth = CryptoCurrency(title: 'ETH', raw: 2); static const bch = CryptoCurrency(title: 'BCH', raw: 2);
static const ltc = CryptoCurrency(title: 'LTC', raw: 3); static const bnb = CryptoCurrency(title: 'BNB', raw: 3);
static const bch = CryptoCurrency(title: 'BCH', raw: 4); static const btc = CryptoCurrency(title: 'BTC', raw: 4);
static const dash = CryptoCurrency(title: 'DASH', raw: 5); 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}) { static CryptoCurrency deserialize({int raw}) {
switch (raw) { switch (raw) {
case 0: case 0:
return xmr; return CryptoCurrency.xmr;
case 1: case 1:
return btc; return CryptoCurrency.ada;
case 2: case 2:
return eth; return CryptoCurrency.bch;
case 3: case 3:
return ltc; return CryptoCurrency.bnb;
case 4: case 4:
return bch; return CryptoCurrency.btc;
case 5: 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: default:
return null; return null;
} }
@ -45,17 +77,33 @@ class CryptoCurrency extends EnumerableItem<int> with Serializable<int> {
static CryptoCurrency fromString(String raw) { static CryptoCurrency fromString(String raw) {
switch (raw.toLowerCase()) { switch (raw.toLowerCase()) {
case 'xmr': case 'xmr':
return xmr; return CryptoCurrency.xmr;
case 'btc': case 'ada':
return btc; return CryptoCurrency.ada;
case 'eth':
return eth;
case 'ltc':
return ltc;
case 'bch': case 'bch':
return bch; return CryptoCurrency.bch;
case 'bnb':
return CryptoCurrency.bnb;
case 'btc':
return CryptoCurrency.btc;
case 'dash': 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: default:
return null; return null;
} }

View file

@ -177,20 +177,44 @@ class AddressBookPage extends BasePage {
case CryptoCurrency.xmr: case CryptoCurrency.xmr:
color = Palette.cakeGreenWithOpacity; color = Palette.cakeGreenWithOpacity;
break; 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: case CryptoCurrency.btc:
color = Colors.orange; color = Colors.orange;
break; break;
case CryptoCurrency.dash:
color = Colors.blue;
break;
case CryptoCurrency.eos:
color = Colors.deepPurple;
break;
case CryptoCurrency.eth: case CryptoCurrency.eth:
color = Colors.black; color = Colors.black;
break; break;
case CryptoCurrency.ltc: case CryptoCurrency.ltc:
color = Colors.blue[200]; color = Colors.blue[200];
break; break;
case CryptoCurrency.bch: case CryptoCurrency.nano:
color = Colors.orangeAccent; color = Colors.blue[900];
break; break;
case CryptoCurrency.dash: case CryptoCurrency.trx:
color = Colors.blue; 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; break;
default: default:
color = Colors.white; color = Colors.white;
@ -207,6 +231,12 @@ class AddressBookPage extends BasePage {
case CryptoCurrency.ltc: case CryptoCurrency.ltc:
color = Palette.lightBlue; color = Palette.lightBlue;
break; break;
case CryptoCurrency.xlm:
color = Colors.blueAccent;
break;
case CryptoCurrency.xrp:
color = Colors.black;
break;
default: default:
color = Colors.white; color = Colors.white;
} }

View file

@ -135,7 +135,7 @@ class ExchangeCardState extends State<ExchangeCard> {
children: <Widget>[ children: <Widget>[
Container( Container(
height: 52, height: 52,
width: 80, width: 90,
child: InkWell( child: InkWell(
onTap: () => _presentPicker(context), onTap: () => _presentPicker(context),
child: Column( child: Column(

View file

@ -45,30 +45,55 @@ abstract class AddressBookStoreBase with Store {
} }
void validateAddress(String value, {CryptoCurrency cryptoCurrency}) { void validateAddress(String value, {CryptoCurrency cryptoCurrency}) {
// XMR (95), BTC (34, 42), ETH (42), LTC (34), BCH (42), DASH (34) // XMR (95), ADA (59, 92, 105), BCH (42), BNB (42), BTC (34, 42), DASH (34), EOS (42),
const pattern = '^[0-9a-zA-Z]{95}\$|^[0-9a-zA-Z]{34}\$|^[0-9a-zA-Z]{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); final regExp = RegExp(pattern);
isValid = regExp.hasMatch(value); isValid = regExp.hasMatch(value);
if (isValid && cryptoCurrency != null) { if (isValid && cryptoCurrency != null) {
switch (cryptoCurrency.toString()) { switch (cryptoCurrency) {
case 'XMR': case CryptoCurrency.xmr:
isValid = (value.length == 95); isValid = (value.length == 95);
break; 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); isValid = (value.length == 34)||(value.length == 42);
break; break;
case 'ETH': case CryptoCurrency.dash:
isValid = (value.length == 42);
break;
case 'LTC':
isValid = (value.length == 34); isValid = (value.length == 34);
break; break;
case 'BCH': case CryptoCurrency.eos:
isValid = (value.length == 42); isValid = (value.length == 42);
break; break;
case 'DASH': case CryptoCurrency.eth:
isValid = (value.length == 42);
break;
case CryptoCurrency.ltc:
isValid = (value.length == 34); 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;
} }
} }

View file

@ -226,30 +226,55 @@ abstract class ExchangeStoreBase with Store {
} }
void validateAddress(String value, {CryptoCurrency cryptoCurrency}) { void validateAddress(String value, {CryptoCurrency cryptoCurrency}) {
// XMR (95), BTC (34, 42), ETH (42), LTC (34), BCH (42), DASH (34) // XMR (95), ADA (59, 92, 105), BCH (42), BNB (42), BTC (34, 42), DASH (34), EOS (42),
const pattern = '^[0-9a-zA-Z]{95}\$|^[0-9a-zA-Z]{34}\$|^[0-9a-zA-Z]{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); final regExp = RegExp(pattern);
isValid = regExp.hasMatch(value); isValid = regExp.hasMatch(value);
if (isValid && cryptoCurrency != null) { if (isValid && cryptoCurrency != null) {
switch (cryptoCurrency.toString()) { switch (cryptoCurrency) {
case 'XMR': case CryptoCurrency.xmr:
isValid = (value.length == 95); isValid = (value.length == 95);
break; 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); isValid = (value.length == 34)||(value.length == 42);
break; break;
case 'ETH': case CryptoCurrency.dash:
isValid = (value.length == 42);
break;
case 'LTC':
isValid = (value.length == 34); isValid = (value.length == 34);
break; break;
case 'BCH': case CryptoCurrency.eos:
isValid = (value.length == 42); isValid = (value.length == 42);
break; break;
case 'DASH': case CryptoCurrency.eth:
isValid = (value.length == 42);
break;
case CryptoCurrency.ltc:
isValid = (value.length == 34); 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;
} }
} }

View file

@ -159,30 +159,55 @@ abstract class SendStoreBase with Store {
} }
void validateAddress(String value, {CryptoCurrency cryptoCurrency}) { void validateAddress(String value, {CryptoCurrency cryptoCurrency}) {
// XMR (95), BTC (34, 42), ETH (42), LTC (34), BCH (42), DASH (34) // XMR (95), ADA (59, 92, 105), BCH (42), BNB (42), BTC (34, 42), DASH (34), EOS (42),
const pattern = '^[0-9a-zA-Z]{95}\$|^[0-9a-zA-Z]{34}\$|^[0-9a-zA-Z]{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); final regExp = RegExp(pattern);
isValid = value == null ? false : regExp.hasMatch(value); isValid = regExp.hasMatch(value);
if (isValid && cryptoCurrency != null) { if (isValid && cryptoCurrency != null) {
switch (cryptoCurrency.toString()) { switch (cryptoCurrency) {
case 'XMR': case CryptoCurrency.xmr:
isValid = (value.length == 95); isValid = (value.length == 95);
break; 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); isValid = (value.length == 34)||(value.length == 42);
break; break;
case 'ETH': case CryptoCurrency.dash:
isValid = (value.length == 42);
break;
case 'LTC':
isValid = (value.length == 34); isValid = (value.length == 34);
break; break;
case 'BCH': case CryptoCurrency.eos:
isValid = (value.length == 42); isValid = (value.length == 42);
break; break;
case 'DASH': case CryptoCurrency.eth:
isValid = (value.length == 42);
break;
case CryptoCurrency.ltc:
isValid = (value.length == 34); 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;
} }
} }

View file

@ -116,30 +116,55 @@ abstract class WalleRestorationStoreBase with Store {
} }
void validateAddress(String value, {CryptoCurrency cryptoCurrency}) { void validateAddress(String value, {CryptoCurrency cryptoCurrency}) {
// XMR (95), BTC (34, 42), ETH (42), LTC (34), BCH (42), DASH (34) // XMR (95), ADA (59, 92, 105), BCH (42), BNB (42), BTC (34, 42), DASH (34), EOS (42),
const pattern = '^[0-9a-zA-Z]{95}\$|^[0-9a-zA-Z]{34}\$|^[0-9a-zA-Z]{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); final regExp = RegExp(pattern);
isValid = regExp.hasMatch(value); isValid = regExp.hasMatch(value);
if (isValid && cryptoCurrency != null) { if (isValid && cryptoCurrency != null) {
switch (cryptoCurrency.toString()) { switch (cryptoCurrency) {
case 'XMR': case CryptoCurrency.xmr:
isValid = (value.length == 95); isValid = (value.length == 95);
break; 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); isValid = (value.length == 34)||(value.length == 42);
break; break;
case 'ETH': case CryptoCurrency.dash:
isValid = (value.length == 42);
break;
case 'LTC':
isValid = (value.length == 34); isValid = (value.length == 34);
break; break;
case 'BCH': case CryptoCurrency.eos:
isValid = (value.length == 42); isValid = (value.length == 42);
break; break;
case 'DASH': case CryptoCurrency.eth:
isValid = (value.length == 42);
break;
case CryptoCurrency.ltc:
isValid = (value.length == 34); 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;
} }
} }