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

Cwa 153 changenow cryptocurrencies
wownero
M 5 years ago
commit 8c15dded7f

@ -10,33 +10,65 @@ class CryptoCurrency extends EnumerableItem<int> with Serializable<int> {
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<int> with Serializable<int> {
static CryptoCurrency fromString(String raw) {
switch (raw.toLowerCase()) {
case 'xmr':
return xmr;
return CryptoCurrency.xmr;
case 'ada':
return CryptoCurrency.ada;
case 'bch':
return CryptoCurrency.bch;
case 'bnb':
return CryptoCurrency.bnb;
case 'btc':
return btc;
return CryptoCurrency.btc;
case 'dash':
return CryptoCurrency.dash;
case 'eos':
return CryptoCurrency.eos;
case 'eth':
return eth;
return CryptoCurrency.eth;
case 'ltc':
return ltc;
case 'bch':
return bch;
case 'dash':
return dash;
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;
}

@ -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;
}

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

@ -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':
case CryptoCurrency.dash:
isValid = (value.length == 34);
break;
case CryptoCurrency.eos:
isValid = (value.length == 42);
break;
case 'LTC':
case CryptoCurrency.eth:
isValid = (value.length == 42);
break;
case CryptoCurrency.ltc:
isValid = (value.length == 34);
break;
case 'BCH':
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 'DASH':
case CryptoCurrency.xlm:
isValid = (value.length == 56);
break;
case CryptoCurrency.xrp:
isValid = (value.length == 34);
break;
}
}

@ -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':
case CryptoCurrency.dash:
isValid = (value.length == 34);
break;
case CryptoCurrency.eos:
isValid = (value.length == 42);
break;
case 'LTC':
case CryptoCurrency.eth:
isValid = (value.length == 42);
break;
case CryptoCurrency.ltc:
isValid = (value.length == 34);
break;
case 'BCH':
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 'DASH':
case CryptoCurrency.xlm:
isValid = (value.length == 56);
break;
case CryptoCurrency.xrp:
isValid = (value.length == 34);
break;
}
}

@ -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':
case CryptoCurrency.dash:
isValid = (value.length == 34);
break;
case CryptoCurrency.eos:
isValid = (value.length == 42);
break;
case 'LTC':
case CryptoCurrency.eth:
isValid = (value.length == 42);
break;
case CryptoCurrency.ltc:
isValid = (value.length == 34);
break;
case 'BCH':
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 'DASH':
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, 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':
case CryptoCurrency.dash:
isValid = (value.length == 34);
break;
case CryptoCurrency.eos:
isValid = (value.length == 42);
break;
case 'LTC':
case CryptoCurrency.eth:
isValid = (value.length == 42);
break;
case CryptoCurrency.ltc:
isValid = (value.length == 34);
break;
case 'BCH':
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 'DASH':
case CryptoCurrency.xlm:
isValid = (value.length == 56);
break;
case CryptoCurrency.xrp:
isValid = (value.length == 34);
break;
}
}

Loading…
Cancel
Save