mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2025-01-22 02:24:30 +00:00
add mockable override option for testing purposes
This commit is contained in:
parent
8921302ee0
commit
60e850f442
22 changed files with 75 additions and 88 deletions
|
@ -10,6 +10,7 @@ import 'package:bs58check/bs58check.dart' as bs58check;
|
|||
import 'package:decimal/decimal.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:isar/isar.dart';
|
||||
import 'package:stackwallet/db/main_db.dart';
|
||||
import 'package:stackwallet/electrumx_rpc/cached_electrumx.dart';
|
||||
import 'package:stackwallet/electrumx_rpc/electrumx.dart';
|
||||
import 'package:stackwallet/models/balance.dart';
|
||||
|
@ -659,8 +660,6 @@ class BitcoinWallet extends CoinServiceAPI with WalletCache, WalletDB {
|
|||
p2wpkhChangeAddressArray.add(address);
|
||||
}
|
||||
|
||||
await isarInit();
|
||||
|
||||
await db.putAddresses([
|
||||
...p2wpkhReceiveAddressArray,
|
||||
...p2wpkhChangeAddressArray,
|
||||
|
@ -1164,7 +1163,6 @@ class BitcoinWallet extends CoinServiceAPI with WalletCache, WalletDB {
|
|||
}
|
||||
|
||||
await _prefs.init();
|
||||
await isarInit();
|
||||
}
|
||||
|
||||
// hack to add tx to txData before refresh completes
|
||||
|
@ -1249,6 +1247,7 @@ class BitcoinWallet extends CoinServiceAPI with WalletCache, WalletDB {
|
|||
required CachedElectrumX cachedClient,
|
||||
required TransactionNotificationTracker tracker,
|
||||
required SecureStorageInterface secureStore,
|
||||
MainDB? mockableOverride,
|
||||
}) {
|
||||
txTracker = tracker;
|
||||
_walletId = walletId;
|
||||
|
@ -1258,6 +1257,7 @@ class BitcoinWallet extends CoinServiceAPI with WalletCache, WalletDB {
|
|||
_cachedElectrumXClient = cachedClient;
|
||||
_secureStore = secureStore;
|
||||
initCache(walletId, coin);
|
||||
isarInit(mockableOverride: mockableOverride);
|
||||
}
|
||||
|
||||
@override
|
||||
|
|
|
@ -11,6 +11,7 @@ import 'package:bs58check/bs58check.dart' as bs58check;
|
|||
import 'package:decimal/decimal.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:isar/isar.dart';
|
||||
import 'package:stackwallet/db/main_db.dart';
|
||||
import 'package:stackwallet/electrumx_rpc/cached_electrumx.dart';
|
||||
import 'package:stackwallet/electrumx_rpc/electrumx.dart';
|
||||
import 'package:stackwallet/models/balance.dart';
|
||||
|
@ -604,8 +605,6 @@ class BitcoinCashWallet extends CoinServiceAPI with WalletCache, WalletDB {
|
|||
p2shChangeAddressArray.add(address);
|
||||
}
|
||||
|
||||
await isarInit();
|
||||
|
||||
await db.putAddresses([
|
||||
...p2pkhReceiveAddressArray,
|
||||
...p2pkhChangeAddressArray,
|
||||
|
@ -1094,7 +1093,6 @@ class BitcoinCashWallet extends CoinServiceAPI with WalletCache, WalletDB {
|
|||
}
|
||||
|
||||
await _prefs.init();
|
||||
await isarInit();
|
||||
}
|
||||
|
||||
// hack to add tx to txData before refresh completes
|
||||
|
@ -1206,6 +1204,7 @@ class BitcoinCashWallet extends CoinServiceAPI with WalletCache, WalletDB {
|
|||
required CachedElectrumX cachedClient,
|
||||
required TransactionNotificationTracker tracker,
|
||||
required SecureStorageInterface secureStore,
|
||||
MainDB? mockableOverride,
|
||||
}) {
|
||||
txTracker = tracker;
|
||||
_walletId = walletId;
|
||||
|
@ -1215,6 +1214,7 @@ class BitcoinCashWallet extends CoinServiceAPI with WalletCache, WalletDB {
|
|||
_cachedElectrumXClient = cachedClient;
|
||||
_secureStore = secureStore;
|
||||
initCache(walletId, coin);
|
||||
isarInit(mockableOverride: mockableOverride);
|
||||
}
|
||||
|
||||
@override
|
||||
|
@ -1372,8 +1372,6 @@ class BitcoinCashWallet extends CoinServiceAPI with WalletCache, WalletDB {
|
|||
_generateAddressForChain(1, 0, DerivePathType.bip49),
|
||||
]);
|
||||
|
||||
await isarInit();
|
||||
|
||||
await db.putAddresses(initialAddresses);
|
||||
|
||||
Logging.instance.log("_generateNewWalletFinished", level: LogLevel.Info);
|
||||
|
|
|
@ -41,6 +41,8 @@ import 'package:stackwallet/utilities/prefs.dart';
|
|||
import 'package:tuple/tuple.dart';
|
||||
import 'package:uuid/uuid.dart';
|
||||
|
||||
import '../../../db/main_db.dart';
|
||||
|
||||
const int MINIMUM_CONFIRMATIONS = 1;
|
||||
const int DUST_LIMIT = 1000000;
|
||||
|
||||
|
@ -519,8 +521,6 @@ class DogecoinWallet extends CoinServiceAPI with WalletCache, WalletDB {
|
|||
p2pkhChangeAddressArray.add(address);
|
||||
}
|
||||
|
||||
await isarInit();
|
||||
|
||||
await db.putAddresses([
|
||||
...p2pkhReceiveAddressArray,
|
||||
...p2pkhChangeAddressArray,
|
||||
|
@ -999,7 +999,6 @@ class DogecoinWallet extends CoinServiceAPI with WalletCache, WalletDB {
|
|||
}
|
||||
|
||||
await _prefs.init();
|
||||
await isarInit();
|
||||
}
|
||||
|
||||
// hack to add tx to txData before refresh completes
|
||||
|
@ -1084,6 +1083,7 @@ class DogecoinWallet extends CoinServiceAPI with WalletCache, WalletDB {
|
|||
required CachedElectrumX cachedClient,
|
||||
required TransactionNotificationTracker tracker,
|
||||
required SecureStorageInterface secureStore,
|
||||
MainDB? mockableOverride,
|
||||
}) {
|
||||
txTracker = tracker;
|
||||
_walletId = walletId;
|
||||
|
@ -1093,6 +1093,7 @@ class DogecoinWallet extends CoinServiceAPI with WalletCache, WalletDB {
|
|||
_cachedElectrumXClient = cachedClient;
|
||||
_secureStore = secureStore;
|
||||
initCache(walletId, coin);
|
||||
isarInit(mockableOverride: mockableOverride);
|
||||
}
|
||||
|
||||
@override
|
||||
|
@ -1234,8 +1235,6 @@ class DogecoinWallet extends CoinServiceAPI with WalletCache, WalletDB {
|
|||
final initialChangeAddressP2PKH =
|
||||
await _generateAddressForChain(1, 0, DerivePathType.bip44);
|
||||
|
||||
await isarInit();
|
||||
|
||||
await db.putAddresses([
|
||||
initialReceivingAddressP2PKH,
|
||||
initialChangeAddressP2PKH,
|
||||
|
|
|
@ -10,6 +10,7 @@ import 'package:http/http.dart';
|
|||
import 'package:isar/isar.dart';
|
||||
import 'package:mutex/mutex.dart';
|
||||
import 'package:stack_wallet_backup/generate_password.dart';
|
||||
import 'package:stackwallet/db/main_db.dart';
|
||||
import 'package:stackwallet/models/balance.dart';
|
||||
import 'package:stackwallet/models/isar/models/isar_models.dart' as isar_models;
|
||||
import 'package:stackwallet/models/node_model.dart';
|
||||
|
@ -528,17 +529,20 @@ class EpicCashWallet extends CoinServiceAPI
|
|||
|
||||
NodeModel? _epicNode;
|
||||
|
||||
EpicCashWallet(
|
||||
{required String walletId,
|
||||
EpicCashWallet({
|
||||
required String walletId,
|
||||
required String walletName,
|
||||
required Coin coin,
|
||||
required SecureStorageInterface secureStore}) {
|
||||
required SecureStorageInterface secureStore,
|
||||
MainDB? mockableOverride,
|
||||
}) {
|
||||
_walletId = walletId;
|
||||
_walletName = walletName;
|
||||
_coin = coin;
|
||||
_secureStore = secureStore;
|
||||
initCache(walletId, coin);
|
||||
initEpicCashHive(walletId);
|
||||
isarInit(mockableOverride: mockableOverride);
|
||||
|
||||
Logging.instance.log("$walletName isolate length: ${isolates.length}",
|
||||
level: LogLevel.Info);
|
||||
|
@ -969,7 +973,6 @@ class EpicCashWallet extends CoinServiceAPI
|
|||
Logging.instance.log("Opening existing ${coin.prettyName} wallet",
|
||||
level: LogLevel.Info);
|
||||
|
||||
await isarInit();
|
||||
final config = await getRealConfig();
|
||||
final password = await _secureStore.read(key: '${_walletId}_password');
|
||||
|
||||
|
@ -1039,8 +1042,6 @@ class EpicCashWallet extends CoinServiceAPI
|
|||
String stringConfig = await getConfig();
|
||||
String epicboxConfig = await getEpicBoxConfig();
|
||||
|
||||
await isarInit();
|
||||
|
||||
await _secureStore.write(
|
||||
key: '${_walletId}_mnemonic', value: mnemonicString);
|
||||
await _secureStore.write(key: '${_walletId}_config', value: stringConfig);
|
||||
|
@ -1081,7 +1082,6 @@ class EpicCashWallet extends CoinServiceAPI
|
|||
epicUpdateChangeIndex(0),
|
||||
]);
|
||||
|
||||
await isarInit();
|
||||
final initialReceivingAddress = await _getReceivingAddressForIndex(0);
|
||||
|
||||
await db.putAddress(initialReceivingAddress);
|
||||
|
|
|
@ -11,6 +11,7 @@ import 'package:decimal/decimal.dart';
|
|||
import 'package:flutter/foundation.dart';
|
||||
import 'package:isar/isar.dart';
|
||||
import 'package:lelantus/lelantus.dart';
|
||||
import 'package:stackwallet/db/main_db.dart';
|
||||
import 'package:stackwallet/electrumx_rpc/cached_electrumx.dart';
|
||||
import 'package:stackwallet/electrumx_rpc/electrumx.dart';
|
||||
import 'package:stackwallet/models/balance.dart';
|
||||
|
@ -1213,6 +1214,7 @@ class FiroWallet extends CoinServiceAPI with WalletCache, WalletDB, FiroHive {
|
|||
required CachedElectrumX cachedClient,
|
||||
required TransactionNotificationTracker tracker,
|
||||
required SecureStorageInterface secureStore,
|
||||
MainDB? mockableOverride,
|
||||
}) {
|
||||
txTracker = tracker;
|
||||
_walletId = walletId;
|
||||
|
@ -1223,6 +1225,7 @@ class FiroWallet extends CoinServiceAPI with WalletCache, WalletDB, FiroHive {
|
|||
_secureStore = secureStore;
|
||||
initCache(walletId, coin);
|
||||
initFiroHive(walletId);
|
||||
isarInit(mockableOverride: mockableOverride);
|
||||
|
||||
Logging.instance.log("$walletName isolates length: ${isolates.length}",
|
||||
level: LogLevel.Info);
|
||||
|
@ -1828,7 +1831,6 @@ class FiroWallet extends CoinServiceAPI with WalletCache, WalletDB, FiroHive {
|
|||
"Attempted to initialize an existing wallet using an unknown wallet ID!");
|
||||
}
|
||||
await _prefs.init();
|
||||
await isarInit();
|
||||
}
|
||||
|
||||
Future<bool> refreshIfThereIsNewData() async {
|
||||
|
@ -2099,8 +2101,6 @@ class FiroWallet extends CoinServiceAPI with WalletCache, WalletDB, FiroHive {
|
|||
final initialReceivingAddress = await _generateAddressForChain(0, 0);
|
||||
final initialChangeAddress = await _generateAddressForChain(1, 0);
|
||||
|
||||
await isarInit();
|
||||
|
||||
await db.putAddresses([
|
||||
initialReceivingAddress,
|
||||
initialChangeAddress,
|
||||
|
@ -4292,8 +4292,6 @@ class FiroWallet extends CoinServiceAPI with WalletCache, WalletDB, FiroHive {
|
|||
Logging.instance
|
||||
.log("PROCESSORS ${Platform.numberOfProcessors}", level: LogLevel.Info);
|
||||
try {
|
||||
await isarInit();
|
||||
|
||||
final latestSetId = await getLatestSetId();
|
||||
final setDataMap = getSetDataMap(latestSetId);
|
||||
final usedSerialNumbers = getUsedCoinSerials();
|
||||
|
|
|
@ -11,6 +11,7 @@ import 'package:crypto/crypto.dart';
|
|||
import 'package:decimal/decimal.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:isar/isar.dart';
|
||||
import 'package:stackwallet/db/main_db.dart';
|
||||
import 'package:stackwallet/electrumx_rpc/cached_electrumx.dart';
|
||||
import 'package:stackwallet/electrumx_rpc/electrumx.dart';
|
||||
import 'package:stackwallet/models/balance.dart';
|
||||
|
@ -677,8 +678,6 @@ class LitecoinWallet extends CoinServiceAPI with WalletCache, WalletDB {
|
|||
p2wpkhChangeAddressArray.add(address);
|
||||
}
|
||||
|
||||
await isarInit();
|
||||
|
||||
await db.putAddresses([
|
||||
...p2wpkhReceiveAddressArray,
|
||||
...p2wpkhChangeAddressArray,
|
||||
|
@ -1182,7 +1181,6 @@ class LitecoinWallet extends CoinServiceAPI with WalletCache, WalletDB {
|
|||
"Attempted to initialize an existing wallet using an unknown wallet ID!");
|
||||
}
|
||||
await _prefs.init();
|
||||
await isarInit();
|
||||
}
|
||||
|
||||
// hack to add tx to txData before refresh completes
|
||||
|
@ -1267,6 +1265,7 @@ class LitecoinWallet extends CoinServiceAPI with WalletCache, WalletDB {
|
|||
required CachedElectrumX cachedClient,
|
||||
required TransactionNotificationTracker tracker,
|
||||
required SecureStorageInterface secureStore,
|
||||
MainDB? mockableOverride,
|
||||
}) {
|
||||
txTracker = tracker;
|
||||
_walletId = walletId;
|
||||
|
@ -1276,6 +1275,7 @@ class LitecoinWallet extends CoinServiceAPI with WalletCache, WalletDB {
|
|||
_cachedElectrumXClient = cachedClient;
|
||||
_secureStore = secureStore;
|
||||
initCache(walletId, coin);
|
||||
isarInit(mockableOverride: mockableOverride);
|
||||
}
|
||||
|
||||
@override
|
||||
|
@ -1473,8 +1473,6 @@ class LitecoinWallet extends CoinServiceAPI with WalletCache, WalletDB {
|
|||
_generateAddressForChain(1, 0, DerivePathType.bip49),
|
||||
]);
|
||||
|
||||
await isarInit();
|
||||
|
||||
await db.putAddresses(initialAddresses);
|
||||
|
||||
Logging.instance.log("_generateNewWalletFinished", level: LogLevel.Info);
|
||||
|
|
|
@ -23,6 +23,7 @@ import 'package:flutter_libmonero/monero/monero.dart';
|
|||
import 'package:flutter_libmonero/view_model/send/output.dart' as monero_output;
|
||||
import 'package:isar/isar.dart';
|
||||
import 'package:mutex/mutex.dart';
|
||||
import 'package:stackwallet/db/main_db.dart';
|
||||
import 'package:stackwallet/hive/db.dart';
|
||||
import 'package:stackwallet/models/balance.dart';
|
||||
import 'package:stackwallet/models/isar/models/isar_models.dart' as isar_models;
|
||||
|
@ -83,6 +84,7 @@ class MoneroWallet extends CoinServiceAPI with WalletCache, WalletDB {
|
|||
required Coin coin,
|
||||
required SecureStorageInterface secureStorage,
|
||||
Prefs? prefs,
|
||||
MainDB? mockableOverride,
|
||||
}) {
|
||||
_walletId = walletId;
|
||||
_walletName = walletName;
|
||||
|
@ -90,6 +92,7 @@ class MoneroWallet extends CoinServiceAPI with WalletCache, WalletDB {
|
|||
_secureStorage = secureStorage;
|
||||
_prefs = prefs ?? Prefs.instance;
|
||||
initCache(walletId, coin);
|
||||
isarInit(mockableOverride: mockableOverride);
|
||||
}
|
||||
|
||||
@override
|
||||
|
@ -269,7 +272,7 @@ class MoneroWallet extends CoinServiceAPI with WalletCache, WalletDB {
|
|||
keysStorage = KeyService(_secureStorage);
|
||||
|
||||
await _prefs.init();
|
||||
await isarInit();
|
||||
|
||||
// final data =
|
||||
// DB.instance.get<dynamic>(boxName: walletId, key: "latest_tx_model")
|
||||
// as TransactionData?;
|
||||
|
@ -389,7 +392,6 @@ class MoneroWallet extends CoinServiceAPI with WalletCache, WalletDB {
|
|||
// Generate and add addresses to relevant arrays
|
||||
final initialReceivingAddress = await _generateAddressForChain(0, 0);
|
||||
// final initialChangeAddress = await _generateAddressForChain(1, 0);
|
||||
await isarInit();
|
||||
|
||||
await db.putAddress(initialReceivingAddress);
|
||||
|
||||
|
|
|
@ -11,6 +11,7 @@ import 'package:crypto/crypto.dart';
|
|||
import 'package:decimal/decimal.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:isar/isar.dart';
|
||||
import 'package:stackwallet/db/main_db.dart';
|
||||
import 'package:stackwallet/electrumx_rpc/cached_electrumx.dart';
|
||||
import 'package:stackwallet/electrumx_rpc/electrumx.dart';
|
||||
import 'package:stackwallet/models/balance.dart';
|
||||
|
@ -667,8 +668,6 @@ class NamecoinWallet extends CoinServiceAPI with WalletCache, WalletDB {
|
|||
p2wpkhChangeAddressArray.add(address);
|
||||
}
|
||||
|
||||
await isarInit();
|
||||
|
||||
await db.putAddresses([
|
||||
...p2wpkhReceiveAddressArray,
|
||||
...p2wpkhChangeAddressArray,
|
||||
|
@ -1171,7 +1170,6 @@ class NamecoinWallet extends CoinServiceAPI with WalletCache, WalletDB {
|
|||
"Attempted to initialize an existing wallet using an unknown wallet ID!");
|
||||
}
|
||||
await _prefs.init();
|
||||
await isarInit();
|
||||
}
|
||||
|
||||
// hack to add tx to txData before refresh completes
|
||||
|
@ -1256,6 +1254,7 @@ class NamecoinWallet extends CoinServiceAPI with WalletCache, WalletDB {
|
|||
required CachedElectrumX cachedClient,
|
||||
required TransactionNotificationTracker tracker,
|
||||
required SecureStorageInterface secureStore,
|
||||
MainDB? mockableOverride,
|
||||
}) {
|
||||
txTracker = tracker;
|
||||
_walletId = walletId;
|
||||
|
@ -1265,6 +1264,7 @@ class NamecoinWallet extends CoinServiceAPI with WalletCache, WalletDB {
|
|||
_cachedElectrumXClient = cachedClient;
|
||||
_secureStore = secureStore;
|
||||
initCache(walletId, coin);
|
||||
isarInit(mockableOverride: mockableOverride);
|
||||
}
|
||||
|
||||
@override
|
||||
|
@ -1450,8 +1450,6 @@ class NamecoinWallet extends CoinServiceAPI with WalletCache, WalletDB {
|
|||
_generateAddressForChain(1, 0, DerivePathType.bip49),
|
||||
]);
|
||||
|
||||
await isarInit();
|
||||
|
||||
await db.putAddresses(initialAddresses);
|
||||
|
||||
Logging.instance.log("_generateNewWalletFinished", level: LogLevel.Info);
|
||||
|
|
|
@ -11,6 +11,7 @@ import 'package:crypto/crypto.dart';
|
|||
import 'package:decimal/decimal.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:isar/isar.dart';
|
||||
import 'package:stackwallet/db/main_db.dart';
|
||||
import 'package:stackwallet/electrumx_rpc/cached_electrumx.dart';
|
||||
import 'package:stackwallet/electrumx_rpc/electrumx.dart';
|
||||
import 'package:stackwallet/models/balance.dart';
|
||||
|
@ -602,8 +603,6 @@ class ParticlWallet extends CoinServiceAPI with WalletCache, WalletDB {
|
|||
p2wpkhChangeAddressArray.add(address);
|
||||
}
|
||||
|
||||
await isarInit();
|
||||
|
||||
await db.putAddresses([
|
||||
...p2wpkhReceiveAddressArray,
|
||||
...p2wpkhChangeAddressArray,
|
||||
|
@ -1101,7 +1100,6 @@ class ParticlWallet extends CoinServiceAPI with WalletCache, WalletDB {
|
|||
"Attempted to initialize an existing wallet using an unknown wallet ID!");
|
||||
}
|
||||
await _prefs.init();
|
||||
await isarInit();
|
||||
}
|
||||
|
||||
// TODO make sure this copied implementation from bitcoin_wallet.dart applies for particl just as well--or import it
|
||||
|
@ -1187,6 +1185,7 @@ class ParticlWallet extends CoinServiceAPI with WalletCache, WalletDB {
|
|||
required CachedElectrumX cachedClient,
|
||||
required TransactionNotificationTracker tracker,
|
||||
required SecureStorageInterface secureStore,
|
||||
MainDB? mockableOverride,
|
||||
}) {
|
||||
txTracker = tracker;
|
||||
_walletId = walletId;
|
||||
|
@ -1196,6 +1195,7 @@ class ParticlWallet extends CoinServiceAPI with WalletCache, WalletDB {
|
|||
_cachedElectrumXClient = cachedClient;
|
||||
_secureStore = secureStore;
|
||||
initCache(walletId, coin);
|
||||
isarInit(mockableOverride: mockableOverride);
|
||||
}
|
||||
|
||||
@override
|
||||
|
@ -1364,8 +1364,6 @@ class ParticlWallet extends CoinServiceAPI with WalletCache, WalletDB {
|
|||
_generateAddressForChain(1, 0, DerivePathType.bip44),
|
||||
]);
|
||||
|
||||
await isarInit();
|
||||
|
||||
await db.putAddresses(initialAddresses);
|
||||
|
||||
Logging.instance.log("_generateNewWalletFinished", level: LogLevel.Info);
|
||||
|
|
|
@ -25,6 +25,7 @@ import 'package:flutter_libmonero/view_model/send/output.dart'
|
|||
import 'package:flutter_libmonero/wownero/wownero.dart';
|
||||
import 'package:isar/isar.dart';
|
||||
import 'package:mutex/mutex.dart';
|
||||
import 'package:stackwallet/db/main_db.dart';
|
||||
import 'package:stackwallet/hive/db.dart';
|
||||
import 'package:stackwallet/models/balance.dart';
|
||||
import 'package:stackwallet/models/isar/models/isar_models.dart' as isar_models;
|
||||
|
@ -85,6 +86,7 @@ class WowneroWallet extends CoinServiceAPI with WalletCache, WalletDB {
|
|||
required Coin coin,
|
||||
required SecureStorageInterface secureStorage,
|
||||
Prefs? prefs,
|
||||
MainDB? mockableOverride,
|
||||
}) {
|
||||
_walletId = walletId;
|
||||
_walletName = walletName;
|
||||
|
@ -92,6 +94,7 @@ class WowneroWallet extends CoinServiceAPI with WalletCache, WalletDB {
|
|||
_secureStorage = secureStorage;
|
||||
_prefs = prefs ?? Prefs.instance;
|
||||
initCache(walletId, coin);
|
||||
isarInit(mockableOverride: mockableOverride);
|
||||
}
|
||||
|
||||
@override
|
||||
|
@ -293,7 +296,6 @@ class WowneroWallet extends CoinServiceAPI with WalletCache, WalletDB {
|
|||
keysStorage = KeyService(_secureStorage);
|
||||
|
||||
await _prefs.init();
|
||||
await isarInit();
|
||||
|
||||
String? password;
|
||||
try {
|
||||
|
@ -397,7 +399,6 @@ class WowneroWallet extends CoinServiceAPI with WalletCache, WalletDB {
|
|||
// Generate and add addresses to relevant arrays
|
||||
final initialReceivingAddress = await _generateAddressForChain(0, 0);
|
||||
// final initialChangeAddress = await _generateAddressForChain(1, 0);
|
||||
await isarInit();
|
||||
|
||||
await db.putAddress(initialReceivingAddress);
|
||||
|
||||
|
|
|
@ -4,10 +4,11 @@ import 'package:stackwallet/models/isar/models/isar_models.dart';
|
|||
import 'package:tuple/tuple.dart';
|
||||
|
||||
mixin WalletDB {
|
||||
MainDB get db => MainDB.instance;
|
||||
MainDB? _db;
|
||||
MainDB get db => _db!;
|
||||
|
||||
Future<void> isarInit() async {
|
||||
await db.isarInit();
|
||||
void isarInit({MainDB? mockableOverride}) async {
|
||||
_db = mockableOverride ?? MainDB.instance;
|
||||
}
|
||||
|
||||
Future<void> addNewTransactionData(
|
||||
|
|
|
@ -403,7 +403,7 @@ class DbVersionMigrator with WalletDB {
|
|||
_parseTransactions(txnsLelantus, walletId, true, newAddresses));
|
||||
|
||||
// store newly parsed data in isar
|
||||
await isarInit();
|
||||
isarInit();
|
||||
await db.isar.writeTxn(() async {
|
||||
await db.isar.addresses.putAll(newAddresses);
|
||||
});
|
||||
|
|
|
@ -1558,14 +1558,14 @@ class MockBitcoinWallet extends _i1.Mock implements _i21.BitcoinWallet {
|
|||
returnValueForMissingStub: _i17.Future<void>.value(),
|
||||
) as _i17.Future<void>);
|
||||
@override
|
||||
_i17.Future<void> isarInit() => (super.noSuchMethod(
|
||||
void isarInit({_i13.MainDB? mockableOverride}) => super.noSuchMethod(
|
||||
Invocation.method(
|
||||
#isarInit,
|
||||
[],
|
||||
{#mockableOverride: mockableOverride},
|
||||
),
|
||||
returnValue: _i17.Future<void>.value(),
|
||||
returnValueForMissingStub: _i17.Future<void>.value(),
|
||||
) as _i17.Future<void>);
|
||||
returnValueForMissingStub: null,
|
||||
);
|
||||
@override
|
||||
_i17.Future<void> addNewTransactionData(
|
||||
List<
|
||||
|
|
|
@ -3,7 +3,6 @@ import 'package:decimal/decimal.dart';
|
|||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:hive/hive.dart';
|
||||
import 'package:hive_test/hive_test.dart';
|
||||
import 'package:isar/isar.dart';
|
||||
import 'package:mockito/annotations.dart';
|
||||
import 'package:mockito/mockito.dart';
|
||||
import 'package:stackwallet/electrumx_rpc/cached_electrumx.dart';
|
||||
|
@ -23,8 +22,6 @@ import 'bitcoin_wallet_test_parameters.dart';
|
|||
|
||||
@GenerateMocks([ElectrumX, CachedElectrumX, TransactionNotificationTracker])
|
||||
void main() async {
|
||||
await Isar.initializeIsarCore(download: true);
|
||||
|
||||
group("bitcoin constants", () {
|
||||
test("bitcoin minimum confirmations", () async {
|
||||
expect(MINIMUM_CONFIRMATIONS, 1);
|
||||
|
|
|
@ -2,7 +2,6 @@ import 'package:decimal/decimal.dart';
|
|||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:hive/hive.dart';
|
||||
import 'package:hive_test/hive_test.dart';
|
||||
import 'package:isar/isar.dart';
|
||||
import 'package:mockito/annotations.dart';
|
||||
import 'package:mockito/mockito.dart';
|
||||
import 'package:stackwallet/electrumx_rpc/cached_electrumx.dart';
|
||||
|
@ -21,8 +20,6 @@ import 'bitcoincash_wallet_test_parameters.dart';
|
|||
|
||||
@GenerateMocks([ElectrumX, CachedElectrumX, TransactionNotificationTracker])
|
||||
void main() async {
|
||||
await Isar.initializeIsarCore(download: true);
|
||||
|
||||
group("bitcoincash constants", () {
|
||||
test("bitcoincash minimum confirmations", () async {
|
||||
expect(MINIMUM_CONFIRMATIONS, 1);
|
||||
|
|
|
@ -978,14 +978,14 @@ class MockFiroWallet extends _i1.Mock implements _i9.FiroWallet {
|
|||
returnValueForMissingStub: _i10.Future<void>.value(),
|
||||
) as _i10.Future<void>);
|
||||
@override
|
||||
_i10.Future<void> isarInit() => (super.noSuchMethod(
|
||||
void isarInit({_i7.MainDB? mockableOverride}) => super.noSuchMethod(
|
||||
Invocation.method(
|
||||
#isarInit,
|
||||
[],
|
||||
{#mockableOverride: mockableOverride},
|
||||
),
|
||||
returnValue: _i10.Future<void>.value(),
|
||||
returnValueForMissingStub: _i10.Future<void>.value(),
|
||||
) as _i10.Future<void>);
|
||||
returnValueForMissingStub: null,
|
||||
);
|
||||
@override
|
||||
_i10.Future<void> addNewTransactionData(
|
||||
List<
|
||||
|
|
|
@ -1348,14 +1348,14 @@ class MockBitcoinWallet extends _i1.Mock implements _i20.BitcoinWallet {
|
|||
returnValueForMissingStub: _i17.Future<void>.value(),
|
||||
) as _i17.Future<void>);
|
||||
@override
|
||||
_i17.Future<void> isarInit() => (super.noSuchMethod(
|
||||
void isarInit({_i12.MainDB? mockableOverride}) => super.noSuchMethod(
|
||||
Invocation.method(
|
||||
#isarInit,
|
||||
[],
|
||||
{#mockableOverride: mockableOverride},
|
||||
),
|
||||
returnValue: _i17.Future<void>.value(),
|
||||
returnValueForMissingStub: _i17.Future<void>.value(),
|
||||
) as _i17.Future<void>);
|
||||
returnValueForMissingStub: null,
|
||||
);
|
||||
@override
|
||||
_i17.Future<void> addNewTransactionData(
|
||||
List<
|
||||
|
|
|
@ -1333,14 +1333,14 @@ class MockBitcoinWallet extends _i1.Mock implements _i19.BitcoinWallet {
|
|||
returnValueForMissingStub: _i16.Future<void>.value(),
|
||||
) as _i16.Future<void>);
|
||||
@override
|
||||
_i16.Future<void> isarInit() => (super.noSuchMethod(
|
||||
void isarInit({_i12.MainDB? mockableOverride}) => super.noSuchMethod(
|
||||
Invocation.method(
|
||||
#isarInit,
|
||||
[],
|
||||
{#mockableOverride: mockableOverride},
|
||||
),
|
||||
returnValue: _i16.Future<void>.value(),
|
||||
returnValueForMissingStub: _i16.Future<void>.value(),
|
||||
) as _i16.Future<void>);
|
||||
returnValueForMissingStub: null,
|
||||
);
|
||||
@override
|
||||
_i16.Future<void> addNewTransactionData(
|
||||
List<
|
||||
|
|
|
@ -1891,14 +1891,14 @@ class MockFiroWallet extends _i1.Mock implements _i22.FiroWallet {
|
|||
returnValueForMissingStub: _i18.Future<void>.value(),
|
||||
) as _i18.Future<void>);
|
||||
@override
|
||||
_i18.Future<void> isarInit() => (super.noSuchMethod(
|
||||
void isarInit({_i13.MainDB? mockableOverride}) => super.noSuchMethod(
|
||||
Invocation.method(
|
||||
#isarInit,
|
||||
[],
|
||||
{#mockableOverride: mockableOverride},
|
||||
),
|
||||
returnValue: _i18.Future<void>.value(),
|
||||
returnValueForMissingStub: _i18.Future<void>.value(),
|
||||
) as _i18.Future<void>);
|
||||
returnValueForMissingStub: null,
|
||||
);
|
||||
@override
|
||||
_i18.Future<void> addNewTransactionData(
|
||||
List<
|
||||
|
|
|
@ -1096,14 +1096,14 @@ class MockBitcoinWallet extends _i1.Mock implements _i18.BitcoinWallet {
|
|||
returnValueForMissingStub: _i15.Future<void>.value(),
|
||||
) as _i15.Future<void>);
|
||||
@override
|
||||
_i15.Future<void> isarInit() => (super.noSuchMethod(
|
||||
void isarInit({_i12.MainDB? mockableOverride}) => super.noSuchMethod(
|
||||
Invocation.method(
|
||||
#isarInit,
|
||||
[],
|
||||
{#mockableOverride: mockableOverride},
|
||||
),
|
||||
returnValue: _i15.Future<void>.value(),
|
||||
returnValueForMissingStub: _i15.Future<void>.value(),
|
||||
) as _i15.Future<void>);
|
||||
returnValueForMissingStub: null,
|
||||
);
|
||||
@override
|
||||
_i15.Future<void> addNewTransactionData(
|
||||
List<
|
||||
|
|
|
@ -1347,14 +1347,14 @@ class MockBitcoinWallet extends _i1.Mock implements _i20.BitcoinWallet {
|
|||
returnValueForMissingStub: _i17.Future<void>.value(),
|
||||
) as _i17.Future<void>);
|
||||
@override
|
||||
_i17.Future<void> isarInit() => (super.noSuchMethod(
|
||||
void isarInit({_i12.MainDB? mockableOverride}) => super.noSuchMethod(
|
||||
Invocation.method(
|
||||
#isarInit,
|
||||
[],
|
||||
{#mockableOverride: mockableOverride},
|
||||
),
|
||||
returnValue: _i17.Future<void>.value(),
|
||||
returnValueForMissingStub: _i17.Future<void>.value(),
|
||||
) as _i17.Future<void>);
|
||||
returnValueForMissingStub: null,
|
||||
);
|
||||
@override
|
||||
_i17.Future<void> addNewTransactionData(
|
||||
List<
|
||||
|
|
|
@ -1347,14 +1347,14 @@ class MockBitcoinWallet extends _i1.Mock implements _i20.BitcoinWallet {
|
|||
returnValueForMissingStub: _i17.Future<void>.value(),
|
||||
) as _i17.Future<void>);
|
||||
@override
|
||||
_i17.Future<void> isarInit() => (super.noSuchMethod(
|
||||
void isarInit({_i12.MainDB? mockableOverride}) => super.noSuchMethod(
|
||||
Invocation.method(
|
||||
#isarInit,
|
||||
[],
|
||||
{#mockableOverride: mockableOverride},
|
||||
),
|
||||
returnValue: _i17.Future<void>.value(),
|
||||
returnValueForMissingStub: _i17.Future<void>.value(),
|
||||
) as _i17.Future<void>);
|
||||
returnValueForMissingStub: null,
|
||||
);
|
||||
@override
|
||||
_i17.Future<void> addNewTransactionData(
|
||||
List<
|
||||
|
|
Loading…
Reference in a new issue