move wallet constructors below class declaration

This commit is contained in:
julian 2023-02-03 16:48:16 -06:00
parent 4d891e0f31
commit ad0059508c
10 changed files with 245 additions and 243 deletions

View file

@ -95,6 +95,50 @@ String constructDerivePath({
class BitcoinWallet extends CoinServiceAPI
with WalletCache, WalletDB, ElectrumXParsing, PaynymWalletInterface {
BitcoinWallet({
required String walletId,
required String walletName,
required Coin coin,
required ElectrumX client,
required CachedElectrumX cachedClient,
required TransactionNotificationTracker tracker,
required SecureStorageInterface secureStore,
MainDB? mockableOverride,
}) {
txTracker = tracker;
_walletId = walletId;
_walletName = walletName;
_coin = coin;
_electrumXClient = client;
_cachedElectrumXClient = cachedClient;
_secureStore = secureStore;
initCache(walletId, coin);
initWalletDB(mockableOverride: mockableOverride);
initPaynymWalletInterface(
walletId: walletId,
walletName: walletName,
network: _network,
coin: coin,
db: db,
electrumXClient: electrumXClient,
secureStorage: secureStore,
getMnemonicString: () => mnemonicString,
getMnemonicPassphrase: () => mnemonicPassphrase,
getChainHeight: () => chainHeight,
getCurrentChangeAddress: () => currentChangeAddressP2PKH,
estimateTxFee: estimateTxFee,
prepareSend: prepareSend,
getTxCount: getTxCount,
fetchBuildTxData: fetchBuildTxData,
refresh: refresh,
checkChangeAddressForTransactions:
_checkP2PKHChangeAddressForTransactions,
addDerivation: addDerivation,
dustLimitP2PKH: DUST_LIMIT_P2PKH,
minConfirms: MINIMUM_CONFIRMATIONS,
);
}
static const integrationTestFlag =
bool.fromEnvironment("IS_INTEGRATION_TEST");
@ -1296,50 +1340,6 @@ class BitcoinWallet extends CoinServiceAPI
late SecureStorageInterface _secureStore;
BitcoinWallet({
required String walletId,
required String walletName,
required Coin coin,
required ElectrumX client,
required CachedElectrumX cachedClient,
required TransactionNotificationTracker tracker,
required SecureStorageInterface secureStore,
MainDB? mockableOverride,
}) {
txTracker = tracker;
_walletId = walletId;
_walletName = walletName;
_coin = coin;
_electrumXClient = client;
_cachedElectrumXClient = cachedClient;
_secureStore = secureStore;
initCache(walletId, coin);
initWalletDB(mockableOverride: mockableOverride);
initPaynymWalletInterface(
walletId: walletId,
walletName: walletName,
network: _network,
coin: coin,
db: db,
electrumXClient: electrumXClient,
secureStorage: secureStore,
getMnemonicString: () => mnemonicString,
getMnemonicPassphrase: () => mnemonicPassphrase,
getChainHeight: () => chainHeight,
getCurrentChangeAddress: () => currentChangeAddressP2PKH,
estimateTxFee: estimateTxFee,
prepareSend: prepareSend,
getTxCount: getTxCount,
fetchBuildTxData: fetchBuildTxData,
refresh: refresh,
checkChangeAddressForTransactions:
_checkP2PKHChangeAddressForTransactions,
addDerivation: addDerivation,
dustLimitP2PKH: DUST_LIMIT_P2PKH,
minConfirms: MINIMUM_CONFIRMATIONS,
);
}
@override
Future<void> updateNode(bool shouldRefresh) async {
final failovers = NodeService(secureStorageInterface: _secureStore)

View file

@ -89,6 +89,27 @@ String constructDerivePath({
}
class BitcoinCashWallet extends CoinServiceAPI with WalletCache, WalletDB {
BitcoinCashWallet({
required String walletId,
required String walletName,
required Coin coin,
required ElectrumX client,
required CachedElectrumX cachedClient,
required TransactionNotificationTracker tracker,
required SecureStorageInterface secureStore,
MainDB? mockableOverride,
}) {
txTracker = tracker;
_walletId = walletId;
_walletName = walletName;
_coin = coin;
_electrumXClient = client;
_cachedElectrumXClient = cachedClient;
_secureStore = secureStore;
initCache(walletId, coin);
initWalletDB(mockableOverride: mockableOverride);
}
static const integrationTestFlag =
bool.fromEnvironment("IS_INTEGRATION_TEST");
final _prefs = Prefs.instance;
@ -1266,27 +1287,6 @@ class BitcoinCashWallet extends CoinServiceAPI with WalletCache, WalletDB {
late SecureStorageInterface _secureStore;
BitcoinCashWallet({
required String walletId,
required String walletName,
required Coin coin,
required ElectrumX client,
required CachedElectrumX cachedClient,
required TransactionNotificationTracker tracker,
required SecureStorageInterface secureStore,
MainDB? mockableOverride,
}) {
txTracker = tracker;
_walletId = walletId;
_walletName = walletName;
_coin = coin;
_electrumXClient = client;
_cachedElectrumXClient = cachedClient;
_secureStore = secureStore;
initCache(walletId, coin);
initWalletDB(mockableOverride: mockableOverride);
}
@override
Future<void> updateNode(bool shouldRefresh) async {
final failovers = NodeService(secureStorageInterface: _secureStore)

View file

@ -86,6 +86,48 @@ String constructDerivePath({
class DogecoinWallet extends CoinServiceAPI
with WalletCache, WalletDB, ElectrumXParsing {
DogecoinWallet({
required String walletId,
required String walletName,
required Coin coin,
required ElectrumX client,
required CachedElectrumX cachedClient,
required TransactionNotificationTracker tracker,
required SecureStorageInterface secureStore,
MainDB? mockableOverride,
}) {
txTracker = tracker;
_walletId = walletId;
_walletName = walletName;
_coin = coin;
_electrumXClient = client;
_cachedElectrumXClient = cachedClient;
_secureStore = secureStore;
initCache(walletId, coin);
initWalletDB(mockableOverride: mockableOverride);
// paynym stuff
// initPaynymWalletInterface(
// walletId: walletId,
// walletName: walletName,
// network: network,
// coin: coin,
// db: db,
// electrumXClient: electrumXClient,
// getMnemonic: () => mnemonic,
// getChainHeight: () => chainHeight,
// getCurrentChangeAddress: () => currentChangeAddress,
// estimateTxFee: estimateTxFee,
// prepareSend: prepareSend,
// getTxCount: getTxCount,
// fetchBuildTxData: fetchBuildTxData,
// refresh: refresh,
// checkChangeAddressForTransactions: checkChangeAddressForTransactions,
// addDerivation: addDerivation,
// addDerivations: addDerivations,
// );
}
static const integrationTestFlag =
bool.fromEnvironment("IS_INTEGRATION_TEST");
final _prefs = Prefs.instance;
@ -1093,48 +1135,6 @@ class DogecoinWallet extends CoinServiceAPI
late SecureStorageInterface _secureStore;
DogecoinWallet({
required String walletId,
required String walletName,
required Coin coin,
required ElectrumX client,
required CachedElectrumX cachedClient,
required TransactionNotificationTracker tracker,
required SecureStorageInterface secureStore,
MainDB? mockableOverride,
}) {
txTracker = tracker;
_walletId = walletId;
_walletName = walletName;
_coin = coin;
_electrumXClient = client;
_cachedElectrumXClient = cachedClient;
_secureStore = secureStore;
initCache(walletId, coin);
initWalletDB(mockableOverride: mockableOverride);
// paynym stuff
// initPaynymWalletInterface(
// walletId: walletId,
// walletName: walletName,
// network: network,
// coin: coin,
// db: db,
// electrumXClient: electrumXClient,
// getMnemonic: () => mnemonic,
// getChainHeight: () => chainHeight,
// getCurrentChangeAddress: () => currentChangeAddress,
// estimateTxFee: estimateTxFee,
// prepareSend: prepareSend,
// getTxCount: getTxCount,
// fetchBuildTxData: fetchBuildTxData,
// refresh: refresh,
// checkChangeAddressForTransactions: checkChangeAddressForTransactions,
// addDerivation: addDerivation,
// addDerivations: addDerivations,
// );
}
@override
Future<void> updateNode(bool shouldRefresh) async {
final failovers = NodeService(secureStorageInterface: _secureStore)

View file

@ -520,15 +520,6 @@ Future<dynamic> deleteSlate(
class EpicCashWallet extends CoinServiceAPI
with WalletCache, WalletDB, EpicCashHive {
static const integrationTestFlag =
bool.fromEnvironment("IS_INTEGRATION_TEST");
final m = Mutex();
final syncMutex = Mutex();
final _prefs = Prefs.instance;
NodeModel? _epicNode;
EpicCashWallet({
required String walletId,
required String walletName,
@ -552,6 +543,15 @@ class EpicCashWallet extends CoinServiceAPI
isolates.clear();
}
static const integrationTestFlag =
bool.fromEnvironment("IS_INTEGRATION_TEST");
final m = Mutex();
final syncMutex = Mutex();
final _prefs = Prefs.instance;
NodeModel? _epicNode;
@override
Future<void> updateNode(bool shouldRefresh) async {
_epicNode = NodeService(secureStorageInterface: _secureStore)

View file

@ -772,6 +772,37 @@ Future<void> _setTestnetWrapper(bool isTestnet) async {
/// Handles a single instance of a firo wallet
class FiroWallet extends CoinServiceAPI with WalletCache, WalletDB, FiroHive {
// Constructor
FiroWallet({
required String walletId,
required String walletName,
required Coin coin,
required ElectrumX client,
required CachedElectrumX cachedClient,
required TransactionNotificationTracker tracker,
required SecureStorageInterface secureStore,
MainDB? mockableOverride,
}) {
txTracker = tracker;
_walletId = walletId;
_walletName = walletName;
_coin = coin;
_electrumXClient = client;
_cachedElectrumXClient = cachedClient;
_secureStore = secureStore;
initCache(walletId, coin);
initFiroHive(walletId);
initWalletDB(mockableOverride: mockableOverride);
Logging.instance.log("$walletName isolates length: ${isolates.length}",
level: LogLevel.Info);
// investigate possible issues killing shared isolates between multiple firo instances
for (final isolate in isolates.values) {
isolate.kill(priority: Isolate.immediate);
}
isolates.clear();
}
static const integrationTestFlag =
bool.fromEnvironment("IS_INTEGRATION_TEST");
@ -1238,37 +1269,6 @@ class FiroWallet extends CoinServiceAPI with WalletCache, WalletDB, FiroHive {
late TransactionNotificationTracker txTracker;
// Constructor
FiroWallet({
required String walletId,
required String walletName,
required Coin coin,
required ElectrumX client,
required CachedElectrumX cachedClient,
required TransactionNotificationTracker tracker,
required SecureStorageInterface secureStore,
MainDB? mockableOverride,
}) {
txTracker = tracker;
_walletId = walletId;
_walletName = walletName;
_coin = coin;
_electrumXClient = client;
_cachedElectrumXClient = cachedClient;
_secureStore = secureStore;
initCache(walletId, coin);
initFiroHive(walletId);
initWalletDB(mockableOverride: mockableOverride);
Logging.instance.log("$walletName isolates length: ${isolates.length}",
level: LogLevel.Info);
// investigate possible issues killing shared isolates between multiple firo instances
for (final isolate in isolates.values) {
isolate.kill(priority: Isolate.immediate);
}
isolates.clear();
}
int estimateTxFee({required int vSize, required int feeRatePerKB}) {
return vSize * (feeRatePerKB / 1000).ceil();
}

View file

@ -91,6 +91,27 @@ String constructDerivePath({
class LitecoinWallet extends CoinServiceAPI
with WalletCache, WalletDB, ElectrumXParsing {
LitecoinWallet({
required String walletId,
required String walletName,
required Coin coin,
required ElectrumX client,
required CachedElectrumX cachedClient,
required TransactionNotificationTracker tracker,
required SecureStorageInterface secureStore,
MainDB? mockableOverride,
}) {
txTracker = tracker;
_walletId = walletId;
_walletName = walletName;
_coin = coin;
_electrumXClient = client;
_cachedElectrumXClient = cachedClient;
_secureStore = secureStore;
initCache(walletId, coin);
initWalletDB(mockableOverride: mockableOverride);
}
static const integrationTestFlag =
bool.fromEnvironment("IS_INTEGRATION_TEST");
@ -1242,26 +1263,7 @@ class LitecoinWallet extends CoinServiceAPI
late SecureStorageInterface _secureStore;
LitecoinWallet({
required String walletId,
required String walletName,
required Coin coin,
required ElectrumX client,
required CachedElectrumX cachedClient,
required TransactionNotificationTracker tracker,
required SecureStorageInterface secureStore,
MainDB? mockableOverride,
}) {
txTracker = tracker;
_walletId = walletId;
_walletName = walletName;
_coin = coin;
_electrumXClient = client;
_cachedElectrumXClient = cachedClient;
_secureStore = secureStore;
initCache(walletId, coin);
initWalletDB(mockableOverride: mockableOverride);
}
@override
Future<void> updateNode(bool shouldRefresh) async {

View file

@ -52,6 +52,23 @@ import 'package:tuple/tuple.dart';
const int MINIMUM_CONFIRMATIONS = 10;
class MoneroWallet extends CoinServiceAPI with WalletCache, WalletDB {
MoneroWallet({
required String walletId,
required String walletName,
required Coin coin,
required SecureStorageInterface secureStorage,
Prefs? prefs,
MainDB? mockableOverride,
}) {
_walletId = walletId;
_walletName = walletName;
_coin = coin;
_secureStorage = secureStorage;
_prefs = prefs ?? Prefs.instance;
initCache(walletId, coin);
initWalletDB(mockableOverride: mockableOverride);
}
late final String _walletId;
late final Coin _coin;
late final SecureStorageInterface _secureStorage;
@ -78,23 +95,6 @@ class MoneroWallet extends CoinServiceAPI with WalletCache, WalletDB {
Mutex prepareSendMutex = Mutex();
Mutex estimateFeeMutex = Mutex();
MoneroWallet({
required String walletId,
required String walletName,
required Coin coin,
required SecureStorageInterface secureStorage,
Prefs? prefs,
MainDB? mockableOverride,
}) {
_walletId = walletId;
_walletName = walletName;
_coin = coin;
_secureStorage = secureStorage;
_prefs = prefs ?? Prefs.instance;
initCache(walletId, coin);
initWalletDB(mockableOverride: mockableOverride);
}
@override
set isFavorite(bool markFavorite) {
_isFavorite = markFavorite;

View file

@ -88,6 +88,27 @@ String constructDerivePath({
class NamecoinWallet extends CoinServiceAPI
with WalletCache, WalletDB, ElectrumXParsing {
NamecoinWallet({
required String walletId,
required String walletName,
required Coin coin,
required ElectrumX client,
required CachedElectrumX cachedClient,
required TransactionNotificationTracker tracker,
required SecureStorageInterface secureStore,
MainDB? mockableOverride,
}) {
txTracker = tracker;
_walletId = walletId;
_walletName = walletName;
_coin = coin;
_electrumXClient = client;
_cachedElectrumXClient = cachedClient;
_secureStore = secureStore;
initCache(walletId, coin);
initWalletDB(mockableOverride: mockableOverride);
}
static const integrationTestFlag =
bool.fromEnvironment("IS_INTEGRATION_TEST");
@ -1232,27 +1253,6 @@ class NamecoinWallet extends CoinServiceAPI
late SecureStorageInterface _secureStore;
NamecoinWallet({
required String walletId,
required String walletName,
required Coin coin,
required ElectrumX client,
required CachedElectrumX cachedClient,
required TransactionNotificationTracker tracker,
required SecureStorageInterface secureStore,
MainDB? mockableOverride,
}) {
txTracker = tracker;
_walletId = walletId;
_walletName = walletName;
_coin = coin;
_electrumXClient = client;
_cachedElectrumXClient = cachedClient;
_secureStore = secureStore;
initCache(walletId, coin);
initWalletDB(mockableOverride: mockableOverride);
}
@override
Future<void> updateNode(bool shouldRefresh) async {
final failovers = NodeService(secureStorageInterface: _secureStore)

View file

@ -82,6 +82,27 @@ String constructDerivePath({
}
class ParticlWallet extends CoinServiceAPI with WalletCache, WalletDB {
ParticlWallet({
required String walletId,
required String walletName,
required Coin coin,
required ElectrumX client,
required CachedElectrumX cachedClient,
required TransactionNotificationTracker tracker,
required SecureStorageInterface secureStore,
MainDB? mockableOverride,
}) {
txTracker = tracker;
_walletId = walletId;
_walletName = walletName;
_coin = coin;
_electrumXClient = client;
_cachedElectrumXClient = cachedClient;
_secureStore = secureStore;
initCache(walletId, coin);
initWalletDB(mockableOverride: mockableOverride);
}
static const integrationTestFlag =
bool.fromEnvironment("IS_INTEGRATION_TEST");
@ -1159,27 +1180,6 @@ class ParticlWallet extends CoinServiceAPI with WalletCache, WalletDB {
late SecureStorageInterface _secureStore;
ParticlWallet({
required String walletId,
required String walletName,
required Coin coin,
required ElectrumX client,
required CachedElectrumX cachedClient,
required TransactionNotificationTracker tracker,
required SecureStorageInterface secureStore,
MainDB? mockableOverride,
}) {
txTracker = tracker;
_walletId = walletId;
_walletName = walletName;
_coin = coin;
_electrumXClient = client;
_cachedElectrumXClient = cachedClient;
_secureStore = secureStore;
initCache(walletId, coin);
initWalletDB(mockableOverride: mockableOverride);
}
@override
Future<void> updateNode(bool shouldRefresh) async {
final failovers = NodeService(secureStorageInterface: _secureStore)

View file

@ -54,6 +54,23 @@ import 'package:tuple/tuple.dart';
const int MINIMUM_CONFIRMATIONS = 10;
class WowneroWallet extends CoinServiceAPI with WalletCache, WalletDB {
WowneroWallet({
required String walletId,
required String walletName,
required Coin coin,
required SecureStorageInterface secureStorage,
Prefs? prefs,
MainDB? mockableOverride,
}) {
_walletId = walletId;
_walletName = walletName;
_coin = coin;
_secureStorage = secureStorage;
_prefs = prefs ?? Prefs.instance;
initCache(walletId, coin);
initWalletDB(mockableOverride: mockableOverride);
}
late final String _walletId;
late final Coin _coin;
late final SecureStorageInterface _secureStorage;
@ -80,23 +97,6 @@ class WowneroWallet extends CoinServiceAPI with WalletCache, WalletDB {
Mutex prepareSendMutex = Mutex();
Mutex estimateFeeMutex = Mutex();
WowneroWallet({
required String walletId,
required String walletName,
required Coin coin,
required SecureStorageInterface secureStorage,
Prefs? prefs,
MainDB? mockableOverride,
}) {
_walletId = walletId;
_walletName = walletName;
_coin = coin;
_secureStorage = secureStorage;
_prefs = prefs ?? Prefs.instance;
initCache(walletId, coin);
initWalletDB(mockableOverride: mockableOverride);
}
@override
set isFavorite(bool markFavorite) {
_isFavorite = markFavorite;