mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2024-12-24 12:39:37 +00:00
e5d99313eb
* CW-498 Call updateTransactions on account change * CW-498 Code Cleanup * CW-498 Add Wallet Address to trade to match transactions to trades * CW-498 Fix containsAddress to include only addresses of account * Handle nullability for fromWalletAddress --------- Co-authored-by: OmarHatem <omarh.ismail1@gmail.com>
41 lines
920 B
Dart
41 lines
920 B
Dart
import 'package:cw_core/address_info.dart';
|
|
import 'package:cw_core/wallet_info.dart';
|
|
|
|
abstract class WalletAddresses {
|
|
WalletAddresses(this.walletInfo)
|
|
: addressesMap = {},
|
|
addressInfos = {};
|
|
|
|
final WalletInfo walletInfo;
|
|
|
|
String get address;
|
|
|
|
set address(String address);
|
|
|
|
Map<String, String> addressesMap;
|
|
|
|
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);
|
|
}
|