mirror of
https://github.com/Such-Software/hash-wallet.git
synced 2026-10-23 06:38:35 +02:00
General changes. CAKE-1.
This commit is contained in:
@@ -1,111 +1,111 @@
|
||||
import 'package:mobx/mobx.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:cake_wallet/generated/i18n.dart';
|
||||
import 'package:cake_wallet/src/domain/common/contact.dart';
|
||||
import 'package:cake_wallet/src/domain/common/crypto_currency.dart';
|
||||
import 'package:hive/hive.dart';
|
||||
|
||||
part 'address_book_store.g.dart';
|
||||
|
||||
class AddressBookStore = AddressBookStoreBase with _$AddressBookStore;
|
||||
|
||||
abstract class AddressBookStoreBase with Store {
|
||||
AddressBookStoreBase({@required this.contacts}) {
|
||||
updateContactList();
|
||||
isDisabledStatus = true;
|
||||
}
|
||||
|
||||
@observable
|
||||
List<Contact> contactList;
|
||||
|
||||
@observable
|
||||
bool isDisabledStatus;
|
||||
|
||||
@observable
|
||||
bool isValid;
|
||||
|
||||
@observable
|
||||
String errorMessage;
|
||||
|
||||
Box<Contact> contacts;
|
||||
|
||||
@action
|
||||
Future add({Contact contact}) async => contacts.add(contact);
|
||||
|
||||
@action
|
||||
Future updateContactList() async => contactList = contacts.values.toList();
|
||||
|
||||
@action
|
||||
Future update({Contact contact}) async => contact.save();
|
||||
|
||||
@action
|
||||
Future delete({Contact contact}) async => await contact.delete();
|
||||
|
||||
@action
|
||||
void setDisabledStatus(bool isDisabled) {
|
||||
isDisabledStatus = isDisabled;
|
||||
}
|
||||
|
||||
void validateContactName(String value) {
|
||||
const pattern = '''^[^`,'"]{1,32}\$''';
|
||||
final regExp = RegExp(pattern);
|
||||
isValid = regExp.hasMatch(value);
|
||||
errorMessage = isValid ? null : S.current.error_text_contact_name;
|
||||
}
|
||||
|
||||
void validateAddress(String value, {CryptoCurrency cryptoCurrency}) {
|
||||
// XMR (95, 106), 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}\$|^[0-9a-zA-Z]{106}\$';
|
||||
final regExp = RegExp(pattern);
|
||||
isValid = regExp.hasMatch(value);
|
||||
if (isValid && cryptoCurrency != null) {
|
||||
switch (cryptoCurrency) {
|
||||
case CryptoCurrency.xmr:
|
||||
isValid = (value.length == 95)||(value.length == 106);
|
||||
break;
|
||||
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 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)||(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;
|
||||
}
|
||||
}
|
||||
|
||||
errorMessage = isValid ? null : S.current.error_text_address;
|
||||
}
|
||||
}
|
||||
//import 'package:mobx/mobx.dart';
|
||||
//import 'package:flutter/foundation.dart';
|
||||
//import 'package:cake_wallet/generated/i18n.dart';
|
||||
//import 'package:cake_wallet/src/domain/common/contact.dart';
|
||||
//import 'package:cake_wallet/src/domain/common/crypto_currency.dart';
|
||||
//import 'package:hive/hive.dart';
|
||||
//
|
||||
//part 'address_book_store.g.dart';
|
||||
//
|
||||
//class AddressBookStore = AddressBookStoreBase with _$AddressBookStore;
|
||||
//
|
||||
//abstract class AddressBookStoreBase with Store {
|
||||
// AddressBookStoreBase({@required this.contacts}) {
|
||||
// updateContactList();
|
||||
// isDisabledStatus = true;
|
||||
// }
|
||||
//
|
||||
// @observable
|
||||
// List<Contact> contactList;
|
||||
//
|
||||
// @observable
|
||||
// bool isDisabledStatus;
|
||||
//
|
||||
// @observable
|
||||
// bool isValid;
|
||||
//
|
||||
// @observable
|
||||
// String errorMessage;
|
||||
//
|
||||
// Box<Contact> contacts;
|
||||
//
|
||||
// @action
|
||||
// Future add({Contact contact}) async => contacts.add(contact);
|
||||
//
|
||||
// @action
|
||||
// Future updateContactList() async => contactList = contacts.values.toList();
|
||||
//
|
||||
// @action
|
||||
// Future update({Contact contact}) async => contact.save();
|
||||
//
|
||||
// @action
|
||||
// Future delete({Contact contact}) async => await contact.delete();
|
||||
//
|
||||
// @action
|
||||
// void setDisabledStatus(bool isDisabled) {
|
||||
// isDisabledStatus = isDisabled;
|
||||
// }
|
||||
//
|
||||
// void validateContactName(String value) {
|
||||
// const pattern = '''^[^`,'"]{1,32}\$''';
|
||||
// final regExp = RegExp(pattern);
|
||||
// isValid = regExp.hasMatch(value);
|
||||
// errorMessage = isValid ? null : S.current.error_text_contact_name;
|
||||
// }
|
||||
//
|
||||
// void validateAddress(String value, {CryptoCurrency cryptoCurrency}) {
|
||||
// // XMR (95, 106), 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}\$|^[0-9a-zA-Z]{106}\$';
|
||||
// final regExp = RegExp(pattern);
|
||||
// isValid = regExp.hasMatch(value);
|
||||
// if (isValid && cryptoCurrency != null) {
|
||||
// switch (cryptoCurrency) {
|
||||
// case CryptoCurrency.xmr:
|
||||
// isValid = (value.length == 95)||(value.length == 106);
|
||||
// break;
|
||||
// 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 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)||(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;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// errorMessage = isValid ? null : S.current.error_text_address;
|
||||
// }
|
||||
//}
|
||||
|
||||
@@ -33,10 +33,8 @@ abstract class ExchangeStoreBase with Store {
|
||||
provider = initialProvider;
|
||||
depositCurrency = initialDepositCurrency;
|
||||
receiveCurrency = initialReceiveCurrency;
|
||||
/*isDepositAddressEnabled = !(depositCurrency == walletStore.type);
|
||||
isReceiveAddressEnabled = !(receiveCurrency == walletStore.type);*/
|
||||
isDepositAddressEnabled = true;
|
||||
isReceiveAddressEnabled = true;
|
||||
isDepositAddressEnabled = !(depositCurrency == walletStore.type);
|
||||
isReceiveAddressEnabled = !(receiveCurrency == walletStore.type);
|
||||
depositAmount = '';
|
||||
receiveAmount = '';
|
||||
depositAddress = '';
|
||||
@@ -109,16 +107,16 @@ abstract class ExchangeStoreBase with Store {
|
||||
void changeDepositCurrency({CryptoCurrency currency}) {
|
||||
depositCurrency = currency;
|
||||
_onPairChange();
|
||||
/*isDepositAddressEnabled = !(depositCurrency == walletStore.type);
|
||||
isReceiveAddressEnabled = !(receiveCurrency == walletStore.type);*/
|
||||
isDepositAddressEnabled = !(depositCurrency == walletStore.type);
|
||||
isReceiveAddressEnabled = !(receiveCurrency == walletStore.type);
|
||||
}
|
||||
|
||||
@action
|
||||
void changeReceiveCurrency({CryptoCurrency currency}) {
|
||||
receiveCurrency = currency;
|
||||
_onPairChange();
|
||||
/*isDepositAddressEnabled = !(depositCurrency == walletStore.type);
|
||||
isReceiveAddressEnabled = !(receiveCurrency == walletStore.type);*/
|
||||
isDepositAddressEnabled = !(depositCurrency == walletStore.type);
|
||||
isReceiveAddressEnabled = !(receiveCurrency == walletStore.type);
|
||||
}
|
||||
|
||||
@action
|
||||
@@ -242,8 +240,8 @@ abstract class ExchangeStoreBase with Store {
|
||||
receiveCurrency = CryptoCurrency.btc;
|
||||
depositAddress = depositCurrency == walletStore.type ? walletStore.address : '';
|
||||
receiveAddress = receiveCurrency == walletStore.type ? walletStore.address : '';
|
||||
/*isDepositAddressEnabled = !(depositCurrency == walletStore.type);
|
||||
isReceiveAddressEnabled = !(receiveCurrency == walletStore.type);*/
|
||||
isDepositAddressEnabled = !(depositCurrency == walletStore.type);
|
||||
isReceiveAddressEnabled = !(receiveCurrency == walletStore.type);
|
||||
_onPairChange();
|
||||
}
|
||||
|
||||
|
||||
@@ -72,8 +72,7 @@ abstract class NodeListBase with Store {
|
||||
|
||||
Future<bool> isNodeOnline(Node node) async {
|
||||
try {
|
||||
return await node.requestNode(node.uri,
|
||||
login: node.login, password: node.password);
|
||||
return await node.requestNode();
|
||||
} catch (e) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user