cake_wallet/cw_zano/lib/zano_wallet_addresses.dart

40 lines
920 B
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 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
Future<void> init() async {
address = walletInfo.address;
await updateAddressesInBox();
2023-12-16 15:00:22 +00:00
}
Future<void> updateAddress(String address) async {
this.address = address;
2023-10-02 14:17:35 +00:00
await updateAddressesInBox();
}
@override
Future<void> updateAddressesInBox() async {
try {
addressesMap.clear();
2023-11-17 17:40:23 +00:00
addressesMap[address] = '';
await saveAddressesInBox();
2023-10-02 14:17:35 +00:00
} catch (e) {
print(e.toString());
}
}
}