2023-08-29 16:11:51 +00:00
|
|
|
import 'package:cw_core/address_info.dart';
|
2021-12-24 12:52:08 +00:00
|
|
|
import 'package:cw_core/wallet_info.dart';
|
|
|
|
|
|
|
|
abstract class WalletAddresses {
|
2022-10-12 17:09:57 +00:00
|
|
|
WalletAddresses(this.walletInfo)
|
2023-08-29 16:11:51 +00:00
|
|
|
: addressesMap = {},
|
|
|
|
addressInfos = {};
|
2021-12-24 12:52:08 +00:00
|
|
|
|
|
|
|
final WalletInfo walletInfo;
|
|
|
|
|
|
|
|
String get address;
|
|
|
|
|
|
|
|
set address(String address);
|
|
|
|
|
|
|
|
Map<String, String> addressesMap;
|
|
|
|
|
2023-08-29 16:11:51 +00:00
|
|
|
Map<int, List<AddressInfo>> addressInfos;
|
|
|
|
|
|
|
|
Set<String> usedAddresses = {};
|
|
|
|
|
2021-12-24 12:52:08 +00:00
|
|
|
Future<void> init();
|
|
|
|
|
|
|
|
Future<void> updateAddressesInBox();
|
|
|
|
|
|
|
|
Future<void> saveAddressesInBox() async {
|
|
|
|
try {
|
|
|
|
walletInfo.address = address;
|
|
|
|
walletInfo.addresses = addressesMap;
|
2023-08-29 16:11:51 +00:00
|
|
|
walletInfo.addressInfos = addressInfos;
|
|
|
|
walletInfo.usedAddresses = usedAddresses.toList();
|
2021-12-24 12:52:08 +00:00
|
|
|
|
|
|
|
if (walletInfo.isInBox) {
|
|
|
|
await walletInfo.save();
|
|
|
|
}
|
|
|
|
} catch (e) {
|
|
|
|
print(e.toString());
|
|
|
|
}
|
|
|
|
}
|
2023-11-02 15:52:47 +00:00
|
|
|
|
|
|
|
bool containsAddress(String address) => addressesMap.containsKey(address);
|
|
|
|
}
|