mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2025-06-28 20:39:51 +00:00
fix(cw_monero): wrong function in account rename call (#2183)
This commit is contained in:
parent
3f25d69244
commit
ea9b87d480
3 changed files with 15 additions and 13 deletions
|
@ -1,4 +1,7 @@
|
||||||
|
import 'dart:async';
|
||||||
|
|
||||||
import 'package:cw_monero/api/wallet.dart';
|
import 'package:cw_monero/api/wallet.dart';
|
||||||
|
import 'package:cw_monero/monero_account_list.dart';
|
||||||
import 'package:monero/monero.dart' as monero;
|
import 'package:monero/monero.dart' as monero;
|
||||||
|
|
||||||
monero.wallet? wptr = null;
|
monero.wallet? wptr = null;
|
||||||
|
@ -15,7 +18,6 @@ monero.WalletListener? getWlptr() {
|
||||||
return _wlptr!;
|
return _wlptr!;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
monero.SubaddressAccount? subaddressAccount;
|
monero.SubaddressAccount? subaddressAccount;
|
||||||
|
|
||||||
bool isUpdating = false;
|
bool isUpdating = false;
|
||||||
|
@ -51,8 +53,9 @@ void addAccountSync({required String label}) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void setLabelForAccountSync({required int accountIndex, required String label}) {
|
void setLabelForAccountSync({required int accountIndex, required String label}) {
|
||||||
// TODO(mrcyjanek): this may be wrong function?
|
monero.SubaddressAccount_setLabel(subaddressAccount!, accountIndex: accountIndex, label: label);
|
||||||
monero.Wallet_setSubaddressLabel(wptr!, accountIndex: accountIndex, addressIndex: 0, label: label);
|
MoneroAccountListBase.cachedAccounts[wptr!.address] = [];
|
||||||
|
refreshAccounts();
|
||||||
}
|
}
|
||||||
|
|
||||||
void _addAccount(String label) => addAccountSync(label: label);
|
void _addAccount(String label) => addAccountSync(label: label);
|
||||||
|
@ -66,10 +69,10 @@ void _setLabelForAccount(Map<String, dynamic> args) {
|
||||||
|
|
||||||
Future<void> addAccount({required String label}) async {
|
Future<void> addAccount({required String label}) async {
|
||||||
_addAccount(label);
|
_addAccount(label);
|
||||||
await store();
|
unawaited(store());
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> setLabelForAccount({required int accountIndex, required String label}) async {
|
Future<void> setLabelForAccount({required int accountIndex, required String label}) async {
|
||||||
_setLabelForAccount({'accountIndex': accountIndex, 'label': label});
|
_setLabelForAccount({'accountIndex': accountIndex, 'label': label});
|
||||||
await store();
|
unawaited(store());
|
||||||
}
|
}
|
|
@ -45,18 +45,18 @@ abstract class MoneroAccountListBase with Store {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Map<int, List<Account>> _cachedAccounts = {};
|
static Map<int, List<Account>> cachedAccounts = {};
|
||||||
|
|
||||||
List<Account> getAll() {
|
List<Account> getAll() {
|
||||||
final allAccounts = account_list.getAllAccount();
|
final allAccounts = account_list.getAllAccount();
|
||||||
final currentCount = allAccounts.length;
|
final currentCount = allAccounts.length;
|
||||||
_cachedAccounts[account_list.wptr!.address] ??= [];
|
cachedAccounts[account_list.wptr!.address] ??= [];
|
||||||
|
|
||||||
if (_cachedAccounts[account_list.wptr!.address]!.length == currentCount) {
|
if (cachedAccounts[account_list.wptr!.address]!.length == currentCount) {
|
||||||
return _cachedAccounts[account_list.wptr!.address]!;
|
return cachedAccounts[account_list.wptr!.address]!;
|
||||||
}
|
}
|
||||||
|
|
||||||
_cachedAccounts[account_list.wptr!.address] = allAccounts.map((accountRow) {
|
cachedAccounts[account_list.wptr!.address] = allAccounts.map((accountRow) {
|
||||||
final balance = monero.SubaddressAccountRow_getUnlockedBalance(accountRow);
|
final balance = monero.SubaddressAccountRow_getUnlockedBalance(accountRow);
|
||||||
|
|
||||||
return Account(
|
return Account(
|
||||||
|
@ -66,7 +66,7 @@ abstract class MoneroAccountListBase with Store {
|
||||||
);
|
);
|
||||||
}).toList();
|
}).toList();
|
||||||
|
|
||||||
return _cachedAccounts[account_list.wptr!.address]!;
|
return cachedAccounts[account_list.wptr!.address]!;
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> addAccount({required String label}) async {
|
Future<void> addAccount({required String label}) async {
|
||||||
|
|
|
@ -48,8 +48,7 @@ void addAccountSync({required String label}) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void setLabelForAccountSync({required int accountIndex, required String label}) {
|
void setLabelForAccountSync({required int accountIndex, required String label}) {
|
||||||
// TODO(mrcyjanek): this may be wrong function?
|
wownero.SubaddressAccount_setLabel(subaddressAccount!, accountIndex: accountIndex, label: label);
|
||||||
wownero.Wallet_setSubaddressLabel(wptr!, accountIndex: accountIndex, addressIndex: 0, label: label);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void _addAccount(String label) => addAccountSync(label: label);
|
void _addAccount(String label) => addAccountSync(label: label);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue