2023-05-26 21:21:16 +00:00
|
|
|
/*
|
|
|
|
* This file is part of Stack Wallet.
|
|
|
|
*
|
|
|
|
* Copyright (c) 2023 Cypher Stack
|
|
|
|
* All Rights Reserved.
|
|
|
|
* The code is distributed under GPLv3 license, see LICENSE file for details.
|
|
|
|
* Generated by Cypher Stack on 2023-05-26
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2024-05-23 00:37:06 +00:00
|
|
|
import '../db/hive/db.dart';
|
2022-08-26 08:11:35 +00:00
|
|
|
|
|
|
|
class TransactionNotificationTracker {
|
|
|
|
final String walletId;
|
|
|
|
|
|
|
|
TransactionNotificationTracker({required this.walletId});
|
|
|
|
|
|
|
|
List<String> get pendings {
|
|
|
|
final notifiedPendingTransactions = DB.instance.get<dynamic>(
|
2024-05-27 23:56:22 +00:00
|
|
|
boxName: walletId,
|
|
|
|
key: "notifiedPendingTransactions",
|
|
|
|
) as Map? ??
|
2022-08-26 08:11:35 +00:00
|
|
|
{};
|
|
|
|
return List<String>.from(notifiedPendingTransactions.keys);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool wasNotifiedPending(String txid) {
|
|
|
|
final notifiedPendingTransactions = DB.instance.get<dynamic>(
|
2024-05-27 23:56:22 +00:00
|
|
|
boxName: walletId,
|
|
|
|
key: "notifiedPendingTransactions",
|
|
|
|
) as Map? ??
|
2022-08-26 08:11:35 +00:00
|
|
|
{};
|
|
|
|
return notifiedPendingTransactions[txid] as bool? ?? false;
|
|
|
|
}
|
|
|
|
|
|
|
|
Future<void> addNotifiedPending(String txid) async {
|
|
|
|
final notifiedPendingTransactions = DB.instance.get<dynamic>(
|
2024-05-27 23:56:22 +00:00
|
|
|
boxName: walletId,
|
|
|
|
key: "notifiedPendingTransactions",
|
|
|
|
) as Map? ??
|
2022-08-26 08:11:35 +00:00
|
|
|
{};
|
|
|
|
notifiedPendingTransactions[txid] = true;
|
|
|
|
await DB.instance.put<dynamic>(
|
2024-05-27 23:56:22 +00:00
|
|
|
boxName: walletId,
|
|
|
|
key: "notifiedPendingTransactions",
|
|
|
|
value: notifiedPendingTransactions,
|
|
|
|
);
|
2022-08-26 08:11:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
List<String> get confirmeds {
|
|
|
|
final notifiedConfirmedTransactions = DB.instance.get<dynamic>(
|
2024-05-27 23:56:22 +00:00
|
|
|
boxName: walletId,
|
|
|
|
key: "notifiedConfirmedTransactions",
|
|
|
|
) as Map? ??
|
2022-08-26 08:11:35 +00:00
|
|
|
{};
|
|
|
|
return List<String>.from(notifiedConfirmedTransactions.keys);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool wasNotifiedConfirmed(String txid) {
|
|
|
|
final notifiedConfirmedTransactions = DB.instance.get<dynamic>(
|
2024-05-27 23:56:22 +00:00
|
|
|
boxName: walletId,
|
|
|
|
key: "notifiedConfirmedTransactions",
|
|
|
|
) as Map? ??
|
2022-08-26 08:11:35 +00:00
|
|
|
{};
|
|
|
|
return notifiedConfirmedTransactions[txid] as bool? ?? false;
|
|
|
|
}
|
|
|
|
|
|
|
|
Future<void> addNotifiedConfirmed(String txid) async {
|
|
|
|
final notifiedConfirmedTransactions = DB.instance.get<dynamic>(
|
2024-05-27 23:56:22 +00:00
|
|
|
boxName: walletId,
|
|
|
|
key: "notifiedConfirmedTransactions",
|
|
|
|
) as Map? ??
|
2022-08-26 08:11:35 +00:00
|
|
|
{};
|
|
|
|
notifiedConfirmedTransactions[txid] = true;
|
|
|
|
await DB.instance.put<dynamic>(
|
2024-05-27 23:56:22 +00:00
|
|
|
boxName: walletId,
|
|
|
|
key: "notifiedConfirmedTransactions",
|
|
|
|
value: notifiedConfirmedTransactions,
|
|
|
|
);
|
2022-08-26 08:11:35 +00:00
|
|
|
}
|
2023-01-27 18:49:25 +00:00
|
|
|
|
|
|
|
Future<void> deleteTransaction(String txid) async {
|
|
|
|
final notifiedPendingTransactions = DB.instance.get<dynamic>(
|
2024-05-27 23:56:22 +00:00
|
|
|
boxName: walletId,
|
|
|
|
key: "notifiedPendingTransactions",
|
|
|
|
) as Map? ??
|
2023-01-27 18:49:25 +00:00
|
|
|
{};
|
|
|
|
final notifiedConfirmedTransactions = DB.instance.get<dynamic>(
|
2024-05-27 23:56:22 +00:00
|
|
|
boxName: walletId,
|
|
|
|
key: "notifiedConfirmedTransactions",
|
|
|
|
) as Map? ??
|
2023-01-27 18:49:25 +00:00
|
|
|
{};
|
|
|
|
|
|
|
|
notifiedPendingTransactions.remove(txid);
|
|
|
|
notifiedConfirmedTransactions.remove(txid);
|
|
|
|
|
|
|
|
await DB.instance.put<dynamic>(
|
2024-05-27 23:56:22 +00:00
|
|
|
boxName: walletId,
|
|
|
|
key: "notifiedConfirmedTransactions",
|
|
|
|
value: notifiedConfirmedTransactions,
|
|
|
|
);
|
2023-01-27 18:49:25 +00:00
|
|
|
await DB.instance.put<dynamic>(
|
2024-05-27 23:56:22 +00:00
|
|
|
boxName: walletId,
|
|
|
|
key: "notifiedPendingTransactions",
|
|
|
|
value: notifiedPendingTransactions,
|
|
|
|
);
|
2023-01-27 18:49:25 +00:00
|
|
|
}
|
2022-08-26 08:11:35 +00:00
|
|
|
}
|