/* * 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 * */ import '../db/hive/db.dart'; class TransactionNotificationTracker { final String walletId; TransactionNotificationTracker({required this.walletId}); List get pendings { final notifiedPendingTransactions = DB.instance.get( boxName: walletId, key: "notifiedPendingTransactions", ) as Map? ?? {}; return List.from(notifiedPendingTransactions.keys); } bool wasNotifiedPending(String txid) { final notifiedPendingTransactions = DB.instance.get( boxName: walletId, key: "notifiedPendingTransactions", ) as Map? ?? {}; return notifiedPendingTransactions[txid] as bool? ?? false; } Future addNotifiedPending(String txid) async { final notifiedPendingTransactions = DB.instance.get( boxName: walletId, key: "notifiedPendingTransactions", ) as Map? ?? {}; notifiedPendingTransactions[txid] = true; await DB.instance.put( boxName: walletId, key: "notifiedPendingTransactions", value: notifiedPendingTransactions, ); } List get confirmeds { final notifiedConfirmedTransactions = DB.instance.get( boxName: walletId, key: "notifiedConfirmedTransactions", ) as Map? ?? {}; return List.from(notifiedConfirmedTransactions.keys); } bool wasNotifiedConfirmed(String txid) { final notifiedConfirmedTransactions = DB.instance.get( boxName: walletId, key: "notifiedConfirmedTransactions", ) as Map? ?? {}; return notifiedConfirmedTransactions[txid] as bool? ?? false; } Future addNotifiedConfirmed(String txid) async { final notifiedConfirmedTransactions = DB.instance.get( boxName: walletId, key: "notifiedConfirmedTransactions", ) as Map? ?? {}; notifiedConfirmedTransactions[txid] = true; await DB.instance.put( boxName: walletId, key: "notifiedConfirmedTransactions", value: notifiedConfirmedTransactions, ); } Future deleteTransaction(String txid) async { final notifiedPendingTransactions = DB.instance.get( boxName: walletId, key: "notifiedPendingTransactions", ) as Map? ?? {}; final notifiedConfirmedTransactions = DB.instance.get( boxName: walletId, key: "notifiedConfirmedTransactions", ) as Map? ?? {}; notifiedPendingTransactions.remove(txid); notifiedConfirmedTransactions.remove(txid); await DB.instance.put( boxName: walletId, key: "notifiedConfirmedTransactions", value: notifiedConfirmedTransactions, ); await DB.instance.put( boxName: walletId, key: "notifiedPendingTransactions", value: notifiedPendingTransactions, ); } }