fix(cw_monero): wrong function in account rename call (#2183)
cyan committed
Apr 10, 2025 at 23:17 UTC
ea9b87d480e2256683318fd010e07ffd3ce8a8a6
3 files changed
+15
-13
cw_monero/lib/api/account_list.dart
+8
-5
@@ -1,4 +1,7 @@
1
+import 'dart:async';
2
+
3
import 'package:cw_monero/api/wallet.dart';
4
+import 'package:cw_monero/monero_account_list.dart';
5
import 'package:monero/monero.dart' as monero;
6
7
monero.wallet? wptr = null;
@@ -15,7 +18,6 @@ monero.WalletListener? getWlptr() {
18
return _wlptr!;
19
}
20
18
-
21
monero.SubaddressAccount? subaddressAccount;
22
23
bool isUpdating = false;
@@ -51,8 +53,9 @@ void addAccountSync({required String label}) {
53
}
54
55
void setLabelForAccountSync({required int accountIndex, required String label}) {
54
- // TODO(mrcyjanek): this may be wrong function?
55
- monero.Wallet_setSubaddressLabel(wptr!, accountIndex: accountIndex, addressIndex: 0, label: label);
56
+ monero.SubaddressAccount_setLabel(subaddressAccount!, accountIndex: accountIndex, label: label);
57
+ MoneroAccountListBase.cachedAccounts[wptr!.address] = [];
58
+ refreshAccounts();
59
}
60
61
void _addAccount(String label) => addAccountSync(label: label);
@@ -66,10 +69,10 @@ void _setLabelForAccount(Map<String, dynamic> args) {
69
70
Future<void> addAccount({required String label}) async {
71
_addAccount(label);
69
- await store();
72
+ unawaited(store());
73
}
74
75
Future<void> setLabelForAccount({required int accountIndex, required String label}) async {
76
_setLabelForAccount({'accountIndex': accountIndex, 'label': label});
74
- await store();
77
+ unawaited(store());
78
}
\ No newline at end of file
cw_monero/lib/monero_account_list.dart
+6
-6
@@ -45,18 +45,18 @@ abstract class MoneroAccountListBase with Store {
45
}
46
}
47
48
- Map<int, List<Account>> _cachedAccounts = {};
48
+ static Map<int, List<Account>> cachedAccounts = {};
49
50
List<Account> getAll() {
51
final allAccounts = account_list.getAllAccount();
52
final currentCount = allAccounts.length;
53
- _cachedAccounts[account_list.wptr!.address] ??= [];
53
+ cachedAccounts[account_list.wptr!.address] ??= [];
54
55
- if (_cachedAccounts[account_list.wptr!.address]!.length == currentCount) {
56
- return _cachedAccounts[account_list.wptr!.address]!;
55
+ if (cachedAccounts[account_list.wptr!.address]!.length == currentCount) {
56
+ return cachedAccounts[account_list.wptr!.address]!;
57
}
58
59
- _cachedAccounts[account_list.wptr!.address] = allAccounts.map((accountRow) {
59
+ cachedAccounts[account_list.wptr!.address] = allAccounts.map((accountRow) {
60
final balance = monero.SubaddressAccountRow_getUnlockedBalance(accountRow);
61
62
return Account(
@@ -66,7 +66,7 @@ abstract class MoneroAccountListBase with Store {
66
);
67
}).toList();
68
69
- return _cachedAccounts[account_list.wptr!.address]!;
69
+ return cachedAccounts[account_list.wptr!.address]!;
70
}
71
72
Future<void> addAccount({required String label}) async {
cw_wownero/lib/api/account_list.dart
+1
-2
@@ -48,8 +48,7 @@ void addAccountSync({required String label}) {
48
}
49
50
void setLabelForAccountSync({required int accountIndex, required String label}) {
51
- // TODO(mrcyjanek): this may be wrong function?
52
- wownero.Wallet_setSubaddressLabel(wptr!, accountIndex: accountIndex, addressIndex: 0, label: label);
51
+ wownero.SubaddressAccount_setLabel(subaddressAccount!, accountIndex: accountIndex, label: label);
52
}
53
54
void _addAccount(String label) => addAccountSync(label: label);