Generic fixes (#1282)

* New versions

* Fix unspent coins issue

* Fix white screen issues for some users
This commit is contained in:
Omar Hatem 2024-01-30 19:57:47 +02:00 committed by GitHub
parent 952503f0d8
commit b92ccb5c0b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
11 changed files with 82 additions and 53 deletions

View file

@ -150,7 +150,7 @@ class CWBitcoin extends Bitcoin {
return bitcoinWallet.unspentCoins; return bitcoinWallet.unspentCoins;
} }
void updateUnspents(Object wallet) async { Future<void> updateUnspents(Object wallet) async {
final bitcoinWallet = wallet as ElectrumWallet; final bitcoinWallet = wallet as ElectrumWallet;
await bitcoinWallet.updateUnspent(); await bitcoinWallet.updateUnspent();
} }

View file

@ -186,7 +186,10 @@ Future<void> defaultSettingsMigration(
await rewriteSecureStoragePin(secureStorage: secureStorage); await rewriteSecureStoragePin(secureStorage: secureStorage);
break; break;
case 26: case 26:
await insecureStorageMigration(secureStorage: secureStorage, sharedPreferences: sharedPreferences); /// commented out as it was a probable cause for some users to have white screen issues
/// maybe due to multiple access on Secure Storage at once
/// or long await time on start of the app
// await insecureStorageMigration(secureStorage: secureStorage, sharedPreferences: sharedPreferences);
break; break;
default: default:
break; break;
@ -507,7 +510,7 @@ Future<void> changeLitecoinCurrentElectrumServerToDefault(
Future<void> changeBitcoinCashCurrentNodeToDefault( Future<void> changeBitcoinCashCurrentNodeToDefault(
{required SharedPreferences sharedPreferences, required Box<Node> nodes}) async { {required SharedPreferences sharedPreferences, required Box<Node> nodes}) async {
final server = getBitcoinCashDefaultElectrumServer(nodes: nodes); final server = getBitcoinCashDefaultElectrumServer(nodes: nodes);
final serverId = server?.key as int ?? 0; final serverId = server?.key as int? ?? 0;
await sharedPreferences.setInt(PreferencesKey.currentBitcoinCashNodeIdKey, serverId); await sharedPreferences.setInt(PreferencesKey.currentBitcoinCashNodeIdKey, serverId);
} }

View file

@ -331,7 +331,7 @@ class CWMonero extends Monero {
} }
@override @override
void updateUnspents(Object wallet) async { Future<void> updateUnspents(Object wallet) async {
final moneroWallet = wallet as MoneroWallet; final moneroWallet = wallet as MoneroWallet;
await moneroWallet.updateUnspent(); await moneroWallet.updateUnspent();
} }

View file

@ -283,15 +283,17 @@ class ExchangeTradeState extends State<ExchangeTradeForm> {
if (state is TransactionCommitted) { if (state is TransactionCommitted) {
WidgetsBinding.instance.addPostFrameCallback((_) { WidgetsBinding.instance.addPostFrameCallback((_) {
showPopUp<void>( if (context.mounted) {
context: context, showPopUp<void>(
builder: (BuildContext popupContext) { context: context,
return AlertWithOneAction( builder: (BuildContext popupContext) {
alertTitle: S.of(popupContext).sending, return AlertWithOneAction(
alertContent: S.of(popupContext).transaction_sent, alertTitle: S.of(popupContext).sending,
buttonText: S.of(popupContext).ok, alertContent: S.of(popupContext).transaction_sent,
buttonAction: () => Navigator.of(popupContext).pop()); buttonText: S.of(popupContext).ok,
}); buttonAction: () => Navigator.of(popupContext).pop());
});
}
}); });
} }
}); });

View file

