cake_wallet/cw_zano/lib/zano_wallet_addresses.dart

85 lines
2.2 KiB
Dart
Raw Normal View History

2023-11-17 17:40:23 +00:00
import 'package:cw_core/wallet_addresses.dart';
2023-10-02 14:17:35 +00:00
import 'package:cw_core/wallet_info.dart';
import 'package:mobx/mobx.dart';
part 'zano_wallet_addresses.g.dart';
class ZanoWalletAddresses = ZanoWalletAddressesBase with _$ZanoWalletAddresses;
2023-11-17 17:40:23 +00:00
/**abstract class ZanoWalletAddressesBase extends WalletAddressesWithAccount<Account> with Store {*/
abstract class ZanoWalletAddressesBase extends WalletAddresses with Store {
2023-10-02 14:17:35 +00:00
ZanoWalletAddressesBase(WalletInfo walletInfo)
2023-11-17 17:40:23 +00:00
: address = '',
2023-10-02 14:17:35 +00:00
super(walletInfo);
@override
@observable
String address;
// @override
2023-11-17 17:40:23 +00:00
/**@observable
Account? account;*/
2023-10-02 14:17:35 +00:00
2023-11-17 17:40:23 +00:00
/**@observable
Subaddress? subaddress;*/
2023-10-02 14:17:35 +00:00
2023-11-17 17:40:23 +00:00
/**ZanoSubaddressList subaddressList;*/
2023-10-02 14:17:35 +00:00
2023-11-17 17:40:23 +00:00
/**ZanoAccountList accountList;*/
2023-10-02 14:17:35 +00:00
@override
Future<void> init() async {
2023-11-17 17:40:23 +00:00
/*accountList.update();
account = accountList.accounts.first;*/
/**updateSubaddressList(accountIndex: account?.id ?? 0);*/
address = walletInfo.address;
2023-10-02 14:17:35 +00:00
await updateAddressesInBox();
}
@override
Future<void> updateAddressesInBox() async {
try {
2023-11-17 17:40:23 +00:00
/**final _subaddressList = ZanoSubaddressList();*/
2023-10-02 14:17:35 +00:00
addressesMap.clear();
2023-11-17 17:40:23 +00:00
addressesMap[address] = '';
await saveAddressesInBox();
2023-10-02 14:17:35 +00:00
2023-11-17 17:40:23 +00:00
/*accountList.accounts.forEach((account) {
2023-10-02 14:17:35 +00:00
_subaddressList.update(accountIndex: account.id);
_subaddressList.subaddresses.forEach((subaddress) {
addressesMap[subaddress.address] = subaddress.label;
});
});
2023-11-17 17:40:23 +00:00
await saveAddressesInBox();*/
2023-10-02 14:17:35 +00:00
} catch (e) {
print(e.toString());
}
}
2023-11-17 17:40:23 +00:00
// bool validate() {
// accountList.update();
// final accountListLength = accountList.accounts.length ?? 0;
2023-10-02 14:17:35 +00:00
2023-11-17 17:40:23 +00:00
// if (accountListLength <= 0) {
// return false;
// }
2023-10-02 14:17:35 +00:00
2023-11-17 17:40:23 +00:00
// /**subaddressList.update(accountIndex: accountList.accounts.first.id);
// final subaddressListLength = subaddressList.subaddresses.length ?? 0;
2023-10-02 14:17:35 +00:00
2023-11-17 17:40:23 +00:00
// if (subaddressListLength <= 0) {
// return false;
// }*/
2023-10-02 14:17:35 +00:00
2023-11-17 17:40:23 +00:00
// return true;
// }
2023-10-02 14:17:35 +00:00
2023-11-17 17:40:23 +00:00
/*void updateSubaddressList({required int accountIndex}) {
2023-10-02 14:17:35 +00:00
subaddressList.update(accountIndex: accountIndex);
subaddress = subaddressList.subaddresses.first;
address = subaddress!.address;
2023-11-17 17:40:23 +00:00
}*/
2023-10-02 14:17:35 +00:00
}