cake_wallet/cw_core/lib/wallet_addresses.dart
Omar Hatem 1769db1641
Generic Fixes (#1373)
* Fix exchanges not showing

* Fix button text on Monero receive screen

* Temp fix for ERC20 and SPL tokens not having raw value

* Manually Add Trocador new providers temporarily until API integration

* properly handle nullability of n2 node [skip ci]

---------

Co-authored-by: tuxsudo <tuxsudo@tux.pizza>
2024-04-12 16:01:21 +02:00

46 lines
1.1 KiB
Dart

import 'package:cw_core/address_info.dart';
import 'package:cw_core/wallet_info.dart';
abstract class WalletAddresses {
WalletAddresses(this.walletInfo)
: addressesMap = {},
allAddressesMap = {},
addressInfos = {};
final WalletInfo walletInfo;
String get address;
String? get primaryAddress => null;
set address(String address);
Map<String, String> addressesMap;
Map<String, String> allAddressesMap;
Map<int, List<AddressInfo>> addressInfos;
Set<String> usedAddresses = {};
Future<void> init();
Future<void> updateAddressesInBox();
Future<void> saveAddressesInBox() async {
try {
walletInfo.address = address;
walletInfo.addresses = addressesMap;
walletInfo.addressInfos = addressInfos;
walletInfo.usedAddresses = usedAddresses.toList();
if (walletInfo.isInBox) {
await walletInfo.save();
}
} catch (e) {
print(e.toString());
}
}
bool containsAddress(String address) =>
addressesMap.containsKey(address) || allAddressesMap.containsKey(address);
}