Merge pull request #600 from cypherstack/less_hive

Less hive
This commit is contained in:
Diego Salazar 2023-07-03 18:53:48 -06:00 committed by GitHub
commit b4602f18c1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
46 changed files with 768 additions and 821 deletions

View file

@ -13,7 +13,6 @@ import 'dart:isolate';
import 'package:cw_core/wallet_info.dart' as xmr;
import 'package:hive/hive.dart';
import 'package:mutex/mutex.dart';
import 'package:stackwallet/models/exchange/change_now/exchange_transaction.dart';
import 'package:stackwallet/models/exchange/response_objects/trade.dart';
import 'package:stackwallet/models/node_model.dart';
import 'package:stackwallet/models/notification_model.dart';
@ -23,8 +22,13 @@ import 'package:stackwallet/utilities/enums/coin_enum.dart';
import 'package:stackwallet/utilities/logger.dart';
class DB {
// legacy (required for migrations)
@Deprecated("Left over for migration from old versions of Stack Wallet")
static const String boxNameAddressBook = "addressBook";
static const String boxNameDebugInfo = "debugInfoBox";
static const String boxNameTrades = "exchangeTransactionsBox";
// in use
// TODO: migrate
static const String boxNameNodeModels = "nodeModels";
static const String boxNamePrimaryNodes = "primaryNodes";
static const String boxNameAllWalletsData = "wallets";
@ -32,33 +36,31 @@ class DB {
static const String boxNameWatchedTransactions =
"watchedTxNotificationModels";
static const String boxNameWatchedTrades = "watchedTradesNotificationModels";
static const String boxNameTrades = "exchangeTransactionsBox";
static const String boxNameTradesV2 = "exchangeTradesBox";
static const String boxNameTradeNotes = "tradeNotesBox";
static const String boxNameTradeLookup = "tradeToTxidLookUpBox";
static const String boxNameFavoriteWallets = "favoriteWallets";
static const String boxNamePrefs = "prefs";
static const String boxNameWalletsToDeleteOnStart = "walletsToDeleteOnStart";
static const String boxNamePriceCache = "priceAPIPrice24hCache";
static const String boxNameDBInfo = "dbInfo";
// static const String boxNameTheme = "theme";
static const String boxNameDesktopData = "desktopData";
static const String boxNameBuys = "buysBox";
String boxNameTxCache({required Coin coin}) => "${coin.name}_txCache";
String boxNameSetCache({required Coin coin}) =>
// in use (keep for now)
static const String boxNameDBInfo = "dbInfo";
static const String boxNamePrefs = "prefs";
String _boxNameTxCache({required Coin coin}) => "${coin.name}_txCache";
// firo only
String _boxNameSetCache({required Coin coin}) =>
"${coin.name}_anonymitySetCache";
String boxNameUsedSerialsCache({required Coin coin}) =>
String _boxNameUsedSerialsCache({required Coin coin}) =>
"${coin.name}_usedSerialsCache";
Box<String>? _boxDebugInfo;
Box<NodeModel>? _boxNodeModels;
Box<NodeModel>? _boxPrimaryNodes;
Box<dynamic>? _boxAllWalletsData;
Box<NotificationModel>? _boxNotifications;
Box<NotificationModel>? _boxWatchedTransactions;
Box<NotificationModel>? _boxWatchedTrades;
Box<ExchangeTransaction>? _boxTrades;
Box<Trade>? _boxTradesV2;
Box<String>? _boxTradeNotes;
Box<String>? _boxFavoriteWallets;
@ -66,7 +68,7 @@ class DB {
Box<dynamic>? _boxPrefs;
Box<TradeWalletLookup>? _boxTradeLookup;
Box<dynamic>? _boxDBInfo;
Box<String>? _boxDesktopData;
// Box<String>? _boxDesktopData;
final Map<String, Box<dynamic>> _walletBoxes = {};
@ -109,8 +111,6 @@ class DB {
_boxPrefs = await Hive.openBox<dynamic>(boxNamePrefs);
}
_boxDebugInfo = await Hive.openBox<String>(boxNameDebugInfo);
if (Hive.isBoxOpen(boxNameNodeModels)) {
_boxNodeModels = Hive.box<NodeModel>(boxNameNodeModels);
} else {
@ -129,19 +129,12 @@ class DB {
_boxAllWalletsData = await Hive.openBox<dynamic>(boxNameAllWalletsData);
}
if (Hive.isBoxOpen(boxNameDesktopData)) {
_boxDesktopData = Hive.box<String>(boxNameDesktopData);
} else {
_boxDesktopData = await Hive.openBox<String>(boxNameDesktopData);
}
_boxNotifications =
await Hive.openBox<NotificationModel>(boxNameNotifications);
_boxWatchedTransactions =
await Hive.openBox<NotificationModel>(boxNameWatchedTransactions);
_boxWatchedTrades =
await Hive.openBox<NotificationModel>(boxNameWatchedTrades);
_boxTrades = await Hive.openBox<ExchangeTransaction>(boxNameTrades);
_boxTradesV2 = await Hive.openBox<Trade>(boxNameTradesV2);
_boxTradeNotes = await Hive.openBox<String>(boxNameTradeNotes);
_boxTradeLookup = await Hive.openBox<TradeWalletLookup>(boxNameTradeLookup);
@ -152,7 +145,6 @@ class DB {
await Future.wait([
Hive.openBox<dynamic>(boxNamePriceCache),
_loadWalletBoxes(),
_loadSharedCoinCacheBoxes(),
]);
}
@ -184,14 +176,39 @@ class DB {
}
}
Future<void> _loadSharedCoinCacheBoxes() async {
for (final coin in Coin.values) {
_txCacheBoxes[coin] =
await Hive.openBox<dynamic>(boxNameTxCache(coin: coin));
_setCacheBoxes[coin] =
await Hive.openBox<dynamic>(boxNameSetCache(coin: coin));
_usedSerialsCacheBoxes[coin] =
await Hive.openBox<dynamic>(boxNameUsedSerialsCache(coin: coin));
Future<Box<dynamic>> getTxCacheBox({required Coin coin}) async {
return _txCacheBoxes[coin] ??=
await Hive.openBox<dynamic>(_boxNameTxCache(coin: coin));
}
Future<void> closeTxCacheBox({required Coin coin}) async {
await _txCacheBoxes[coin]?.close();
}
Future<Box<dynamic>> getAnonymitySetCacheBox({required Coin coin}) async {
return _setCacheBoxes[coin] ??=
await Hive.openBox<dynamic>(_boxNameSetCache(coin: coin));
}
Future<void> closeAnonymitySetCacheBox({required Coin coin}) async {
await _setCacheBoxes[coin]?.close();
}
Future<Box<dynamic>> getUsedSerialsCacheBox({required Coin coin}) async {
return _usedSerialsCacheBoxes[coin] ??=
await Hive.openBox<dynamic>(_boxNameUsedSerialsCache(coin: coin));
}
Future<void> closeUsedSerialsCacheBox({required Coin coin}) async {
await _usedSerialsCacheBoxes[coin]?.close();
}
/// Clear all cached transactions for the specified coin
Future<void> clearSharedTransactionCache({required Coin coin}) async {
await deleteAll<dynamic>(boxName: _boxNameTxCache(coin: coin));
if (coin == Coin.firo) {
await deleteAll<dynamic>(boxName: _boxNameSetCache(coin: coin));
await deleteAll<dynamic>(boxName: _boxNameUsedSerialsCache(coin: coin));
}
}
@ -253,6 +270,36 @@ class DB {
Future<void> deleteBoxFromDisk({required String boxName}) async =>
await mutex.protect(() async => await Hive.deleteBoxFromDisk(boxName));
///////////////////////////////////////////////////////////////////////////
Future<bool> deleteEverything() async {
try {
await DB.instance.deleteBoxFromDisk(boxName: DB.boxNameAddressBook);
await DB.instance.deleteBoxFromDisk(boxName: "debugInfoBox");
await DB.instance.deleteBoxFromDisk(boxName: DB.boxNameNodeModels);
await DB.instance.deleteBoxFromDisk(boxName: DB.boxNamePrimaryNodes);
await DB.instance.deleteBoxFromDisk(boxName: DB.boxNameAllWalletsData);
await DB.instance.deleteBoxFromDisk(boxName: DB.boxNameNotifications);
await DB.instance
.deleteBoxFromDisk(boxName: DB.boxNameWatchedTransactions);
await DB.instance.deleteBoxFromDisk(boxName: DB.boxNameWatchedTrades);
await DB.instance.deleteBoxFromDisk(boxName: DB.boxNameTrades);
await DB.instance.deleteBoxFromDisk(boxName: DB.boxNameTradesV2);
await DB.instance.deleteBoxFromDisk(boxName: DB.boxNameTradeNotes);
await DB.instance.deleteBoxFromDisk(boxName: DB.boxNameTradeLookup);
await DB.instance.deleteBoxFromDisk(boxName: DB.boxNameFavoriteWallets);
await DB.instance.deleteBoxFromDisk(boxName: DB.boxNamePrefs);
await DB.instance
.deleteBoxFromDisk(boxName: DB.boxNameWalletsToDeleteOnStart);
await DB.instance.deleteBoxFromDisk(boxName: DB.boxNamePriceCache);
await DB.instance.deleteBoxFromDisk(boxName: DB.boxNameDBInfo);
await DB.instance.deleteBoxFromDisk(boxName: "theme");
return true;
} catch (e, s) {
Logging.instance.log("$e $s", level: LogLevel.Error);
return false;
}
}
}
abstract class DBKeys {

View file

@ -38,9 +38,8 @@ class CachedElectrumX {
required Coin coin,
}) async {
try {
final cachedSet = DB.instance.get<dynamic>(
boxName: DB.instance.boxNameSetCache(coin: coin),
key: groupId) as Map?;
final box = await DB.instance.getAnonymitySetCacheBox(coin: coin);
final cachedSet = box.get(groupId) as Map?;
Map<String, dynamic> set;
@ -71,7 +70,7 @@ class CachedElectrumX {
: newSet["blockHash"];
for (int i = (newSet["coins"] as List).length - 1; i >= 0; i--) {
dynamic newCoin = newSet["coins"][i];
List translatedCoin = [];
List<dynamic> translatedCoin = [];
translatedCoin.add(!isHexadecimal(newCoin[0] as String)
? base64ToHex(newCoin[0] as String)
: newCoin[0]);
@ -91,10 +90,7 @@ class CachedElectrumX {
set["coins"].insert(0, translatedCoin);
}
// save set to db
await DB.instance.put<dynamic>(
boxName: DB.instance.boxNameSetCache(coin: coin),
key: groupId,
value: set);
await box.put(groupId, set);
Logging.instance.log(
"Updated current anonymity set for ${coin.name} with group ID $groupId",
level: LogLevel.Info,
@ -130,8 +126,9 @@ class CachedElectrumX {
bool verbose = true,
}) async {
try {
final cachedTx = DB.instance.get<dynamic>(
boxName: DB.instance.boxNameTxCache(coin: coin), key: txHash) as Map?;
final box = await DB.instance.getTxCacheBox(coin: coin);
final cachedTx = box.get(txHash) as Map?;
if (cachedTx == null) {
final Map<String, dynamic> result = await electrumXClient
.getTransaction(txHash: txHash, verbose: verbose);
@ -141,10 +138,7 @@ class CachedElectrumX {
if (result["confirmations"] != null &&
result["confirmations"] as int > minCacheConfirms) {
await DB.instance.put<dynamic>(
boxName: DB.instance.boxNameTxCache(coin: coin),
key: txHash,
value: result);
await box.put(txHash, result);
}
Logging.instance.log("using fetched result", level: LogLevel.Info);
@ -166,9 +160,9 @@ class CachedElectrumX {
int startNumber = 0,
}) async {
try {
final _list = DB.instance.get<dynamic>(
boxName: DB.instance.boxNameUsedSerialsCache(coin: coin),
key: "serials") as List?;
final box = await DB.instance.getUsedSerialsCacheBox(coin: coin);
final _list = box.get("serials") as List?;
List<String> cachedSerials =
_list == null ? [] : List<String>.from(_list);
@ -188,10 +182,9 @@ class CachedElectrumX {
}
cachedSerials.addAll(newSerials);
await DB.instance.put<dynamic>(
boxName: DB.instance.boxNameUsedSerialsCache(coin: coin),
key: "serials",
value: cachedSerials,
await box.put(
"serials",
cachedSerials,
);
return cachedSerials;
@ -205,11 +198,6 @@ class CachedElectrumX {
/// Clear all cached transactions for the specified coin
Future<void> clearSharedTransactionCache({required Coin coin}) async {
await DB.instance
.deleteAll<dynamic>(boxName: DB.instance.boxNameTxCache(coin: coin));
await DB.instance
.deleteAll<dynamic>(boxName: DB.instance.boxNameSetCache(coin: coin));
await DB.instance.deleteAll<dynamic>(
boxName: DB.instance.boxNameUsedSerialsCache(coin: coin));
await DB.instance.closeAnonymitySetCacheBox(coin: coin);
}
}

View file

@ -167,6 +167,8 @@ void main() async {
await Hive.openBox<dynamic>(DB.boxNamePrefs);
await Prefs.instance.init();
await StackFileSystem.initThemesDir();
// Desktop migrate handled elsewhere (currently desktop_login_view.dart)
if (!Util.isDesktop) {
int dbVersion = DB.instance.get<dynamic>(
@ -312,7 +314,7 @@ class _MaterialAppWithThemeState extends ConsumerState<MaterialAppWithTheme>
}
ref.read(applicationThemesDirectoryPathProvider.notifier).state =
(await StackFileSystem.applicationThemesDirectory()).path;
StackFileSystem.themesDir!.path;
_notificationsService = ref.read(notificationsProvider);
_nodeService = ref.read(nodeServiceChangeNotifierProvider);
@ -407,7 +409,7 @@ class _MaterialAppWithThemeState extends ConsumerState<MaterialAppWithTheme>
WidgetsBinding.instance.addPostFrameCallback((_) async {
//Add themes path to provider
ref.read(applicationThemesDirectoryPathProvider.notifier).state =
(await StackFileSystem.applicationThemesDirectory()).path;
StackFileSystem.themesDir!.path;
ref.read(themeProvider.state).state = ref.read(pThemeService).getTheme(
themeId: themeId,

View file

@ -9,6 +9,7 @@
*/
import 'dart:convert';
import 'dart:io';
import 'package:flutter/material.dart';
import 'package:isar/isar.dart';
@ -17,6 +18,7 @@ import 'package:stackwallet/utilities/enums/coin_enum.dart';
import 'package:stackwallet/utilities/extensions/impl/box_shadow.dart';
import 'package:stackwallet/utilities/extensions/impl/gradient.dart';
import 'package:stackwallet/utilities/extensions/impl/string.dart';
import 'package:stackwallet/utilities/stack_file_system.dart';
part 'stack_theme.g.dart';
@ -1508,7 +1510,6 @@ class StackTheme {
factory StackTheme.fromJson({
required Map<String, dynamic> json,
required String applicationThemesDirectoryPath,
}) {
final version = json["version"] as int? ?? 1;
@ -1517,21 +1518,18 @@ class StackTheme {
..assetsV1 = version == 1
? ThemeAssets.fromJson(
json: Map<String, dynamic>.from(json["assets"] as Map),
applicationThemesDirectoryPath: applicationThemesDirectoryPath,
themeId: json["id"] as String,
)
: null
..assetsV2 = version == 2
? ThemeAssetsV2.fromJson(
json: Map<String, dynamic>.from(json["assets"] as Map),
applicationThemesDirectoryPath: applicationThemesDirectoryPath,
themeId: json["id"] as String,
)
: null
..assetsV3 = version >= 3
? ThemeAssetsV3.fromJson(
json: Map<String, dynamic>.from(json["assets"] as Map),
applicationThemesDirectoryPath: applicationThemesDirectoryPath,
themeId: json["id"] as String,
)
: null
@ -1954,117 +1952,81 @@ class ThemeAssets implements IThemeAssets {
factory ThemeAssets.fromJson({
required Map<String, dynamic> json,
required String applicationThemesDirectoryPath,
required String themeId,
}) {
return ThemeAssets()
..bellNew =
"$applicationThemesDirectoryPath/$themeId/assets/${json["bell_new"] as String}"
..buy =
"$applicationThemesDirectoryPath/$themeId/assets/${json["buy"] as String}"
..exchange =
"$applicationThemesDirectoryPath/$themeId/assets/${json["exchange"] as String}"
..bellNew = "$themeId/assets/${json["bell_new"] as String}"
..buy = "$themeId/assets/${json["buy"] as String}"
..exchange = "$themeId/assets/${json["exchange"] as String}"
..personaIncognito =
"$applicationThemesDirectoryPath/$themeId/assets/${json["persona_incognito"] as String}"
..personaEasy =
"$applicationThemesDirectoryPath/$themeId/assets/${json["persona_easy"] as String}"
..stack =
"$applicationThemesDirectoryPath/$themeId/assets/${json["stack"] as String}"
..stackIcon =
"$applicationThemesDirectoryPath/$themeId/assets/${json["stack_icon"] as String}"
..receive =
"$applicationThemesDirectoryPath/$themeId/assets/${json["receive"] as String}"
..receivePending =
"$applicationThemesDirectoryPath/$themeId/assets/${json["receive_pending"] as String}"
"$themeId/assets/${json["persona_incognito"] as String}"
..personaEasy = "$themeId/assets/${json["persona_easy"] as String}"
..stack = "$themeId/assets/${json["stack"] as String}"
..stackIcon = "$themeId/assets/${json["stack_icon"] as String}"
..receive = "$themeId/assets/${json["receive"] as String}"
..receivePending = "$themeId/assets/${json["receive_pending"] as String}"
..receiveCancelled =
"$applicationThemesDirectoryPath/$themeId/assets/${json["receive_cancelled"] as String}"
..send =
"$applicationThemesDirectoryPath/$themeId/assets/${json["send"] as String}"
..sendPending =
"$applicationThemesDirectoryPath/$themeId/assets/${json["send_pending"] as String}"
..sendCancelled =
"$applicationThemesDirectoryPath/$themeId/assets/${json["send_cancelled"] as String}"
..themeSelector =
"$applicationThemesDirectoryPath/$themeId/assets/${json["theme_selector"] as String}"
..themePreview =
"$applicationThemesDirectoryPath/$themeId/assets/${json["theme_preview"] as String}"
..txExchange =
"$applicationThemesDirectoryPath/$themeId/assets/${json["tx_exchange"] as String}"
"$themeId/assets/${json["receive_cancelled"] as String}"
..send = "$themeId/assets/${json["send"] as String}"
..sendPending = "$themeId/assets/${json["send_pending"] as String}"
..sendCancelled = "$themeId/assets/${json["send_cancelled"] as String}"
..themeSelector = "$themeId/assets/${json["theme_selector"] as String}"
..themePreview = "$themeId/assets/${json["theme_preview"] as String}"
..txExchange = "$themeId/assets/${json["tx_exchange"] as String}"
..txExchangePending =
"$applicationThemesDirectoryPath/$themeId/assets/${json["tx_exchange_pending"] as String}"
"$themeId/assets/${json["tx_exchange_pending"] as String}"
..txExchangeFailed =
"$applicationThemesDirectoryPath/$themeId/assets/${json["tx_exchange_failed"] as String}"
..bitcoin =
"$applicationThemesDirectoryPath/$themeId/assets/${json["bitcoin"] as String}"
..litecoin =
"$applicationThemesDirectoryPath/$themeId/assets/${json["litecoin"] as String}"
..bitcoincash =
"$applicationThemesDirectoryPath/$themeId/assets/${json["bitcoincash"] as String}"
..dogecoin =
"$applicationThemesDirectoryPath/$themeId/assets/${json["dogecoin"] as String}"
..epicCash =
"$applicationThemesDirectoryPath/$themeId/assets/${json["epicCash"] as String}"
..ethereum =
"$applicationThemesDirectoryPath/$themeId/assets/${json["ethereum"] as String}"
..firo =
"$applicationThemesDirectoryPath/$themeId/assets/${json["firo"] as String}"
..monero =
"$applicationThemesDirectoryPath/$themeId/assets/${json["monero"] as String}"
..wownero =
"$applicationThemesDirectoryPath/$themeId/assets/${json["wownero"] as String}"
..namecoin =
"$applicationThemesDirectoryPath/$themeId/assets/${json["namecoin"] as String}"
..particl =
"$applicationThemesDirectoryPath/$themeId/assets/${json["particl"] as String}"
..bitcoinImage =
"$applicationThemesDirectoryPath/$themeId/assets/${json["bitcoin_image"] as String}"
"$themeId/assets/${json["tx_exchange_failed"] as String}"
..bitcoin = "$themeId/assets/${json["bitcoin"] as String}"
..litecoin = "$themeId/assets/${json["litecoin"] as String}"
..bitcoincash = "$themeId/assets/${json["bitcoincash"] as String}"
..dogecoin = "$themeId/assets/${json["dogecoin"] as String}"
..epicCash = "$themeId/assets/${json["epicCash"] as String}"
..ethereum = "$themeId/assets/${json["ethereum"] as String}"
..firo = "$themeId/assets/${json["firo"] as String}"
..monero = "$themeId/assets/${json["monero"] as String}"
..wownero = "$themeId/assets/${json["wownero"] as String}"
..namecoin = "$themeId/assets/${json["namecoin"] as String}"
..particl = "$themeId/assets/${json["particl"] as String}"
..bitcoinImage = "$themeId/assets/${json["bitcoin_image"] as String}"
..bitcoincashImage =
"$applicationThemesDirectoryPath/$themeId/assets/${json["bitcoincash_image"] as String}"
..dogecoinImage =
"$applicationThemesDirectoryPath/$themeId/assets/${json["dogecoin_image"] as String}"
..epicCashImage =
"$applicationThemesDirectoryPath/$themeId/assets/${json["epicCash_image"] as String}"
..ethereumImage =
"$applicationThemesDirectoryPath/$themeId/assets/${json["ethereum_image"] as String}"
..firoImage =
"$applicationThemesDirectoryPath/$themeId/assets/${json["firo_image"] as String}"
..litecoinImage =
"$applicationThemesDirectoryPath/$themeId/assets/${json["litecoin_image"] as String}"
..moneroImage =
"$applicationThemesDirectoryPath/$themeId/assets/${json["monero_image"] as String}"
..wowneroImage =
"$applicationThemesDirectoryPath/$themeId/assets/${json["wownero_image"] as String}"
..namecoinImage =
"$applicationThemesDirectoryPath/$themeId/assets/${json["namecoin_image"] as String}"
..particlImage =
"$applicationThemesDirectoryPath/$themeId/assets/${json["particl_image"] as String}"
"$themeId/assets/${json["bitcoincash_image"] as String}"
..dogecoinImage = "$themeId/assets/${json["dogecoin_image"] as String}"
..epicCashImage = "$themeId/assets/${json["epicCash_image"] as String}"
..ethereumImage = "$themeId/assets/${json["ethereum_image"] as String}"
..firoImage = "$themeId/assets/${json["firo_image"] as String}"
..litecoinImage = "$themeId/assets/${json["litecoin_image"] as String}"
..moneroImage = "$themeId/assets/${json["monero_image"] as String}"
..wowneroImage = "$themeId/assets/${json["wownero_image"] as String}"
..namecoinImage = "$themeId/assets/${json["namecoin_image"] as String}"
..particlImage = "$themeId/assets/${json["particl_image"] as String}"
..bitcoinImageSecondary =
"$applicationThemesDirectoryPath/$themeId/assets/${json["bitcoin_image_secondary"] as String}"
"$themeId/assets/${json["bitcoin_image_secondary"] as String}"
..bitcoincashImageSecondary =
"$applicationThemesDirectoryPath/$themeId/assets/${json["bitcoincash_image_secondary"] as String}"
"$themeId/assets/${json["bitcoincash_image_secondary"] as String}"
..dogecoinImageSecondary =
"$applicationThemesDirectoryPath/$themeId/assets/${json["dogecoin_image_secondary"] as String}"
"$themeId/assets/${json["dogecoin_image_secondary"] as String}"
..epicCashImageSecondary =
"$applicationThemesDirectoryPath/$themeId/assets/${json["epicCash_image_secondary"] as String}"
"$themeId/assets/${json["epicCash_image_secondary"] as String}"
..ethereumImageSecondary =
"$applicationThemesDirectoryPath/$themeId/assets/${json["ethereum_image_secondary"] as String}"
"$themeId/assets/${json["ethereum_image_secondary"] as String}"
..firoImageSecondary =
"$applicationThemesDirectoryPath/$themeId/assets/${json["firo_image_secondary"] as String}"
"$themeId/assets/${json["firo_image_secondary"] as String}"
..litecoinImageSecondary =
"$applicationThemesDirectoryPath/$themeId/assets/${json["litecoin_image_secondary"] as String}"
"$themeId/assets/${json["litecoin_image_secondary"] as String}"
..moneroImageSecondary =
"$applicationThemesDirectoryPath/$themeId/assets/${json["monero_image_secondary"] as String}"
"$themeId/assets/${json["monero_image_secondary"] as String}"
..wowneroImageSecondary =
"$applicationThemesDirectoryPath/$themeId/assets/${json["wownero_image_secondary"] as String}"
"$themeId/assets/${json["wownero_image_secondary"] as String}"
..namecoinImageSecondary =
"$applicationThemesDirectoryPath/$themeId/assets/${json["namecoin_image_secondary"] as String}"
"$themeId/assets/${json["namecoin_image_secondary"] as String}"
..particlImageSecondary =
"$applicationThemesDirectoryPath/$themeId/assets/${json["particl_image_secondary"] as String}"
"$themeId/assets/${json["particl_image_secondary"] as String}"
..loadingGif = json["loading_gif"] is String
? "$applicationThemesDirectoryPath/$themeId/assets/${json["loading_gif"] as String}"
? "$themeId/assets/${json["loading_gif"] as String}"
: null
..background = json["background"] is String
? "$applicationThemesDirectoryPath/$themeId/assets/${json["background"] as String}"
? "$themeId/assets/${json["background"] as String}"
: null;
}
}
@ -2146,65 +2108,50 @@ class ThemeAssetsV2 implements IThemeAssets {
factory ThemeAssetsV2.fromJson({
required Map<String, dynamic> json,
required String applicationThemesDirectoryPath,
required String themeId,
}) {
return ThemeAssetsV2()
..bellNew =
"$applicationThemesDirectoryPath/$themeId/assets/${json["bell_new"] as String}"
..buy =
"$applicationThemesDirectoryPath/$themeId/assets/${json["buy"] as String}"
..exchange =
"$applicationThemesDirectoryPath/$themeId/assets/${json["exchange"] as String}"
..bellNew = "$themeId/assets/${json["bell_new"] as String}"
..buy = "$themeId/assets/${json["buy"] as String}"
..exchange = "$themeId/assets/${json["exchange"] as String}"
..personaIncognito =
"$applicationThemesDirectoryPath/$themeId/assets/${json["persona_incognito"] as String}"
..personaEasy =
"$applicationThemesDirectoryPath/$themeId/assets/${json["persona_easy"] as String}"
..stack =
"$applicationThemesDirectoryPath/$themeId/assets/${json["stack"] as String}"
..stackIcon =
"$applicationThemesDirectoryPath/$themeId/assets/${json["stack_icon"] as String}"
..receive =
"$applicationThemesDirectoryPath/$themeId/assets/${json["receive"] as String}"
..receivePending =
"$applicationThemesDirectoryPath/$themeId/assets/${json["receive_pending"] as String}"
"$themeId/assets/${json["persona_incognito"] as String}"
..personaEasy = "$themeId/assets/${json["persona_easy"] as String}"
..stack = "$themeId/assets/${json["stack"] as String}"
..stackIcon = "$themeId/assets/${json["stack_icon"] as String}"
..receive = "$themeId/assets/${json["receive"] as String}"
..receivePending = "$themeId/assets/${json["receive_pending"] as String}"
..receiveCancelled =
"$applicationThemesDirectoryPath/$themeId/assets/${json["receive_cancelled"] as String}"
..send =
"$applicationThemesDirectoryPath/$themeId/assets/${json["send"] as String}"
..sendPending =
"$applicationThemesDirectoryPath/$themeId/assets/${json["send_pending"] as String}"
..sendCancelled =
"$applicationThemesDirectoryPath/$themeId/assets/${json["send_cancelled"] as String}"
..themeSelector =
"$applicationThemesDirectoryPath/$themeId/assets/${json["theme_selector"] as String}"
..themePreview =
"$applicationThemesDirectoryPath/$themeId/assets/${json["theme_preview"] as String}"
..txExchange =
"$applicationThemesDirectoryPath/$themeId/assets/${json["tx_exchange"] as String}"
"$themeId/assets/${json["receive_cancelled"] as String}"
..send = "$themeId/assets/${json["send"] as String}"
..sendPending = "$themeId/assets/${json["send_pending"] as String}"
..sendCancelled = "$themeId/assets/${json["send_cancelled"] as String}"
..themeSelector = "$themeId/assets/${json["theme_selector"] as String}"
..themePreview = "$themeId/assets/${json["theme_preview"] as String}"
..txExchange = "$themeId/assets/${json["tx_exchange"] as String}"
..txExchangePending =
"$applicationThemesDirectoryPath/$themeId/assets/${json["tx_exchange_pending"] as String}"
"$themeId/assets/${json["tx_exchange_pending"] as String}"
..txExchangeFailed =
"$applicationThemesDirectoryPath/$themeId/assets/${json["tx_exchange_failed"] as String}"
"$themeId/assets/${json["tx_exchange_failed"] as String}"
..coinPlaceholder =
"$applicationThemesDirectoryPath/$themeId/assets/${json["coin_placeholder"] as String}"
"$themeId/assets/${json["coin_placeholder"] as String}"
..coinIconsString = createCoinAssetsString(
"$applicationThemesDirectoryPath/$themeId/assets",
"$themeId/assets",
Map<String, dynamic>.from(json["coins"]["icons"] as Map),
)
..coinImagesString = createCoinAssetsString(
"$applicationThemesDirectoryPath/$themeId/assets",
"$themeId/assets",
Map<String, dynamic>.from(json["coins"]["images"] as Map),
)
..coinSecondaryImagesString = createCoinAssetsString(
"$applicationThemesDirectoryPath/$themeId/assets",
"$themeId/assets",
Map<String, dynamic>.from(json["coins"]["secondaries"] as Map),
)
..loadingGif = json["loading_gif"] is String
? "$applicationThemesDirectoryPath/$themeId/assets/${json["loading_gif"] as String}"
? "$themeId/assets/${json["loading_gif"] as String}"
: null
..background = json["background"] is String
? "$applicationThemesDirectoryPath/$themeId/assets/${json["background"] as String}"
? "$themeId/assets/${json["background"] as String}"
: null;
}
@ -2265,48 +2212,132 @@ class ThemeAssetsV2 implements IThemeAssets {
@Embedded(inheritance: false)
class ThemeAssetsV3 implements IThemeAssets {
@Name("bellNew")
late final String bellNewRelative;
@override
late final String bellNew;
@override
late final String buy;
@override
late final String exchange;
@override
late final String personaIncognito;
@override
late final String personaEasy;
@override
late final String stack;
@override
late final String stackIcon;
@override
late final String receive;
@override
late final String receivePending;
@override
late final String receiveCancelled;
@override
late final String send;
@override
late final String sendPending;
@override
late final String sendCancelled;
@override
late final String themeSelector;
@override
late final String themePreview;
@override
late final String txExchange;
@override
late final String txExchangePending;
@override
late final String txExchangeFailed;
@override
late final String? loadingGif;
@override
late final String? background;
@ignore
String get bellNew => prependIfNeeded(bellNewRelative);
late final String coinPlaceholder;
@Name("buy")
late final String buyRelative;
@override
@ignore
String get buy => prependIfNeeded(buyRelative);
@Name("exchange")
late final String exchangeRelative;
@override
@ignore
String get exchange => prependIfNeeded(exchangeRelative);
@Name("personaIncognito")
late final String personaIncognitoRelative;
@override
@ignore
String get personaIncognito => prependIfNeeded(personaIncognitoRelative);
@Name("personaEasy")
late final String personaEasyRelative;
@override
@ignore
String get personaEasy => prependIfNeeded(personaEasyRelative);
@Name("stack")
late final String stackRelative;
@override
@ignore
String get stack => prependIfNeeded(stackRelative);
@Name("stackIcon")
late final String stackIconRelative;
@override
@ignore
String get stackIcon => prependIfNeeded(stackIconRelative);
@Name("receive")
late final String receiveRelative;
@override
@ignore
String get receive => prependIfNeeded(receiveRelative);
@Name("receivePending")
late final String receivePendingRelative;
@override
@ignore
String get receivePending => prependIfNeeded(receivePendingRelative);
@Name("receiveCancelled")
late final String receiveCancelledRelative;
@override
@ignore
String get receiveCancelled => prependIfNeeded(receiveCancelledRelative);
@Name("send")
late final String sendRelative;
@override
@ignore
String get send => prependIfNeeded(sendRelative);
@Name("sendPending")
late final String sendPendingRelative;
@override
@ignore
String get sendPending => prependIfNeeded(sendPendingRelative);
@Name("sendCancelled")
late final String sendCancelledRelative;
@override
@ignore
String get sendCancelled => prependIfNeeded(sendCancelledRelative);
@Name("themeSelector")
late final String themeSelectorRelative;
@override
@ignore
String get themeSelector => prependIfNeeded(themeSelectorRelative);
@Name("themePreview")
late final String themePreviewRelative;
@override
@ignore
String get themePreview => prependIfNeeded(themePreviewRelative);
@Name("txExchange")
late final String txExchangeRelative;
@override
@ignore
String get txExchange => prependIfNeeded(txExchangeRelative);
@Name("txExchangePending")
late final String txExchangePendingRelative;
@override
@ignore
String get txExchangePending => prependIfNeeded(txExchangePendingRelative);
@Name("txExchangeFailed")
late final String txExchangeFailedRelative;
@override
@ignore
String get txExchangeFailed => prependIfNeeded(txExchangeFailedRelative);
@Name("loadingGif")
late final String? loadingGifRelative;
@override
@ignore
String? get loadingGif =>
loadingGifRelative != null ? prependIfNeeded(loadingGifRelative!) : null;
@Name("background")
late final String? backgroundRelative;
@override
@ignore
String? get background =>
backgroundRelative != null ? prependIfNeeded(backgroundRelative!) : null;
@Name("coinPlaceholder")
late final String coinPlaceholderRelative;
@ignore
String get coinPlaceholder => prependIfNeeded(coinPlaceholderRelative);
// Added some future proof params in case we want to add anything else
// This should provide some buffer in stead of creating assetsV4 etc
@ -2361,77 +2392,88 @@ class ThemeAssetsV3 implements IThemeAssets {
factory ThemeAssetsV3.fromJson({
required Map<String, dynamic> json,
required String applicationThemesDirectoryPath,
required String themeId,
}) {
return ThemeAssetsV3()
..bellNew =
"$applicationThemesDirectoryPath/$themeId/assets/${json["bell_new"] as String}"
..buy =
"$applicationThemesDirectoryPath/$themeId/assets/${json["buy"] as String}"
..exchange =
"$applicationThemesDirectoryPath/$themeId/assets/${json["exchange"] as String}"
..personaIncognito =
"$applicationThemesDirectoryPath/$themeId/assets/${json["persona_incognito"] as String}"
..personaEasy =
"$applicationThemesDirectoryPath/$themeId/assets/${json["persona_easy"] as String}"
..stack =
"$applicationThemesDirectoryPath/$themeId/assets/${json["stack"] as String}"
..stackIcon =
"$applicationThemesDirectoryPath/$themeId/assets/${json["stack_icon"] as String}"
..receive =
"$applicationThemesDirectoryPath/$themeId/assets/${json["receive"] as String}"
..receivePending =
"$applicationThemesDirectoryPath/$themeId/assets/${json["receive_pending"] as String}"
..receiveCancelled =
"$applicationThemesDirectoryPath/$themeId/assets/${json["receive_cancelled"] as String}"
..send =
"$applicationThemesDirectoryPath/$themeId/assets/${json["send"] as String}"
..sendPending =
"$applicationThemesDirectoryPath/$themeId/assets/${json["send_pending"] as String}"
..sendCancelled =
"$applicationThemesDirectoryPath/$themeId/assets/${json["send_cancelled"] as String}"
..themeSelector =
"$applicationThemesDirectoryPath/$themeId/assets/${json["theme_selector"] as String}"
..themePreview =
"$applicationThemesDirectoryPath/$themeId/assets/${json["theme_preview"] as String}"
..txExchange =
"$applicationThemesDirectoryPath/$themeId/assets/${json["tx_exchange"] as String}"
..txExchangePending =
"$applicationThemesDirectoryPath/$themeId/assets/${json["tx_exchange_pending"] as String}"
..txExchangeFailed =
"$applicationThemesDirectoryPath/$themeId/assets/${json["tx_exchange_failed"] as String}"
..coinPlaceholder =
"$applicationThemesDirectoryPath/$themeId/assets/${json["coin_placeholder"] as String}"
..bellNewRelative = "$themeId/assets/${json["bell_new"] as String}"
..buyRelative = "$themeId/assets/${json["buy"] as String}"
..exchangeRelative = "$themeId/assets/${json["exchange"] as String}"
..personaIncognitoRelative =
"$themeId/assets/${json["persona_incognito"] as String}"
..personaEasyRelative =
"$themeId/assets/${json["persona_easy"] as String}"
..stackRelative = "$themeId/assets/${json["stack"] as String}"
..stackIconRelative = "$themeId/assets/${json["stack_icon"] as String}"
..receiveRelative = "$themeId/assets/${json["receive"] as String}"
..receivePendingRelative =
"$themeId/assets/${json["receive_pending"] as String}"
..receiveCancelledRelative =
"$themeId/assets/${json["receive_cancelled"] as String}"
..sendRelative = "$themeId/assets/${json["send"] as String}"
..sendPendingRelative =
"$themeId/assets/${json["send_pending"] as String}"
..sendCancelledRelative =
"$themeId/assets/${json["send_cancelled"] as String}"
..themeSelectorRelative =
"$themeId/assets/${json["theme_selector"] as String}"
..themePreviewRelative =
"$themeId/assets/${json["theme_preview"] as String}"
..txExchangeRelative = "$themeId/assets/${json["tx_exchange"] as String}"
..txExchangePendingRelative =
"$themeId/assets/${json["tx_exchange_pending"] as String}"
..txExchangeFailedRelative =
"$themeId/assets/${json["tx_exchange_failed"] as String}"
..coinPlaceholderRelative =
"$themeId/assets/${json["coin_placeholder"] as String}"
..coinIconsString = createCoinAssetsString(
"$applicationThemesDirectoryPath/$themeId/assets",
"$themeId/assets",
Map<String, dynamic>.from(json["coins"]["icons"] as Map),
)
..coinImagesString = createCoinAssetsString(
"$applicationThemesDirectoryPath/$themeId/assets",
"$themeId/assets",
Map<String, dynamic>.from(json["coins"]["images"] as Map),
)
..coinSecondaryImagesString = createCoinAssetsString(
"$applicationThemesDirectoryPath/$themeId/assets",
"$themeId/assets",
Map<String, dynamic>.from(json["coins"]["secondaries"] as Map),
)
..coinCardImagesString = json["coins"]["cards"] is Map
? createCoinAssetsString(
"$applicationThemesDirectoryPath/$themeId/assets",
"$themeId/assets",
Map<String, dynamic>.from(json["coins"]["cards"] as Map),
)
: null
..loadingGif = json["loading_gif"] is String
? "$applicationThemesDirectoryPath/$themeId/assets/${json["loading_gif"] as String}"
..loadingGifRelative = json["loading_gif"] is String
? "$themeId/assets/${json["loading_gif"] as String}"
: null
..background = json["background"] is String
? "$applicationThemesDirectoryPath/$themeId/assets/${json["background"] as String}"
..backgroundRelative = json["background"] is String
? "$themeId/assets/${json["background"] as String}"
: null
..dummy1 = null
..dummy2 = null
..dummy3 = null;
}
static String prependIfNeeded(String relativePath) {
final path = StackFileSystem.themesDir!.path;
if (relativePath.startsWith(path)) {
return relativePath;
} else {
if (Platform.isIOS) {
const pattern = "/var/mobile/Containers/Data/Application/";
if (relativePath.startsWith(pattern)) {
final parts = relativePath.split("/Library/themes/");
if (parts.isNotEmpty) {
return "$path/${parts.last}";
}
}
}
return "$path/$relativePath";
}
}
static String createCoinAssetsString(String path, Map<String, dynamic> json) {
final Map<String, dynamic> map = {};
for (final entry in json.entries) {
@ -2451,6 +2493,8 @@ class ThemeAssetsV3 implements IThemeAssets {
for (final coin in Coin.values) {
result[coin] = map[coin.name] as String? ?? placeHolder;
result[coin] = prependIfNeeded(result[coin]!);
}
return result;

File diff suppressed because it is too large Load diff

View file

@ -126,7 +126,7 @@ class _StackThemeCardState extends ConsumerState<StackThemeCard> {
}
Future<String> getThemeDirectorySize() async {
final themesDir = await StackFileSystem.applicationThemesDirectory();
final themesDir = StackFileSystem.themesDir!;
final themeDir = Directory("${themesDir.path}/${widget.data.id}");
int bytes = 0;
if (await themeDir.exists()) {

View file

@ -9,9 +9,9 @@
*/
import 'package:flutter/material.dart';
import 'package:stackwallet/db/hive/db.dart';
import 'package:stackwallet/pages/intro_view.dart';
import 'package:stackwallet/themes/stack_colors.dart';
import 'package:stackwallet/utilities/delete_everything.dart';
import 'package:stackwallet/utilities/text_styles.dart';
import 'package:stackwallet/utilities/util.dart';
import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart';
@ -36,7 +36,7 @@ class _DeleteAccountViewState extends State<DeleteAccountView> {
Future<void> onConfirmDeleteAccount() async {
// TODO delete everything then pop to intro view
await showDialog(
await showDialog<void>(
barrierDismissible: true,
context: context,
builder: (_) => StackDialog(
@ -61,12 +61,14 @@ class _DeleteAccountViewState extends State<DeleteAccountView> {
.extension<StackColors>()!
.getPrimaryEnabledButtonStyle(context),
onPressed: () async {
await deleteEverything();
await DB.instance.deleteEverything();
if (mounted) {
await Navigator.of(context).pushNamedAndRemoveUntil(
IntroView.routeName,
(route) => false,
);
}
},
child: Text(
"Delete",
@ -82,7 +84,7 @@ class _DeleteAccountViewState extends State<DeleteAccountView> {
return MasterScaffold(
isDesktop: isDesktop,
appBar: isDesktop
? DesktopAppBar(isCompactHeight: true)
? const DesktopAppBar(isCompactHeight: true)
: AppBar(
leading: AppBarBackButton(
onPressed: () async {

View file

@ -15,7 +15,6 @@ import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:flutter_svg/svg.dart';
import 'package:hive_flutter/hive_flutter.dart';
import 'package:stackwallet/db/hive/db.dart';
import 'package:stackwallet/notifications/show_flush_bar.dart';
import 'package:stackwallet/pages/settings_views/global_settings_view/stack_backup_views/helpers/restore_create_backup.dart';
@ -213,8 +212,8 @@ class _ForgottenPassphraseRestoreFromSWBState
await (ref.read(secureStoreProvider).store as DesktopSecureStore)
.close();
ref.refresh(secureStoreProvider);
await ref.read(storageCryptoHandlerProvider).deleteBox();
ref.refresh(storageCryptoHandlerProvider);
await Hive.deleteBoxFromDisk(DB.boxNameDesktopData);
await DB.instance.init();
if (mounted) {
Navigator.of(context)

View file

@ -40,7 +40,7 @@ class ThemeService {
void init(MainDB db) => _db ??= db;
Future<void> install({required Uint8List themeArchiveData}) async {
final themesDir = await StackFileSystem.applicationThemesDirectory();
final themesDir = StackFileSystem.themesDir!;
final archive = ZipDecoder().decodeBytes(themeArchiveData);
@ -55,7 +55,6 @@ class ThemeService {
final theme = StackTheme.fromJson(
json: Map<String, dynamic>.from(json),
applicationThemesDirectoryPath: themesDir.path,
);
try {
@ -88,7 +87,7 @@ class ThemeService {
}
Future<void> remove({required String themeId}) async {
final themesDir = await StackFileSystem.applicationThemesDirectory();
final themesDir = StackFileSystem.themesDir!;
final isarId = await db.isar.stackThemes
.where()
.themeIdEqualTo(themeId)
@ -187,7 +186,7 @@ class ThemeService {
return false;
}
final themesDir = await StackFileSystem.applicationThemesDirectory();
final themesDir = StackFileSystem.themesDir!;
final jsonFileExists =
await File("${themesDir.path}/$themeId/theme.json").exists();
final assetsDirExists =

View file

@ -178,10 +178,8 @@ class DbVersionMigrator with WalletDB {
case 3:
// clear possible broken firo cache
await DB.instance.deleteBoxFromDisk(
boxName: DB.instance.boxNameSetCache(coin: Coin.firo));
await DB.instance.deleteBoxFromDisk(
boxName: DB.instance.boxNameUsedSerialsCache(coin: Coin.firo));
await DB.instance.clearSharedTransactionCache(coin: Coin.firo);
// update version
await DB.instance.put<dynamic>(

View file

@ -1,40 +0,0 @@
/*
* 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 'package:stackwallet/db/hive/db.dart';
import 'package:stackwallet/utilities/logger.dart';
Future<bool> deleteEverything() async {
try {
await DB.instance.deleteBoxFromDisk(boxName: DB.boxNameAddressBook);
await DB.instance.deleteBoxFromDisk(boxName: DB.boxNameDebugInfo);
await DB.instance.deleteBoxFromDisk(boxName: DB.boxNameNodeModels);
await DB.instance.deleteBoxFromDisk(boxName: DB.boxNamePrimaryNodes);
await DB.instance.deleteBoxFromDisk(boxName: DB.boxNameAllWalletsData);
await DB.instance.deleteBoxFromDisk(boxName: DB.boxNameNotifications);
await DB.instance.deleteBoxFromDisk(boxName: DB.boxNameWatchedTransactions);
await DB.instance.deleteBoxFromDisk(boxName: DB.boxNameWatchedTrades);
await DB.instance.deleteBoxFromDisk(boxName: DB.boxNameTrades);
await DB.instance.deleteBoxFromDisk(boxName: DB.boxNameTradesV2);
await DB.instance.deleteBoxFromDisk(boxName: DB.boxNameTradeNotes);
await DB.instance.deleteBoxFromDisk(boxName: DB.boxNameTradeLookup);
await DB.instance.deleteBoxFromDisk(boxName: DB.boxNameFavoriteWallets);
await DB.instance.deleteBoxFromDisk(boxName: DB.boxNamePrefs);
await DB.instance
.deleteBoxFromDisk(boxName: DB.boxNameWalletsToDeleteOnStart);
await DB.instance.deleteBoxFromDisk(boxName: DB.boxNamePriceCache);
await DB.instance.deleteBoxFromDisk(boxName: DB.boxNameDBInfo);
await DB.instance.deleteBoxFromDisk(boxName: "theme");
return true;
} catch (e, s) {
Logging.instance.log("$e $s", level: LogLevel.Error);
return false;
}
}

View file

@ -10,9 +10,9 @@
import 'package:hive/hive.dart';
import 'package:stack_wallet_backup/secure_storage.dart';
import 'package:stackwallet/db/hive/db.dart';
import 'package:stackwallet/utilities/logger.dart';
const String kBoxNameDesktopData = "desktopData";
const String _kKeyBlobKey = "swbKeyBlobKeyStringID";
const String _kKeyBlobVersionKey = "swbKeyBlobVersionKeyStringID";
@ -62,14 +62,8 @@ class DPS {
kLatestBlobVersion,
);
final box = await Hive.openBox<String>(DB.boxNameDesktopData);
await DB.instance.put<String>(
boxName: DB.boxNameDesktopData,
key: _kKeyBlobKey,
value: await _handler!.getKeyBlob(),
);
await _put(key: _kKeyBlobKey, value: await _handler!.getKeyBlob());
await _updateStoredKeyBlobVersion(kLatestBlobVersion);
await box.close();
} catch (e, s) {
Logging.instance.log(
"${_getMessageFromException(e)}\n$s",
@ -85,19 +79,13 @@ class DPS {
"DPS: attempted to re initialize with existing passphrase");
}
final box = await Hive.openBox<String>(DB.boxNameDesktopData);
final keyBlob = DB.instance.get<String>(
boxName: DB.boxNameDesktopData,
key: _kKeyBlobKey,
);
await box.close();
try {
final keyBlob = await _get(key: _kKeyBlobKey);
if (keyBlob == null) {
throw Exception(
"DPS: failed to find keyBlob while attempting to initialize with existing passphrase");
}
try {
final blobVersion = await _getStoredKeyBlobVersion();
_handler = await StorageCryptoHandler.fromExisting(
passphrase,
@ -107,14 +95,8 @@ class DPS {
if (blobVersion < kLatestBlobVersion) {
// update blob
await _handler!.resetPassphrase(passphrase, kLatestBlobVersion);
final box = await Hive.openBox<String>(DB.boxNameDesktopData);
await DB.instance.put<String>(
boxName: DB.boxNameDesktopData,
key: _kKeyBlobKey,
value: await _handler!.getKeyBlob(),
);
await _put(key: _kKeyBlobKey, value: await _handler!.getKeyBlob());
await _updateStoredKeyBlobVersion(kLatestBlobVersion);
await box.close();
}
} catch (e, s) {
Logging.instance.log(
@ -126,19 +108,13 @@ class DPS {
}
Future<bool> verifyPassphrase(String passphrase) async {
final box = await Hive.openBox<String>(DB.boxNameDesktopData);
final keyBlob = DB.instance.get<String>(
boxName: DB.boxNameDesktopData,
key: _kKeyBlobKey,
);
await box.close();
try {
final keyBlob = await _get(key: _kKeyBlobKey);
if (keyBlob == null) {
// no passphrase key blob found so any passphrase is technically bad
return false;
}
try {
final blobVersion = await _getStoredKeyBlobVersion();
await StorageCryptoHandler.fromExisting(passphrase, keyBlob, blobVersion);
// existing passphrase matches key blob
@ -157,12 +133,8 @@ class DPS {
String passphraseOld,
String passphraseNew,
) async {
final box = await Hive.openBox<String>(DB.boxNameDesktopData);
final keyBlob = DB.instance.get<String>(
boxName: DB.boxNameDesktopData,
key: _kKeyBlobKey,
);
await box.close();
try {
final keyBlob = await _get(key: _kKeyBlobKey);
if (keyBlob == null) {
// no passphrase key blob found so any passphrase is technically bad
@ -174,18 +146,12 @@ class DPS {
}
final blobVersion = await _getStoredKeyBlobVersion();
try {
await _handler!.resetPassphrase(passphraseNew, blobVersion);
final box = await Hive.openBox<String>(DB.boxNameDesktopData);
await DB.instance.put<String>(
boxName: DB.boxNameDesktopData,
await _put(
key: _kKeyBlobKey,
value: await _handler!.getKeyBlob(),
);
await _updateStoredKeyBlobVersion(blobVersion);
await box.close();
// successfully updated passphrase
return true;
@ -199,28 +165,54 @@ class DPS {
}
Future<bool> hasPassword() async {
final keyBlob = DB.instance.get<String>(
boxName: DB.boxNameDesktopData,
key: _kKeyBlobKey,
);
final keyBlob = await _get(key: _kKeyBlobKey);
return keyBlob != null;
}
Future<int> _getStoredKeyBlobVersion() async {
final box = await Hive.openBox<String>(DB.boxNameDesktopData);
final keyBlobVersionString = DB.instance.get<String>(
boxName: DB.boxNameDesktopData,
key: _kKeyBlobVersionKey,
);
await box.close();
final keyBlobVersionString = await _get(key: _kKeyBlobVersionKey);
return int.tryParse(keyBlobVersionString ?? "1") ?? 1;
}
Future<void> _updateStoredKeyBlobVersion(int version) async {
await DB.instance.put<String>(
boxName: DB.boxNameDesktopData,
key: _kKeyBlobVersionKey,
value: version.toString(),
await _put(key: _kKeyBlobVersionKey, value: version.toString());
}
Future<void> _put({required String key, required String value}) async {
Box<String>? box;
try {
box = await Hive.openBox<String>(kBoxNameDesktopData);
await box.put(key, value);
} catch (e, s) {
Logging.instance.log(
"DPS failed put($key): $e\n$s",
level: LogLevel.Fatal,
);
} finally {
await box?.close();
}
}
Future<String?> _get({required String key}) async {
String? value;
Box<String>? box;
try {
box = await Hive.openBox<String>(kBoxNameDesktopData);
value = box.get(key);
} catch (e, s) {
Logging.instance.log(
"DPS failed get($key): $e\n$s",
level: LogLevel.Fatal,
);
} finally {
await box?.close();
}
return value;
}
/// Dangerous. Used in one place and should not be called anywhere else.
@Deprecated("Don't use this if at all possible")
Future<void> deleteBox() async {
await Hive.deleteBoxFromDisk(kBoxNameDesktopData);
}
}

View file

@ -73,16 +73,15 @@ abstract class StackFileSystem {
}
}
static Future<Directory> applicationThemesDirectory() async {
static Future<void> initThemesDir() async {
final root = await applicationRootDirectory();
// if (Util.isDesktop) {
final dir = Directory("${root.path}/themes");
if (!dir.existsSync()) {
await dir.create();
}
return dir;
// } else {
// return root;
// }
themesDir = dir;
}
static Directory? themesDir;
}

View file

@ -1,9 +1,7 @@
import 'package:flutter_test/flutter_test.dart';
import 'package:hive/hive.dart';
import 'package:hive_test/hive_test.dart';
import 'package:mockito/annotations.dart';
import 'package:mockito/mockito.dart';
import 'package:stackwallet/db/hive/db.dart';
import 'package:stackwallet/electrumx_rpc/cached_electrumx.dart';
import 'package:stackwallet/electrumx_rpc/electrumx.dart';
import 'package:stackwallet/utilities/enums/coin_enum.dart';
@ -17,10 +15,10 @@ void main() {
group("tests using mock hive", () {
setUp(() async {
await setUpTestHive();
await Hive.openBox<dynamic>(
DB.instance.boxNameUsedSerialsCache(coin: Coin.firo));
await Hive.openBox<dynamic>(DB.instance.boxNameSetCache(coin: Coin.firo));
await Hive.openBox<dynamic>(DB.instance.boxNameTxCache(coin: Coin.firo));
// await Hive.openBox<dynamic>(
// DB.instance.boxNameUsedSerialsCache(coin: Coin.firo));
// await Hive.openBox<dynamic>(DB.instance.boxNameSetCache(coin: Coin.firo));
// await Hive.openBox<dynamic>(DB.instance.boxNameTxCache(coin: Coin.firo));
});
group("getAnonymitySet", () {
// test("empty set cache call", () async {

View file

@ -1,12 +1,10 @@
import 'package:flutter_test/flutter_test.dart';
import 'package:hive_test/hive_test.dart';
import 'package:stackwallet/db/hive/db.dart';
import 'package:stackwallet/utilities/enums/coin_enum.dart';
void main() {
group("DB box names", () {
test("address book", () => expect(DB.boxNameAddressBook, "addressBook"));
test("debug info", () => expect(DB.boxNameDebugInfo, "debugInfoBox"));
test("nodes", () => expect(DB.boxNameNodeModels, "nodeModels"));
test("primary nodes", () => expect(DB.boxNamePrimaryNodes, "primaryNodes"));
test("wallets info", () => expect(DB.boxNameAllWalletsData, "wallets"));
@ -33,26 +31,6 @@ void main() {
expect(DB.boxNameWalletsToDeleteOnStart, "walletsToDeleteOnStart"));
test("price cache",
() => expect(DB.boxNamePriceCache, "priceAPIPrice24hCache"));
test("boxNameTxCache", () {
for (final coin in Coin.values) {
expect(DB.instance.boxNameTxCache(coin: coin), "${coin.name}_txCache");
}
});
test("boxNameSetCache", () {
for (final coin in Coin.values) {
expect(DB.instance.boxNameSetCache(coin: coin),
"${coin.name}_anonymitySetCache");
}
});
test("boxNameUsedSerialsCache", () {
for (final coin in Coin.values) {
expect(DB.instance.boxNameUsedSerialsCache(coin: coin),
"${coin.name}_usedSerialsCache");
}
});
});
group("tests requiring test hive environment", () {

View file

@ -23,7 +23,6 @@ void main() {
final mockThemeService = MockThemeService();
final theme = StackTheme.fromJson(
json: lightThemeJsonMap,
applicationThemesDirectoryPath: "test",
);
when(mockThemeService.getTheme(themeId: "light")).thenAnswer(

View file

@ -59,7 +59,6 @@ void main() {
when(mockThemeService.getTheme(themeId: "light")).thenAnswer(
(_) => StackTheme.fromJson(
json: lightThemeJsonMap,
applicationThemesDirectoryPath: "test",
),
);
when(mockPrefs.currency).thenAnswer((_) => "USD");
@ -89,7 +88,6 @@ void main() {
StackColors.fromStackColorTheme(
StackTheme.fromJson(
json: lightThemeJsonMap,
applicationThemesDirectoryPath: "test",
),
),
],
@ -143,7 +141,6 @@ void main() {
when(mockThemeService.getTheme(themeId: "light")).thenAnswer(
(_) => StackTheme.fromJson(
json: lightThemeJsonMap,
applicationThemesDirectoryPath: "test",
),
);
@ -169,7 +166,6 @@ void main() {
StackColors.fromStackColorTheme(
StackTheme.fromJson(
json: lightThemeJsonMap,
applicationThemesDirectoryPath: "test",
),
),
],

View file

@ -56,8 +56,6 @@ void main() {
StackColors.fromStackColorTheme(
StackTheme.fromJson(
json: lightThemeJsonMap,
applicationThemesDirectoryPath:
applicationThemesDirectoryPath,
),
),
],

View file

@ -28,7 +28,6 @@ void main() {
StackColors.fromStackColorTheme(
StackTheme.fromJson(
json: lightThemeJsonMap,
applicationThemesDirectoryPath: "test",
),
),
],

View file

@ -28,7 +28,6 @@ void main() {
StackColors.fromStackColorTheme(
StackTheme.fromJson(
json: lightThemeJsonMap,
applicationThemesDirectoryPath: "test",
),
),
],

View file

@ -24,7 +24,6 @@ void main() {
StackColors.fromStackColorTheme(
StackTheme.fromJson(
json: lightThemeJsonMap,
applicationThemesDirectoryPath: "test",
),
),
],
@ -56,7 +55,6 @@ void main() {
StackColors.fromStackColorTheme(
StackTheme.fromJson(
json: lightThemeJsonMap,
applicationThemesDirectoryPath: "test",
),
),
],
@ -93,7 +91,6 @@ void main() {
StackColors.fromStackColorTheme(
StackTheme.fromJson(
json: lightThemeJsonMap,
applicationThemesDirectoryPath: "test",
),
),
],

View file

@ -22,7 +22,6 @@ void main() {
when(mockThemeService.getTheme(themeId: "light")).thenAnswer(
(_) => StackTheme.fromJson(
json: lightThemeJsonMap,
applicationThemesDirectoryPath: "test",
),
);
@ -37,7 +36,6 @@ void main() {
StackColors.fromStackColorTheme(
StackTheme.fromJson(
json: lightThemeJsonMap,
applicationThemesDirectoryPath: "test",
),
),
],

View file

@ -22,7 +22,6 @@ void main() {
when(mockThemeService.getTheme(themeId: "light")).thenAnswer(
(_) => StackTheme.fromJson(
json: lightThemeJsonMap,
applicationThemesDirectoryPath: "test",
),
);
@ -37,7 +36,6 @@ void main() {
StackColors.fromStackColorTheme(
StackTheme.fromJson(
json: lightThemeJsonMap,
applicationThemesDirectoryPath: "test",
),
),
],

View file

@ -67,7 +67,6 @@ void main() {
StackColors.fromStackColorTheme(
StackTheme.fromJson(
json: lightThemeJsonMap,
applicationThemesDirectoryPath: "test",
),
),
],
@ -99,7 +98,6 @@ void main() {
StackColors.fromStackColorTheme(
StackTheme.fromJson(
json: lightThemeJsonMap,
applicationThemesDirectoryPath: "test",
),
),
],
@ -151,7 +149,6 @@ void main() {
StackColors.fromStackColorTheme(
StackTheme.fromJson(
json: lightThemeJsonMap,
applicationThemesDirectoryPath: "test",
),
),
],
@ -187,7 +184,6 @@ void main() {
StackColors.fromStackColorTheme(
StackTheme.fromJson(
json: lightThemeJsonMap,
applicationThemesDirectoryPath: "test",
),
),
],
@ -223,7 +219,6 @@ void main() {
StackColors.fromStackColorTheme(
StackTheme.fromJson(
json: lightThemeJsonMap,
applicationThemesDirectoryPath: "test",
),
),
],
@ -264,7 +259,6 @@ void main() {
StackColors.fromStackColorTheme(
StackTheme.fromJson(
json: lightThemeJsonMap,
applicationThemesDirectoryPath: "test",
),
),
],
@ -301,7 +295,6 @@ void main() {
StackColors.fromStackColorTheme(
StackTheme.fromJson(
json: lightThemeJsonMap,
applicationThemesDirectoryPath: "test",
),
),
],
@ -333,7 +326,7 @@ void main() {
// StackColors.fromStackColorTheme(
// StackTheme.fromJson(
// json: lightThemeJsonMap,
// applicationThemesDirectoryPath: "test",
//
// ),
// ),
// ],
@ -385,7 +378,6 @@ void main() {
StackColors.fromStackColorTheme(
StackTheme.fromJson(
json: lightThemeJsonMap,
applicationThemesDirectoryPath: "test",
),
),
],
@ -427,7 +419,6 @@ void main() {
StackColors.fromStackColorTheme(
StackTheme.fromJson(
json: lightThemeJsonMap,
applicationThemesDirectoryPath: "test",
),
),
],
@ -469,7 +460,6 @@ void main() {
StackColors.fromStackColorTheme(
StackTheme.fromJson(
json: lightThemeJsonMap,
applicationThemesDirectoryPath: "test",
),
),
],
@ -510,7 +500,6 @@ void main() {
StackColors.fromStackColorTheme(
StackTheme.fromJson(
json: lightThemeJsonMap,
applicationThemesDirectoryPath: "test",
),
),
],

View file

@ -17,7 +17,6 @@ void main() {
StackColors.fromStackColorTheme(
StackTheme.fromJson(
json: lightThemeJsonMap,
applicationThemesDirectoryPath: "test",
),
),
],

View file

@ -19,7 +19,6 @@ void main() {
StackColors.fromStackColorTheme(
StackTheme.fromJson(
json: lightThemeJsonMap,
applicationThemesDirectoryPath: "test",
),
),
],

View file

@ -24,7 +24,6 @@ void main() {
StackColors.fromStackColorTheme(
StackTheme.fromJson(
json: lightThemeJsonMap,
applicationThemesDirectoryPath: "test",
),
),
],

View file

@ -18,7 +18,6 @@ void main() {
StackColors.fromStackColorTheme(
StackTheme.fromJson(
json: lightThemeJsonMap,
applicationThemesDirectoryPath: "test",
),
),
],

View file

@ -21,7 +21,6 @@ void main() {
when(mockThemeService.getTheme(themeId: "light")).thenAnswer(
(_) => StackTheme.fromJson(
json: lightThemeJsonMap,
applicationThemesDirectoryPath: "test",
),
);
await widgetTester.pumpWidget(
@ -35,7 +34,6 @@ void main() {
StackColors.fromStackColorTheme(
StackTheme.fromJson(
json: lightThemeJsonMap,
applicationThemesDirectoryPath: "test",
),
),
],
@ -57,7 +55,6 @@ void main() {
when(mockThemeService.getTheme(themeId: "light")).thenAnswer(
(_) => StackTheme.fromJson(
json: lightThemeJsonMap,
applicationThemesDirectoryPath: "test",
),
);
@ -72,7 +69,6 @@ void main() {
StackColors.fromStackColorTheme(
StackTheme.fromJson(
json: lightThemeJsonMap,
applicationThemesDirectoryPath: "test",
),
),
],
@ -97,7 +93,6 @@ void main() {
when(mockThemeService.getTheme(themeId: "light")).thenAnswer(
(_) => StackTheme.fromJson(
json: lightThemeJsonMap,
applicationThemesDirectoryPath: "test",
),
);
@ -112,7 +107,6 @@ void main() {
StackColors.fromStackColorTheme(
StackTheme.fromJson(
json: lightThemeJsonMap,
applicationThemesDirectoryPath: "test",
),
),
],

View file

@ -20,7 +20,6 @@ void main() {
StackColors.fromStackColorTheme(
StackTheme.fromJson(
json: lightThemeJsonMap,
applicationThemesDirectoryPath: "test",
),
),
],
@ -49,7 +48,6 @@ void main() {
StackColors.fromStackColorTheme(
StackTheme.fromJson(
json: lightThemeJsonMap,
applicationThemesDirectoryPath: "test",
),
),
],

View file

@ -21,7 +21,6 @@ void main() {
StackColors.fromStackColorTheme(
StackTheme.fromJson(
json: lightThemeJsonMap,
applicationThemesDirectoryPath: "test",
),
),
],

View file

@ -55,7 +55,6 @@ void main() {
when(mockThemeService.getTheme(themeId: "light")).thenAnswer(
(_) => StackTheme.fromJson(
json: lightThemeJsonMap,
applicationThemesDirectoryPath: "test",
),
);
when(wallet.coin).thenAnswer((_) => Coin.bitcoin);
@ -97,7 +96,6 @@ void main() {
StackColors.fromStackColorTheme(
StackTheme.fromJson(
json: lightThemeJsonMap,
applicationThemesDirectoryPath: "test",
),
),
],
@ -126,7 +124,6 @@ void main() {
when(mockThemeService.getTheme(themeId: "light")).thenAnswer(
(_) => StackTheme.fromJson(
json: lightThemeJsonMap,
applicationThemesDirectoryPath: "test",
),
);
when(wallet.coin).thenAnswer((_) => Coin.bitcoin);
@ -186,7 +183,6 @@ void main() {
StackColors.fromStackColorTheme(
StackTheme.fromJson(
json: lightThemeJsonMap,
applicationThemesDirectoryPath: "test",
),
),
],
@ -214,7 +210,6 @@ void main() {
when(mockThemeService.getTheme(themeId: "light")).thenAnswer(
(_) => StackTheme.fromJson(
json: lightThemeJsonMap,
applicationThemesDirectoryPath: "test",
),
);
when(wallet.coin).thenAnswer((_) => Coin.bitcoin);
@ -274,7 +269,6 @@ void main() {
StackColors.fromStackColorTheme(
StackTheme.fromJson(
json: lightThemeJsonMap,
applicationThemesDirectoryPath: "test",
),
),
],

View file

@ -57,7 +57,6 @@ void main() {
StackColors.fromStackColorTheme(
StackTheme.fromJson(
json: lightThemeJsonMap,
applicationThemesDirectoryPath: "test",
),
),
],
@ -118,7 +117,6 @@ void main() {
StackColors.fromStackColorTheme(
StackTheme.fromJson(
json: lightThemeJsonMap,
applicationThemesDirectoryPath: "test",
),
),
],
@ -180,7 +178,6 @@ void main() {
StackColors.fromStackColorTheme(
StackTheme.fromJson(
json: lightThemeJsonMap,
applicationThemesDirectoryPath: "test",
),
),
],

View file

@ -63,7 +63,6 @@ void main() {
StackColors.fromStackColorTheme(
StackTheme.fromJson(
json: lightThemeJsonMap,
applicationThemesDirectoryPath: "test",
),
),
],
@ -136,7 +135,6 @@ void main() {
StackColors.fromStackColorTheme(
StackTheme.fromJson(
json: lightThemeJsonMap,
applicationThemesDirectoryPath: "test",
),
),
],
@ -203,7 +201,6 @@ void main() {
StackColors.fromStackColorTheme(
StackTheme.fromJson(
json: lightThemeJsonMap,
applicationThemesDirectoryPath: "test",
),
),
],

View file

@ -10,7 +10,6 @@ void main() {
testWidgets("Widget build", (widgetTester) async {
final theme = StackTheme.fromJson(
json: lightThemeJsonMap,
applicationThemesDirectoryPath: "test",
);
await widgetTester.pumpWidget(
MaterialApp(

View file

@ -15,7 +15,6 @@ void main() {
StackColors.fromStackColorTheme(
StackTheme.fromJson(
json: lightThemeJsonMap,
applicationThemesDirectoryPath: "test",
),
),
],
@ -25,13 +24,14 @@ void main() {
animationRange: 10,
controller: ShakeController(),
animationDuration: const Duration(milliseconds: 200),
child: Column(
children: const [
child: const Column(
children: [
Center(
child: Text("Enter Pin"),
)
],
)),
),
),
),
),
);

View file

@ -17,7 +17,6 @@ void main() {
StackColors.fromStackColorTheme(
StackTheme.fromJson(
json: lightThemeJsonMap,
applicationThemesDirectoryPath: "test",
),
),
],
@ -39,7 +38,6 @@ void main() {
StackColors.fromStackColorTheme(
StackTheme.fromJson(
json: lightThemeJsonMap,
applicationThemesDirectoryPath: "test",
),
),
],
@ -75,7 +73,6 @@ void main() {
StackColors.fromStackColorTheme(
StackTheme.fromJson(
json: lightThemeJsonMap,
applicationThemesDirectoryPath: "test",
),
),
],

View file

@ -16,7 +16,6 @@ void main() {
StackColors.fromStackColorTheme(
StackTheme.fromJson(
json: lightThemeJsonMap,
applicationThemesDirectoryPath: "test",
),
),
],

View file

@ -42,7 +42,6 @@ void main() {
when(mockThemeService.getTheme(themeId: "light")).thenAnswer(
(_) => StackTheme.fromJson(
json: lightThemeJsonMap,
applicationThemesDirectoryPath: "test",
),
);
@ -80,7 +79,6 @@ void main() {
StackColors.fromStackColorTheme(
StackTheme.fromJson(
json: lightThemeJsonMap,
applicationThemesDirectoryPath: "test",
),
),
],

View file

@ -17,7 +17,6 @@ void main() {
StackColors.fromStackColorTheme(
StackTheme.fromJson(
json: lightThemeJsonMap,
applicationThemesDirectoryPath: "test",
),
),
],

View file

@ -16,7 +16,6 @@ void main() {
StackColors.fromStackColorTheme(
StackTheme.fromJson(
json: lightThemeJsonMap,
applicationThemesDirectoryPath: "test",
),
),
],

View file

@ -21,7 +21,6 @@ void main() {
when(mockThemeService.getTheme(themeId: "light")).thenAnswer(
(_) => StackTheme.fromJson(
json: lightThemeJsonMap,
applicationThemesDirectoryPath: "test",
),
);
final trade = Trade(
@ -59,7 +58,6 @@ void main() {
StackColors.fromStackColorTheme(
StackTheme.fromJson(
json: lightThemeJsonMap,
applicationThemesDirectoryPath: "test/sample_data",
),
),
],

View file

@ -93,7 +93,6 @@ void main() {
when(mockThemeService.getTheme(themeId: "light")).thenAnswer(
(_) => StackTheme.fromJson(
json: lightThemeJsonMap,
applicationThemesDirectoryPath: "test",
),
);
when(wallet.coin.ticker).thenAnswer((_) => "FIRO");
@ -138,7 +137,6 @@ void main() {
StackColors.fromStackColorTheme(
StackTheme.fromJson(
json: lightThemeJsonMap,
applicationThemesDirectoryPath: "test",
),
),
],
@ -224,7 +222,6 @@ void main() {
when(mockThemeService.getTheme(themeId: "light")).thenAnswer(
(_) => StackTheme.fromJson(
json: lightThemeJsonMap,
applicationThemesDirectoryPath: "test",
),
);
when(wallet.coin.ticker).thenAnswer((_) => "FIRO");
@ -268,7 +265,6 @@ void main() {
StackColors.fromStackColorTheme(
StackTheme.fromJson(
json: lightThemeJsonMap,
applicationThemesDirectoryPath: "test",
),
),
],
@ -352,7 +348,6 @@ void main() {
when(mockThemeService.getTheme(themeId: "light")).thenAnswer(
(_) => StackTheme.fromJson(
json: lightThemeJsonMap,
applicationThemesDirectoryPath: "test",
),
);
when(wallet.coin.ticker).thenAnswer((_) => "FIRO");
@ -397,7 +392,6 @@ void main() {
StackColors.fromStackColorTheme(
StackTheme.fromJson(
json: lightThemeJsonMap,
applicationThemesDirectoryPath: "test",
),
),
],
@ -474,7 +468,6 @@ void main() {
when(mockThemeService.getTheme(themeId: "light")).thenAnswer(
(_) => StackTheme.fromJson(
json: lightThemeJsonMap,
applicationThemesDirectoryPath: "test",
),
);
when(wallet.coin.ticker).thenAnswer((_) => "FIRO");
@ -524,7 +517,6 @@ void main() {
StackColors.fromStackColorTheme(
StackTheme.fromJson(
json: lightThemeJsonMap,
applicationThemesDirectoryPath: "test",
),
),
],

View file

@ -42,7 +42,6 @@ void main() {
mockito.when(mockThemeService.getTheme(themeId: "light")).thenAnswer(
(_) => StackTheme.fromJson(
json: lightThemeJsonMap,
applicationThemesDirectoryPath: "test",
),
);
mockito.when(wallet.walletId).thenAnswer((realInvocation) => "wallet id");
@ -81,7 +80,6 @@ void main() {
StackColors.fromStackColorTheme(
StackTheme.fromJson(
json: lightThemeJsonMap,
applicationThemesDirectoryPath: "test",
),
),
],

View file

@ -64,7 +64,6 @@ void main() {
StackColors.fromStackColorTheme(
StackTheme.fromJson(
json: lightThemeJsonMap,
applicationThemesDirectoryPath: "test",
),
),
],

View file

@ -41,7 +41,6 @@ void main() {
when(mockThemeService.getTheme(themeId: "light")).thenAnswer(
(_) => StackTheme.fromJson(
json: lightThemeJsonMap,
applicationThemesDirectoryPath: "test",
),
);
when(wallet.coin).thenAnswer((_) => Coin.bitcoin);
@ -73,7 +72,6 @@ void main() {
StackColors.fromStackColorTheme(
StackTheme.fromJson(
json: lightThemeJsonMap,
applicationThemesDirectoryPath: "test",
),
),
],