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
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2022-08-26 08:11:35 +00:00
|
|
|
import 'package:flutter/material.dart';
|
2024-05-27 23:56:22 +00:00
|
|
|
|
2024-05-23 00:37:06 +00:00
|
|
|
import '../db/hive/db.dart';
|
|
|
|
import '../models/trade_wallet_lookup.dart';
|
2022-08-26 08:11:35 +00:00
|
|
|
|
|
|
|
class TradeSentFromStackService extends ChangeNotifier {
|
|
|
|
List<TradeWalletLookup> get all =>
|
|
|
|
DB.instance.values<TradeWalletLookup>(boxName: DB.boxNameTradeLookup);
|
|
|
|
|
|
|
|
String? getTradeIdForTxid(String txid) {
|
|
|
|
final matches = all.where((e) => e.txid == txid);
|
|
|
|
|
|
|
|
if (matches.length == 1) {
|
|
|
|
return matches.first.tradeId;
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
String? getTxidForTradeId(String tradeId) {
|
|
|
|
final matches = all.where((e) => e.tradeId == tradeId);
|
|
|
|
|
|
|
|
if (matches.length == 1) {
|
|
|
|
return matches.first.txid;
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
List<String>? getWalletIdsForTradeId(String tradeId) {
|
|
|
|
final matches = all.where((e) => e.tradeId == tradeId);
|
|
|
|
|
|
|
|
if (matches.length == 1) {
|
|
|
|
return matches.first.walletIds;
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
List<String>? getWalletIdForTxid(String txid) {
|
|
|
|
final matches = all.where((e) => e.txid == txid);
|
|
|
|
|
|
|
|
if (matches.length == 1) {
|
|
|
|
return matches.first.walletIds;
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
Future<void> save({
|
|
|
|
required TradeWalletLookup tradeWalletLookup,
|
|
|
|
}) async {
|
|
|
|
await DB.instance.put(
|
2024-05-27 23:56:22 +00:00
|
|
|
boxName: DB.boxNameTradeLookup,
|
|
|
|
key: tradeWalletLookup.uuid,
|
|
|
|
value: tradeWalletLookup,
|
|
|
|
);
|
2022-08-26 08:11:35 +00:00
|
|
|
notifyListeners();
|
|
|
|
}
|
|
|
|
|
|
|
|
Future<void> delete({
|
|
|
|
required TradeWalletLookup tradeWalletLookup,
|
|
|
|
}) async {
|
|
|
|
await DB.instance.delete<TradeWalletLookup>(
|
2024-05-27 23:56:22 +00:00
|
|
|
key: tradeWalletLookup.uuid,
|
|
|
|
boxName: DB.boxNameTradeLookup,
|
|
|
|
);
|
2022-08-26 08:11:35 +00:00
|
|
|
}
|
|
|
|
}
|