@ -53,16 +53,16 @@ class RootState extends State<Root> with WidgetsBindingObserver {
@override @override
void initState() { void initState() {
WidgetsBinding.instance.addPostFrameCallback((_) async { WidgetsBinding.instance.addObserver(this);
bool value = await widget.authService.requireAuth();
setState(() { widget.authService.requireAuth().then((value) {
_requestAuth = value; WidgetsBinding.instance.addPostFrameCallback((_) {
setState(() => _requestAuth = value);
}); });
}); });
_isInactiveController = StreamController<bool>.broadcast(); _isInactiveController = StreamController<bool>.broadcast();
_isInactive = false; _isInactive = false;
_postFrameCallback = false; _postFrameCallback = false;
WidgetsBinding.instance.addObserver(this);
super.initState(); super.initState();
if (DeviceInfo.instance.isMobile) { if (DeviceInfo.instance.isMobile) {
initUniLinks(); initUniLinks();

View file

@ -922,7 +922,7 @@ abstract class SettingsStoreBase with Store {
final allowBiometricalAuthentication = await SecureKey.getBool( final allowBiometricalAuthentication = await SecureKey.getBool(
secureStorage: secureStorage, secureStorage: secureStorage,
sharedPreferences: sharedPreferences, sharedPreferences: sharedPreferences,
key: SecureKey.pinTimeOutDuration, key: SecureKey.allowBiometricalAuthenticationKey,
) ?? ) ??
false; false;
@ -1247,6 +1247,16 @@ abstract class SettingsStoreBase with Store {
) ?? ) ??
totpSecretKey; totpSecretKey;
final timeOutDuration = await SecureKey.getInt(
secureStorage: _secureStorage,
sharedPreferences: sharedPreferences,
key: SecureKey.pinTimeOutDuration,
);
pinTimeOutDuration = timeOutDuration != null
? PinCodeRequiredDuration.deserialize(raw: timeOutDuration)
: defaultPinCodeTimeOutDuration;
allowBiometricalAuthentication = await SecureKey.getBool( allowBiometricalAuthentication = await SecureKey.getBool(
secureStorage: _secureStorage, secureStorage: _secureStorage,
sharedPreferences: sharedPreferences, sharedPreferences: sharedPreferences,

View file

@ -16,30 +16,17 @@ abstract class UnspentCoinsListViewModelBase with Store {
UnspentCoinsListViewModelBase( UnspentCoinsListViewModelBase(
{required this.wallet, required Box<UnspentCoinsInfo> unspentCoinsInfo}) {required this.wallet, required Box<UnspentCoinsInfo> unspentCoinsInfo})
: _unspentCoinsInfo = unspentCoinsInfo { : _unspentCoinsInfo = unspentCoinsInfo {
_updateUnspentCoinsInfo();
_updateUnspents(); _updateUnspents();
} }
WalletBase wallet; WalletBase wallet;
final Box<UnspentCoinsInfo> _unspentCoinsInfo; final Box<UnspentCoinsInfo> _unspentCoinsInfo;
@computed final ObservableList<UnspentCoinsItem> _items = ObservableList();
ObservableList<UnspentCoinsItem> get items => ObservableList.of(_getUnspents().map((elem) {
final info =
getUnspentCoinInfo(elem.hash, elem.address, elem.value, elem.vout, elem.keyImage);
return UnspentCoinsItem( @computed
address: elem.address, ObservableList<UnspentCoinsItem> get items => _items;
amount: '${formatAmountToString(elem.value)} ${wallet.currency.title}',
hash: elem.hash,
isFrozen: info.isFrozen,
note: info.note,
isSending: info.isSending,
amountRaw: elem.value,
vout: elem.vout,
keyImage: elem.keyImage,
isChange: elem.isChange,
);
}));
Future<void> saveUnspentCoinInfo(UnspentCoinsItem item) async { Future<void> saveUnspentCoinInfo(UnspentCoinsItem item) async {
try { try {
@ -77,9 +64,14 @@ abstract class UnspentCoinsListViewModelBase with Store {
} }
Future<void> _updateUnspents() async { Future<void> _updateUnspents() async {
if (wallet.type == WalletType.monero) return monero!.updateUnspents(wallet); if (wallet.type == WalletType.monero) {
if ([WalletType.bitcoin, WalletType.litecoin, WalletType.bitcoinCash].contains(wallet.type)) await monero!.updateUnspents(wallet);
return bitcoin!.updateUnspents(wallet); }
if ([WalletType.bitcoin, WalletType.litecoin, WalletType.bitcoinCash].contains(wallet.type)) {
await bitcoin!.updateUnspents(wallet);
}
_updateUnspentCoinsInfo();
} }
List<Unspent> _getUnspents() { List<Unspent> _getUnspents() {
@ -88,4 +80,26 @@ abstract class UnspentCoinsListViewModelBase with Store {
return bitcoin!.getUnspents(wallet); return bitcoin!.getUnspents(wallet);
return List.empty(); return List.empty();
} }
@action
void _updateUnspentCoinsInfo() {
_items.clear();
_items.addAll(_getUnspents().map((elem) {
final info =
getUnspentCoinInfo(elem.hash, elem.address, elem.value, elem.vout, elem.keyImage);
return UnspentCoinsItem(
address: elem.address,
amount: '${formatAmountToString(elem.value)} ${wallet.currency.title}',
hash: elem.hash,
isFrozen: info.isFrozen,
note: info.note,
isSending: info.isSending,
amountRaw: elem.value,
vout: elem.vout,
keyImage: elem.keyImage,
isChange: elem.isChange,
);
}));
}
} }

View file

@ -15,15 +15,15 @@ TYPES=($MONERO_COM $CAKEWALLET $HAVEN)
APP_ANDROID_TYPE=$1 APP_ANDROID_TYPE=$1
MONERO_COM_NAME="Monero.com" MONERO_COM_NAME="Monero.com"
MONERO_COM_VERSION="1.10.1" MONERO_COM_VERSION="1.10.2"
MONERO_COM_BUILD_NUMBER=73 MONERO_COM_BUILD_NUMBER=74
MONERO_COM_BUNDLE_ID="com.monero.app" MONERO_COM_BUNDLE_ID="com.monero.app"
MONERO_COM_PACKAGE="com.monero.app" MONERO_COM_PACKAGE="com.monero.app"
MONERO_COM_SCHEME="monero.com" MONERO_COM_SCHEME="monero.com"
CAKEWALLET_NAME="Cake Wallet" CAKEWALLET_NAME="Cake Wallet"
CAKEWALLET_VERSION="4.13.1" CAKEWALLET_VERSION="4.13.2"
CAKEWALLET_BUILD_NUMBER=190 CAKEWALLET_BUILD_NUMBER=191
CAKEWALLET_BUNDLE_ID="com.cakewallet.cake_wallet" CAKEWALLET_BUNDLE_ID="com.cakewallet.cake_wallet"
CAKEWALLET_PACKAGE="com.cakewallet.cake_wallet" CAKEWALLET_PACKAGE="com.cakewallet.cake_wallet"
CAKEWALLET_SCHEME="cakewallet" CAKEWALLET_SCHEME="cakewallet"

View file

@ -13,13 +13,13 @@ TYPES=($MONERO_COM $CAKEWALLET $HAVEN)
APP_IOS_TYPE=$1 APP_IOS_TYPE=$1
MONERO_COM_NAME="Monero.com" MONERO_COM_NAME="Monero.com"
MONERO_COM_VERSION="1.10.1" MONERO_COM_VERSION="1.10.2"
MONERO_COM_BUILD_NUMBER=71 MONERO_COM_BUILD_NUMBER=72
MONERO_COM_BUNDLE_ID="com.cakewallet.monero" MONERO_COM_BUNDLE_ID="com.cakewallet.monero"
CAKEWALLET_NAME="Cake Wallet" CAKEWALLET_NAME="Cake Wallet"
CAKEWALLET_VERSION="4.13.1" CAKEWALLET_VERSION="4.13.2"
CAKEWALLET_BUILD_NUMBER=209 CAKEWALLET_BUILD_NUMBER=210
CAKEWALLET_BUNDLE_ID="com.fotolockr.cakewallet" CAKEWALLET_BUNDLE_ID="com.fotolockr.cakewallet"
HAVEN_NAME="Haven" HAVEN_NAME="Haven"

View file

@ -16,13 +16,13 @@ if [ -n "$1" ]; then
fi fi
MONERO_COM_NAME="Monero.com" MONERO_COM_NAME="Monero.com"
MONERO_COM_VERSION="1.0.1" MONERO_COM_VERSION="1.0.2"
MONERO_COM_BUILD_NUMBER=3 MONERO_COM_BUILD_NUMBER=4
MONERO_COM_BUNDLE_ID="com.cakewallet.monero" MONERO_COM_BUNDLE_ID="com.cakewallet.monero"
CAKEWALLET_NAME="Cake Wallet" CAKEWALLET_NAME="Cake Wallet"
CAKEWALLET_VERSION="1.6.1" CAKEWALLET_VERSION="1.6.2"
CAKEWALLET_BUILD_NUMBER=51 CAKEWALLET_BUILD_NUMBER=52
CAKEWALLET_BUNDLE_ID="com.fotolockr.cakewallet" CAKEWALLET_BUNDLE_ID="com.fotolockr.cakewallet"
if ! [[ " ${TYPES[*]} " =~ " ${APP_MACOS_TYPE} " ]]; then if ! [[ " ${TYPES[*]} " =~ " ${APP_MACOS_TYPE} " ]]; then

View file

@ -127,7 +127,7 @@ abstract class Bitcoin {
String bitcoinTransactionPriorityWithLabel(TransactionPriority priority, int rate); String bitcoinTransactionPriorityWithLabel(TransactionPriority priority, int rate);
List<Unspent> getUnspents(Object wallet); List<Unspent> getUnspents(Object wallet);
void updateUnspents(Object wallet); Future<void> updateUnspents(Object wallet);
WalletService createBitcoinWalletService(Box<WalletInfo> walletInfoSource, Box<UnspentCoinsInfo> unspentCoinSource); WalletService createBitcoinWalletService(Box<WalletInfo> walletInfoSource, Box<UnspentCoinsInfo> unspentCoinSource);
WalletService createLitecoinWalletService(Box<WalletInfo> walletInfoSource, Box<UnspentCoinsInfo> unspentCoinSource); WalletService createLitecoinWalletService(Box<WalletInfo> walletInfoSource, Box<UnspentCoinsInfo> unspentCoinSource);
TransactionPriority getBitcoinTransactionPriorityMedium(); TransactionPriority getBitcoinTransactionPriorityMedium();
@ -270,7 +270,7 @@ abstract class Monero {
List<String> getMoneroWordList(String language); List<String> getMoneroWordList(String language);
List<Unspent> getUnspents(Object wallet); List<Unspent> getUnspents(Object wallet);
void updateUnspents(Object wallet); Future<void> updateUnspents(Object wallet);
WalletCredentials createMoneroRestoreWalletFromKeysCredentials({ WalletCredentials createMoneroRestoreWalletFromKeysCredentials({
required String name, required String name,