Generic fixes (#1282)
* New versions * Fix unspent coins issue * Fix white screen issues for some users
Omar Hatem committed
Jan 30, 2024 at 19:57 UTC
b92ccb5c0b28d6ea260aca5751738e8a034598f0
11 files changed
+82
-53
lib/bitcoin/cw_bitcoin.dart
+1
-1
@@ -150,7 +150,7 @@ class CWBitcoin extends Bitcoin {
150
return bitcoinWallet.unspentCoins;
151
}
152
153
- void updateUnspents(Object wallet) async {
153
+ Future<void> updateUnspents(Object wallet) async {
154
final bitcoinWallet = wallet as ElectrumWallet;
155
await bitcoinWallet.updateUnspent();
156
}
lib/entities/default_settings_migration.dart
+5
-2
@@ -186,7 +186,10 @@ Future<void> defaultSettingsMigration(
186
await rewriteSecureStoragePin(secureStorage: secureStorage);
187
break;
188
case 26:
189
- await insecureStorageMigration(secureStorage: secureStorage, sharedPreferences: sharedPreferences);
189
+ /// commented out as it was a probable cause for some users to have white screen issues
190
+ /// maybe due to multiple access on Secure Storage at once
191
+ /// or long await time on start of the app
192
+ // await insecureStorageMigration(secureStorage: secureStorage, sharedPreferences: sharedPreferences);
193
break;
194
default:
195
break;
@@ -507,7 +510,7 @@ Future<void> changeLitecoinCurrentElectrumServerToDefault(
510
Future<void> changeBitcoinCashCurrentNodeToDefault(
511
{required SharedPreferences sharedPreferences, required Box<Node> nodes}) async {
512
final server = getBitcoinCashDefaultElectrumServer(nodes: nodes);
510
- final serverId = server?.key as int ?? 0;
513
+ final serverId = server?.key as int? ?? 0;
514
515
await sharedPreferences.setInt(PreferencesKey.currentBitcoinCashNodeIdKey, serverId);
516
}
lib/monero/cw_monero.dart
+1
-1
@@ -331,7 +331,7 @@ class CWMonero extends Monero {
331
}
332
333
@override
334
- void updateUnspents(Object wallet) async {
334
+ Future<void> updateUnspents(Object wallet) async {
335
final moneroWallet = wallet as MoneroWallet;
336
await moneroWallet.updateUnspent();
337
}
lib/src/screens/exchange_trade/exchange_trade_page.dart
+11
-9
@@ -283,15 +283,17 @@ class ExchangeTradeState extends State<ExchangeTradeForm> {
283
284
if (state is TransactionCommitted) {
285
WidgetsBinding.instance.addPostFrameCallback((_) {
286
- showPopUp<void>(
287
- context: context,
288
- builder: (BuildContext popupContext) {
289
- return AlertWithOneAction(
290
- alertTitle: S.of(popupContext).sending,
291
- alertContent: S.of(popupContext).transaction_sent,
292
- buttonText: S.of(popupContext).ok,
293
- buttonAction: () => Navigator.of(popupContext).pop());
294
- });
286
+ if (context.mounted) {
287
+ showPopUp<void>(
288
+ context: context,
289
+ builder: (BuildContext popupContext) {
290
+ return AlertWithOneAction(
291
+ alertTitle: S.of(popupContext).sending,
292
+ alertContent: S.of(popupContext).transaction_sent,
293
+ buttonText: S.of(popupContext).ok,
294
+ buttonAction: () => Navigator.of(popupContext).pop());
295
+ });
296
+ }
297
});
298
}
299
});
lib/src/screens/root/root.dart
+5
-5
@@ -53,16 +53,16 @@ class RootState extends State<Root> with WidgetsBindingObserver {
53
54
@override
55
void initState() {
56
- WidgetsBinding.instance.addPostFrameCallback((_) async {
57
- bool value = await widget.authService.requireAuth();
58
- setState(() {
59
- _requestAuth = value;
56
+ WidgetsBinding.instance.addObserver(this);
57
+
58
+ widget.authService.requireAuth().then((value) {
59
+ WidgetsBinding.instance.addPostFrameCallback((_) {
60
+ setState(() => _requestAuth = value);
61
});
62
});
63
_isInactiveController = StreamController<bool>.broadcast();
64
_isInactive = false;
65
_postFrameCallback = false;
65
- WidgetsBinding.instance.addObserver(this);
66
super.initState();
67
if (DeviceInfo.instance.isMobile) {
68
initUniLinks();
lib/store/settings_store.dart
+11
-1
@@ -922,7 +922,7 @@ abstract class SettingsStoreBase with Store {
922
final allowBiometricalAuthentication = await SecureKey.getBool(
923
secureStorage: secureStorage,
924
sharedPreferences: sharedPreferences,
925
- key: SecureKey.pinTimeOutDuration,
925
+ key: SecureKey.allowBiometricalAuthenticationKey,
926
) ??
927
false;
928
@@ -1247,6 +1247,16 @@ abstract class SettingsStoreBase with Store {
1247
) ??
1248
totpSecretKey;
1249
1250
+ final timeOutDuration = await SecureKey.getInt(
1251
+ secureStorage: _secureStorage,
1252
+ sharedPreferences: sharedPreferences,
1253
+ key: SecureKey.pinTimeOutDuration,
1254
+ );
1255
+
1256
+ pinTimeOutDuration = timeOutDuration != null
1257
+ ? PinCodeRequiredDuration.deserialize(raw: timeOutDuration)
1258
+ : defaultPinCodeTimeOutDuration;
1259
+
1260
allowBiometricalAuthentication = await SecureKey.getBool(
1261
secureStorage: _secureStorage,
1262
sharedPreferences: sharedPreferences,
lib/view_model/unspent_coins/unspent_coins_list_view_model.dart
+34
-20
@@ -16,30 +16,17 @@ abstract class UnspentCoinsListViewModelBase with Store {
16
UnspentCoinsListViewModelBase(
17
{required this.wallet, required Box<UnspentCoinsInfo> unspentCoinsInfo})
18
: _unspentCoinsInfo = unspentCoinsInfo {
19
+ _updateUnspentCoinsInfo();
20
_updateUnspents();
21
}
22
23
WalletBase wallet;
24
final Box<UnspentCoinsInfo> _unspentCoinsInfo;
25
26
+ final ObservableList<UnspentCoinsItem> _items = ObservableList();
27
+
28
@computed
26
- ObservableList<UnspentCoinsItem> get items => ObservableList.of(_getUnspents().map((elem) {
27
- final info =
28
- getUnspentCoinInfo(elem.hash, elem.address, elem.value, elem.vout, elem.keyImage);
29
-
30
- return UnspentCoinsItem(
31
- address: elem.address,
32
- amount: '${formatAmountToString(elem.value)} ${wallet.currency.title}',
33
- hash: elem.hash,
34
- isFrozen: info.isFrozen,
35
- note: info.note,
36
- isSending: info.isSending,
37
- amountRaw: elem.value,
38
- vout: elem.vout,
39
- keyImage: elem.keyImage,
40
- isChange: elem.isChange,
41
- );
42
- }));
29
+ ObservableList<UnspentCoinsItem> get items => _items;
30
31
Future<void> saveUnspentCoinInfo(UnspentCoinsItem item) async {
32
try {
@@ -77,9 +64,14 @@ abstract class UnspentCoinsListViewModelBase with Store {
64
}
65
66
Future<void> _updateUnspents() async {
80
- if (wallet.type == WalletType.monero) return monero!.updateUnspents(wallet);
81
- if ([WalletType.bitcoin, WalletType.litecoin, WalletType.bitcoinCash].contains(wallet.type))
82
- return bitcoin!.updateUnspents(wallet);
67
+ if (wallet.type == WalletType.monero) {
68
+ await monero!.updateUnspents(wallet);
69
+ }
70
+ if ([WalletType.bitcoin, WalletType.litecoin, WalletType.bitcoinCash].contains(wallet.type)) {
71
+ await bitcoin!.updateUnspents(wallet);
72
+ }
73
+
74
+ _updateUnspentCoinsInfo();
75
}
76
77
List<Unspent> _getUnspents() {
@@ -88,4 +80,26 @@ abstract class UnspentCoinsListViewModelBase with Store {
80
return bitcoin!.getUnspents(wallet);
81
return List.empty();
82
}
83
+
84
+ @action
85
+ void _updateUnspentCoinsInfo() {
86
+ _items.clear();
87
+ _items.addAll(_getUnspents().map((elem) {
88
+ final info =
89
+ getUnspentCoinInfo(elem.hash, elem.address, elem.value, elem.vout, elem.keyImage);
90
+
91
+ return UnspentCoinsItem(
92
+ address: elem.address,
93
+ amount: '${formatAmountToString(elem.value)} ${wallet.currency.title}',
94
+ hash: elem.hash,
95
+ isFrozen: info.isFrozen,
96
+ note: info.note,
97
+ isSending: info.isSending,
98
+ amountRaw: elem.value,
99
+ vout: elem.vout,
100
+ keyImage: elem.keyImage,
101
+ isChange: elem.isChange,
102
+ );
103
+ }));
104
+ }
105
}
scripts/android/app_env.sh
+4
-4
@@ -15,15 +15,15 @@ TYPES=($MONERO_COM $CAKEWALLET $HAVEN)
15
APP_ANDROID_TYPE=$1
16
17
MONERO_COM_NAME="Monero.com"
18
-MONERO_COM_VERSION="1.10.1"
19
-MONERO_COM_BUILD_NUMBER=73
18
+MONERO_COM_VERSION="1.10.2"
19
+MONERO_COM_BUILD_NUMBER=74
20
MONERO_COM_BUNDLE_ID="com.monero.app"
21
MONERO_COM_PACKAGE="com.monero.app"
22
MONERO_COM_SCHEME="monero.com"
23
24
CAKEWALLET_NAME="Cake Wallet"
25
-CAKEWALLET_VERSION="4.13.1"
26
-CAKEWALLET_BUILD_NUMBER=190
25
+CAKEWALLET_VERSION="4.13.2"
26
+CAKEWALLET_BUILD_NUMBER=191
27
CAKEWALLET_BUNDLE_ID="com.cakewallet.cake_wallet"
28
CAKEWALLET_PACKAGE="com.cakewallet.cake_wallet"
29
CAKEWALLET_SCHEME="cakewallet"
scripts/ios/app_env.sh
+4
-4
@@ -13,13 +13,13 @@ TYPES=($MONERO_COM $CAKEWALLET $HAVEN)
13
APP_IOS_TYPE=$1
14
15
MONERO_COM_NAME="Monero.com"
16
-MONERO_COM_VERSION="1.10.1"
17
-MONERO_COM_BUILD_NUMBER=71
16
+MONERO_COM_VERSION="1.10.2"
17
+MONERO_COM_BUILD_NUMBER=72
18
MONERO_COM_BUNDLE_ID="com.cakewallet.monero"
19
20
CAKEWALLET_NAME="Cake Wallet"
21
-CAKEWALLET_VERSION="4.13.1"
22
-CAKEWALLET_BUILD_NUMBER=209
21
+CAKEWALLET_VERSION="4.13.2"
22
+CAKEWALLET_BUILD_NUMBER=210
23
CAKEWALLET_BUNDLE_ID="com.fotolockr.cakewallet"
24
25
HAVEN_NAME="Haven"
scripts/macos/app_env.sh
+4
-4
@@ -16,13 +16,13 @@ if [ -n "$1" ]; then
16
fi
17
18
MONERO_COM_NAME="Monero.com"
19
-MONERO_COM_VERSION="1.0.1"
20
-MONERO_COM_BUILD_NUMBER=3
19
+MONERO_COM_VERSION="1.0.2"
20
+MONERO_COM_BUILD_NUMBER=4
21
MONERO_COM_BUNDLE_ID="com.cakewallet.monero"
22
23
CAKEWALLET_NAME="Cake Wallet"
24
-CAKEWALLET_VERSION="1.6.1"
25
-CAKEWALLET_BUILD_NUMBER=51
24
+CAKEWALLET_VERSION="1.6.2"
25
+CAKEWALLET_BUILD_NUMBER=52
26
CAKEWALLET_BUNDLE_ID="com.fotolockr.cakewallet"
27
28
if ! [[ " ${TYPES[*]} " =~ " ${APP_MACOS_TYPE} " ]]; then
tool/configure.dart
+2
-2
@@ -127,7 +127,7 @@ abstract class Bitcoin {
127
String bitcoinTransactionPriorityWithLabel(TransactionPriority priority, int rate);
128
129
List<Unspent> getUnspents(Object wallet);
130
- void updateUnspents(Object wallet);
130
+ Future<void> updateUnspents(Object wallet);
131
WalletService createBitcoinWalletService(Box<WalletInfo> walletInfoSource, Box<UnspentCoinsInfo> unspentCoinSource);
132
WalletService createLitecoinWalletService(Box<WalletInfo> walletInfoSource, Box<UnspentCoinsInfo> unspentCoinSource);
133
TransactionPriority getBitcoinTransactionPriorityMedium();
@@ -270,7 +270,7 @@ abstract class Monero {
270
List<String> getMoneroWordList(String language);
271
272
List<Unspent> getUnspents(Object wallet);
273
- void updateUnspents(Object wallet);
273
+ Future<void> updateUnspents(Object wallet);
274
275
WalletCredentials createMoneroRestoreWalletFromKeysCredentials({
276
required String name,