Merge pull request #718 from cypherstack/wallets_refactor

Wallets refactor
This commit is contained in:
julian-CStack 2024-01-16 19:26:30 -06:00 committed by GitHub
commit d521188783
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
30 changed files with 309 additions and 5633 deletions

View file

@ -111,7 +111,7 @@ class _ConfirmChangeNowSendViewState
try {
if (wallet is FiroWallet && widget.shouldSendPublicFiroFunds == false) {
txidFuture = wallet.confirmSendLelantus(txData: widget.txData);
txidFuture = wallet.confirmSendSpark(txData: widget.txData);
} else {
txidFuture = wallet.confirmSend(txData: widget.txData);
}

View file

@ -224,8 +224,10 @@ class _Step2ViewState extends ConsumerState<Step2View> {
_toController.text = wallet.info.name;
model.recipientAddress = (await wallet
.getCurrentReceivingAddress())!
.value;
.getCurrentReceivingAddress())
?.value ??
wallet
.info.cachedReceivingAddress;
setState(() {
enableNext =

View file

@ -241,10 +241,8 @@ class _Step4ViewState extends ConsumerState<Step4View> {
Future<TxData> txDataFuture;
// TODO: [prio=high] Firo spark
if (wallet is FiroWallet && !firoPublicSend) {
txDataFuture = wallet.prepareSendLelantus(
txDataFuture = wallet.prepareSendSpark(
txData: TxData(
recipients: [
(

View file

@ -287,7 +287,8 @@ class _SendFromCardState extends ConsumerState<SendFromCard> {
recipients: [
(
address: address,
amount: amount, isChange: false,
amount: amount,
isChange: false,
),
],
memo: memo,
@ -303,19 +304,21 @@ class _SendFromCardState extends ConsumerState<SendFromCard> {
recipients: [
(
address: address,
amount: amount, isChange: false,
amount: amount,
isChange: false,
),
],
feeRateType: FeeRateType.average,
),
);
} else {
txDataFuture = firoWallet.prepareSendLelantus(
txDataFuture = firoWallet.prepareSendSpark(
txData: TxData(
recipients: [
(
address: address,
amount: amount, isChange: false,
amount: amount,
isChange: false,
),
],
// feeRateType: FeeRateType.average,
@ -481,7 +484,7 @@ class _SendFromCardState extends ConsumerState<SendFromCard> {
),
Text(
ref.watch(pAmountFormatter(coin)).format(ref
.watch(pWalletBalance(walletId))
.watch(pWalletBalanceTertiary(walletId))
.spendable),
style: STextStyles.itemSubtitle(context),
),
@ -543,8 +546,7 @@ class _SendFromCardState extends ConsumerState<SendFromCard> {
Text(
ref.watch(pAmountFormatter(coin)).format(
ref
.watch(
pWalletBalanceSecondary(walletId))
.watch(pWalletBalance(walletId))
.spendable,
),
style: STextStyles.itemSubtitle(context),

View file

@ -234,7 +234,10 @@ class _DesktopChooseFromStackState
CustomTextButton(
text: "Select wallet",
onTap: () async {
final address = wallet.info.cachedReceivingAddress;
final address =
(await wallet.getCurrentReceivingAddress())
?.value ??
wallet.info.cachedReceivingAddress;
if (mounted) {
Navigator.of(context).pop(

File diff suppressed because it is too large Load diff

View file

@ -1,227 +0,0 @@
// import 'dart:async';
//
// import 'package:bip39/bip39.dart' as bip39;
// import 'package:isar/isar.dart';
// import 'package:stackwallet/db/isar/main_db.dart';
// import 'package:stackwallet/models/balance.dart' as SWBalance;
// import 'package:stackwallet/models/isar/models/blockchain_data/address.dart'
// as SWAddress;
// import 'package:stackwallet/models/isar/models/blockchain_data/transaction.dart'
// as SWTransaction;
// import 'package:stackwallet/models/isar/models/blockchain_data/utxo.dart';
// import 'package:stackwallet/models/node_model.dart';
// import 'package:stackwallet/models/paymint/fee_object_model.dart';
// import 'package:stackwallet/services/coins/coin_service.dart';
// import 'package:stackwallet/services/event_bus/events/global/node_connection_status_changed_event.dart';
// import 'package:stackwallet/services/event_bus/events/global/updated_in_background_event.dart';
// import 'package:stackwallet/services/event_bus/events/global/wallet_sync_status_changed_event.dart';
// import 'package:stackwallet/services/event_bus/global_event_bus.dart';
// import 'package:stackwallet/services/mixins/wallet_cache.dart';
// import 'package:stackwallet/services/mixins/wallet_db.dart';
// import 'package:stackwallet/services/node_service.dart';
// import 'package:stackwallet/services/transaction_notification_tracker.dart';
// import 'package:stackwallet/utilities/amount/amount.dart';
// import 'package:stackwallet/utilities/constants.dart';
// import 'package:stackwallet/utilities/default_nodes.dart';
// import 'package:stackwallet/utilities/enums/coin_enum.dart';
// import 'package:stackwallet/utilities/enums/fee_rate_type_enum.dart';
// import 'package:stackwallet/utilities/flutter_secure_storage_interface.dart';
// import 'package:stackwallet/utilities/logger.dart';
// import 'package:stackwallet/utilities/prefs.dart';
// import 'package:stackwallet/utilities/test_stellar_node_connection.dart';
// import 'package:stellar_flutter_sdk/stellar_flutter_sdk.dart';
// import 'package:tuple/tuple.dart';
//
// const int MINIMUM_CONFIRMATIONS = 1;
//
// class StellarWallet extends CoinServiceAPI with WalletCache, WalletDB {
// late StellarSDK stellarSdk;
// late Network stellarNetwork;
//
// StellarWallet({
// required String walletId,
// required String walletName,
// required Coin coin,
// required TransactionNotificationTracker tracker,
// required SecureStorageInterface secureStore,
// MainDB? mockableOverride,
// }) {
// txTracker = tracker;
// _walletId = walletId;
// _walletName = walletName;
// _coin = coin;
// _secureStore = secureStore;
// initCache(walletId, coin);
// initWalletDB(mockableOverride: mockableOverride);
//
// if (coin.isTestNet) {
// stellarNetwork = Network.TESTNET;
// } else {
// stellarNetwork = Network.PUBLIC;
// }
//
// _updateNode();
// }
//
// Future<void> updateTransactions() async {
// try {
// List<Tuple2<SWTransaction.Transaction, SWAddress.Address?>>
// transactionList = [];
// Page<OperationResponse> payments;
// try {
// payments = await stellarSdk.payments
// .forAccount(await getAddressSW())
// .order(RequestBuilderOrder.DESC)
// .execute()
// .onError((error, stackTrace) => throw error!);
// } catch (e) {
// if (e is ErrorResponse &&
// e.body.contains("The resource at the url requested was not found. "
// "This usually occurs for one of two reasons: "
// "The url requested is not valid, or no data in our database "
// "could be found with the parameters provided.")) {
// // probably just doesn't have any history yet or whatever stellar needs
// return;
// } else {
// Logging.instance.log(
// "Stellar $walletName $walletId failed to fetch transactions",
// level: LogLevel.Warning,
// );
// rethrow;
// }
// }
// for (OperationResponse response in payments.records!) {
// // PaymentOperationResponse por;
// if (response is PaymentOperationResponse) {
// PaymentOperationResponse por = response;
//
// SWTransaction.TransactionType type;
// if (por.sourceAccount == await getAddressSW()) {
// type = SWTransaction.TransactionType.outgoing;
// } else {
// type = SWTransaction.TransactionType.incoming;
// }
// final amount = Amount(
// rawValue: BigInt.parse(float
// .parse(por.amount!)
// .toStringAsFixed(coin.decimals)
// .replaceAll(".", "")),
// fractionDigits: coin.decimals,
// );
// int fee = 0;
// int height = 0;
// //Query the transaction linked to the payment,
// // por.transaction returns a null sometimes
// TransactionResponse tx =
// await stellarSdk.transactions.transaction(por.transactionHash!);
//
// if (tx.hash.isNotEmpty) {
// fee = tx.feeCharged!;
// height = tx.ledger;
// }
// var theTransaction = SWTransaction.Transaction(
// walletId: walletId,
// txid: por.transactionHash!,
// timestamp:
// DateTime.parse(por.createdAt!).millisecondsSinceEpoch ~/ 1000,
// type: type,
// subType: SWTransaction.TransactionSubType.none,
// amount: 0,
// amountString: amount.toJsonString(),
// fee: fee,
// height: height,
// isCancelled: false,
// isLelantus: false,
// slateId: "",
// otherData: "",
// inputs: [],
// outputs: [],
// nonce: 0,
// numberOfMessages: null,
// );
// SWAddress.Address? receivingAddress = await _currentReceivingAddress;
// SWAddress.Address address =
// type == SWTransaction.TransactionType.incoming
// ? receivingAddress!
// : SWAddress.Address(
// walletId: walletId,
// value: por.sourceAccount!,
// publicKey:
// KeyPair.fromAccountId(por.sourceAccount!).publicKey,
// derivationIndex: 0,
// derivationPath: null,
// type: SWAddress.AddressType.unknown, // TODO: set type
// subType: SWAddress.AddressSubType.unknown);
// Tuple2<SWTransaction.Transaction, SWAddress.Address> tuple =
// Tuple2(theTransaction, address);
// transactionList.add(tuple);
// } else if (response is CreateAccountOperationResponse) {
// CreateAccountOperationResponse caor = response;
// SWTransaction.TransactionType type;
// if (caor.sourceAccount == await getAddressSW()) {
// type = SWTransaction.TransactionType.outgoing;
// } else {
// type = SWTransaction.TransactionType.incoming;
// }
// final amount = Amount(
// rawValue: BigInt.parse(float
// .parse(caor.startingBalance!)
// .toStringAsFixed(coin.decimals)
// .replaceAll(".", "")),
// fractionDigits: coin.decimals,
// );
// int fee = 0;
// int height = 0;
// TransactionResponse tx =
// await stellarSdk.transactions.transaction(caor.transactionHash!);
// if (tx.hash.isNotEmpty) {
// fee = tx.feeCharged!;
// height = tx.ledger;
// }
// var theTransaction = SWTransaction.Transaction(
// walletId: walletId,
// txid: caor.transactionHash!,
// timestamp:
// DateTime.parse(caor.createdAt!).millisecondsSinceEpoch ~/ 1000,
// type: type,
// subType: SWTransaction.TransactionSubType.none,
// amount: 0,
// amountString: amount.toJsonString(),
// fee: fee,
// height: height,
// isCancelled: false,
// isLelantus: false,
// slateId: "",
// otherData: "",
// inputs: [],
// outputs: [],
// nonce: 0,
// numberOfMessages: null,
// );
// SWAddress.Address? receivingAddress = await _currentReceivingAddress;
// SWAddress.Address address =
// type == SWTransaction.TransactionType.incoming
// ? receivingAddress!
// : SWAddress.Address(
// walletId: walletId,
// value: caor.sourceAccount!,
// publicKey:
// KeyPair.fromAccountId(caor.sourceAccount!).publicKey,
// derivationIndex: 0,
// derivationPath: null,
// type: SWAddress.AddressType.unknown, // TODO: set type
// subType: SWAddress.AddressSubType.unknown);
// Tuple2<SWTransaction.Transaction, SWAddress.Address> tuple =
// Tuple2(theTransaction, address);
// transactionList.add(tuple);
// }
// }
// await db.addNewTransactionData(transactionList, walletId);
// } catch (e, s) {
// Logging.instance.log(
// "Exception rethrown from updateTransactions(): $e\n$s",
// level: LogLevel.Error);
// rethrow;
// }
// }
// }

View file

@ -1,375 +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 'dart:convert';
import 'package:bip47/src/util.dart';
import 'package:decimal/decimal.dart';
import 'package:stackwallet/electrumx_rpc/cached_electrumx_client.dart';
import 'package:stackwallet/models/isar/models/blockchain_data/v2/input_v2.dart';
import 'package:stackwallet/models/isar/models/blockchain_data/v2/output_v2.dart';
import 'package:stackwallet/models/isar/models/blockchain_data/v2/transaction_v2.dart';
import 'package:stackwallet/models/isar/models/isar_models.dart';
import 'package:stackwallet/utilities/amount/amount.dart';
import 'package:stackwallet/utilities/enums/coin_enum.dart';
import 'package:stackwallet/utilities/util.dart' as util;
import 'package:stackwallet/wallets/wallet/wallet_mixin_interfaces/paynym_interface.dart';
import 'package:tuple/tuple.dart';
mixin ElectrumXParsing {
Future<TransactionV2> getTransaction(
String txHash,
Coin coin,
String walletId,
CachedElectrumXClient cachedElectrumX, [
String? debugTitle,
]) async {
final jsonTx = await cachedElectrumX.getTransaction(
txHash: txHash,
coin: coin,
);
print("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++");
util.Util.printJson(jsonTx, debugTitle);
print("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++");
// parse inputs
final List<InputV2> inputs = [];
for (final jsonInput in jsonTx["vin"] as List) {
final map = Map<String, dynamic>.from(jsonInput as Map);
final List<String> addresses = [];
String valueStringSats = "0";
OutpointV2? outpoint;
final coinbase = map["coinbase"] as String?;
if (coinbase == null) {
final txid = map["txid"] as String;
final vout = map["vout"] as int;
final inputTx =
await cachedElectrumX.getTransaction(txHash: txid, coin: coin);
final prevOutJson = Map<String, dynamic>.from(
(inputTx["vout"] as List).firstWhere((e) => e["n"] == vout) as Map);
final prevOut = OutputV2.fromElectrumXJson(
prevOutJson,
decimalPlaces: coin.decimals,
walletOwns: false,
);
outpoint = OutpointV2.isarCantDoRequiredInDefaultConstructor(
txid: txid,
vout: vout,
);
valueStringSats = prevOut.valueStringSats;
addresses.addAll(prevOut.addresses);
}
final input = InputV2.isarCantDoRequiredInDefaultConstructor(
scriptSigHex: map["scriptSig"]?["hex"] as String?,
scriptSigAsm: map["scriptSig"]?["asm"] as String?,
sequence: map["sequence"] as int?,
outpoint: outpoint,
valueStringSats: valueStringSats,
addresses: addresses,
witness: map["witness"] as String?,
coinbase: coinbase,
innerRedeemScriptAsm: map["innerRedeemscriptAsm"] as String?,
walletOwns: false,
);
inputs.add(input);
}
// parse outputs
final List<OutputV2> outputs = [];
for (final outputJson in jsonTx["vout"] as List) {
final output = OutputV2.fromElectrumXJson(
Map<String, dynamic>.from(outputJson as Map),
decimalPlaces: coin.decimals,
walletOwns: false,
);
outputs.add(output);
}
return TransactionV2(
walletId: walletId,
blockHash: jsonTx["blockhash"] as String?,
hash: jsonTx["hash"] as String,
txid: jsonTx["txid"] as String,
height: jsonTx["height"] as int?,
version: jsonTx["version"] as int,
timestamp: jsonTx["blocktime"] as int? ??
DateTime.timestamp().millisecondsSinceEpoch ~/ 1000,
inputs: List.unmodifiable(inputs),
outputs: List.unmodifiable(outputs),
subType: TransactionSubType.none,
type: TransactionType.unknown,
otherData: null,
);
}
Future<Tuple2<Transaction, Address>> parseTransaction(
Map<String, dynamic> txData,
dynamic electrumxClient,
List<Address> myAddresses,
Coin coin,
int minConfirms,
String walletId,
) async {
Set<String> receivingAddresses = myAddresses
.where((e) =>
e.subType == AddressSubType.receiving ||
e.subType == AddressSubType.paynymReceive ||
e.subType == AddressSubType.paynymNotification)
.map((e) => e.value)
.toSet();
Set<String> changeAddresses = myAddresses
.where((e) => e.subType == AddressSubType.change)
.map((e) => e.value)
.toSet();
Set<String> inputAddresses = {};
Set<String> outputAddresses = {};
Amount totalInputValue = Amount(
rawValue: BigInt.zero,
fractionDigits: coin.decimals,
);
Amount totalOutputValue = Amount(
rawValue: BigInt.zero,
fractionDigits: coin.decimals,
);
Amount amountSentFromWallet = Amount(
rawValue: BigInt.zero,
fractionDigits: coin.decimals,
);
Amount amountReceivedInWallet = Amount(
rawValue: BigInt.zero,
fractionDigits: coin.decimals,
);
Amount changeAmount = Amount(
rawValue: BigInt.zero,
fractionDigits: coin.decimals,
);
// parse inputs
for (final input in txData["vin"] as List) {
final prevTxid = input["txid"] as String;
final prevOut = input["vout"] as int;
// fetch input tx to get address
final inputTx = await electrumxClient.getTransaction(
txHash: prevTxid,
coin: coin,
);
for (final output in inputTx["vout"] as List) {
// check matching output
if (prevOut == output["n"]) {
// get value
final value = Amount.fromDecimal(
Decimal.parse(output["value"].toString()),
fractionDigits: coin.decimals,
);
// add value to total
totalInputValue += value;
// get input(prevOut) address
final address = output["scriptPubKey"]?["addresses"]?[0] as String? ??
output["scriptPubKey"]?["address"] as String?;
if (address != null) {
inputAddresses.add(address);
// if input was from my wallet, add value to amount sent
if (receivingAddresses.contains(address) ||
changeAddresses.contains(address)) {
amountSentFromWallet += value;
}
}
}
}
}
// parse outputs
for (final output in txData["vout"] as List) {
// get value
final value = Amount.fromDecimal(
Decimal.parse(output["value"].toString()),
fractionDigits: coin.decimals,
);
// add value to total
totalOutputValue += value;
// get output address
final address = output["scriptPubKey"]?["addresses"]?[0] as String? ??
output["scriptPubKey"]?["address"] as String?;
if (address != null) {
outputAddresses.add(address);
// if output was to my wallet, add value to amount received
if (receivingAddresses.contains(address)) {
amountReceivedInWallet += value;
} else if (changeAddresses.contains(address)) {
changeAmount += value;
}
}
}
final mySentFromAddresses = [
...receivingAddresses.intersection(inputAddresses),
...changeAddresses.intersection(inputAddresses)
];
final myReceivedOnAddresses =
receivingAddresses.intersection(outputAddresses);
final myChangeReceivedOnAddresses =
changeAddresses.intersection(outputAddresses);
final fee = totalInputValue - totalOutputValue;
// this is the address initially used to fetch the txid
Address transactionAddress = txData["address"] as Address;
TransactionType type;
Amount amount;
if (mySentFromAddresses.isNotEmpty && myReceivedOnAddresses.isNotEmpty) {
// tx is sent to self
type = TransactionType.sentToSelf;
// should be 0
amount =
amountSentFromWallet - amountReceivedInWallet - fee - changeAmount;
} else if (mySentFromAddresses.isNotEmpty) {
// outgoing tx
type = TransactionType.outgoing;
amount = amountSentFromWallet - changeAmount - fee;
// non wallet addresses found in tx outputs
final nonWalletOutAddresses = outputAddresses.difference(
myChangeReceivedOnAddresses,
);
if (nonWalletOutAddresses.isNotEmpty) {
final possible = nonWalletOutAddresses.first;
if (transactionAddress.value != possible) {
transactionAddress = Address(
walletId: walletId,
value: possible,
derivationIndex: -1,
derivationPath: null,
subType: AddressSubType.nonWallet,
type: AddressType.nonWallet,
publicKey: [],
);
}
} else {
// some other type of tx where the receiving address is
// one of my change addresses
type = TransactionType.sentToSelf;
amount = changeAmount;
}
} else {
// incoming tx
type = TransactionType.incoming;
amount = amountReceivedInWallet;
}
List<Output> outs = [];
List<Input> ins = [];
for (final json in txData["vin"] as List) {
bool isCoinBase = json['coinbase'] != null;
String? witness;
if (json['witness'] != null && json['witness'] is String) {
witness = json['witness'] as String;
} else if (json['txinwitness'] != null) {
if (json['txinwitness'] is List) {
witness = jsonEncode(json['txinwitness']);
}
}
final input = Input(
txid: json['txid'] as String,
vout: json['vout'] as int? ?? -1,
scriptSig: json['scriptSig']?['hex'] as String?,
scriptSigAsm: json['scriptSig']?['asm'] as String?,
isCoinbase: isCoinBase ? isCoinBase : json['is_coinbase'] as bool?,
sequence: json['sequence'] as int?,
innerRedeemScriptAsm: json['innerRedeemscriptAsm'] as String?,
witness: witness,
);
ins.add(input);
}
for (final json in txData["vout"] as List) {
final output = Output(
scriptPubKey: json['scriptPubKey']?['hex'] as String?,
scriptPubKeyAsm: json['scriptPubKey']?['asm'] as String?,
scriptPubKeyType: json['scriptPubKey']?['type'] as String?,
scriptPubKeyAddress:
json["scriptPubKey"]?["addresses"]?[0] as String? ??
json['scriptPubKey']?['type'] as String? ??
"",
value: Amount.fromDecimal(
Decimal.parse(json["value"].toString()),
fractionDigits: coin.decimals,
).raw.toInt(),
);
outs.add(output);
}
TransactionSubType txSubType = TransactionSubType.none;
if (this is PaynymInterface && outs.length > 1 && ins.isNotEmpty) {
for (int i = 0; i < outs.length; i++) {
List<String>? scriptChunks = outs[i].scriptPubKeyAsm?.split(" ");
if (scriptChunks?.length == 2 && scriptChunks?[0] == "OP_RETURN") {
final blindedPaymentCode = scriptChunks![1];
final bytes = blindedPaymentCode.fromHex;
// https://en.bitcoin.it/wiki/BIP_0047#Sending
if (bytes.length == 80 && bytes.first == 1) {
txSubType = TransactionSubType.bip47Notification;
}
}
}
}
final tx = Transaction(
walletId: walletId,
txid: txData["txid"] as String,
timestamp: txData["blocktime"] as int? ??
(DateTime.now().millisecondsSinceEpoch ~/ 1000),
type: type,
subType: txSubType,
// amount may overflow. Deprecated. Use amountString
amount: amount.raw.toInt(),
amountString: amount.toJsonString(),
fee: fee.raw.toInt(),
height: txData["height"] as int?,
isCancelled: false,
isLelantus: false,
slateId: null,
otherData: null,
nonce: null,
inputs: ins,
outputs: outs,
numberOfMessages: null,
);
return Tuple2(tx, transactionAddress);
}
}

View file

@ -486,7 +486,7 @@ class EpiccashWallet extends Bip39Wallet {
@override
Future<void> checkSaveInitialReceivingAddress() async {
// epiccash seems ok with nothing here?
// epiccash seems ok with nothing here?
}
@override
@ -946,7 +946,7 @@ class EpiccashWallet extends Bip39Wallet {
final slatesToCommits = info.epicData?.slatesToCommits ?? {};
for (final tx in transactions) {
// Logging.instance.log("tx: $tx", level: LogLevel.Info);
Logging.instance.log("tx: $tx", level: LogLevel.Info);
final isIncoming =
tx.txType == epic_models.TransactionType.TxReceived ||
@ -1043,7 +1043,13 @@ class EpiccashWallet extends Bip39Wallet {
txns.add(txn);
}
await mainDB.updateOrPutTransactionV2s(txns);
await mainDB.isar.writeTxn(() async {
await mainDB.isar.transactionV2s
.where()
.walletIdEqualTo(walletId)
.deleteAll();
await mainDB.isar.transactionV2s.putAll(txns);
});
} catch (e, s) {
Logging.instance.log(
"${cryptoCurrency.runtimeType} ${cryptoCurrency.network} net wallet"

View file

@ -33,7 +33,7 @@ class EthereumWallet extends Bip39Wallet with PrivateKeyInterface {
EthereumWallet(CryptoCurrencyNetwork network) : super(Ethereum(network));
Timer? timer;
late web3.EthPrivateKey _credentials;
web3.EthPrivateKey? _credentials;
Future<void> updateTokenContracts(List<String> contractAddresses) async {
await info.updateContractAddresses(
@ -78,11 +78,10 @@ class EthereumWallet extends Bip39Wallet with PrivateKeyInterface {
// ==================== Private ==============================================
Future<void> _initCredentials(
String mnemonic,
String mnemonicPassphrase,
) async {
String privateKey = getPrivateKey(mnemonic, mnemonicPassphrase);
Future<void> _initCredentials() async {
final mnemonic = await getMnemonic();
final mnemonicPassphrase = await getMnemonicPassphrase();
final privateKey = getPrivateKey(mnemonic, mnemonicPassphrase);
_credentials = web3.EthPrivateKey.fromHex(privateKey);
}
@ -111,14 +110,13 @@ class EthereumWallet extends Bip39Wallet with PrivateKeyInterface {
Future<void> checkSaveInitialReceivingAddress() async {
final address = await getCurrentReceivingAddress();
if (address == null) {
await _initCredentials(
await getMnemonic(),
await getMnemonicPassphrase(),
);
if (_credentials == null) {
await _initCredentials();
}
final address = Address(
walletId: walletId,
value: _credentials.address.hexEip55,
value: _credentials!.address.hexEip55,
publicKey: [],
// maybe store address bytes here? seems a waste of space though
derivationIndex: 0,
@ -450,9 +448,12 @@ class EthereumWallet extends Bip39Wallet with PrivateKeyInterface {
@override
Future<TxData> confirmSend({required TxData txData}) async {
final client = getEthClient();
if (_credentials == null) {
await _initCredentials();
}
final txid = await client.sendTransaction(
_credentials,
_credentials!,
txData.web3dartTransaction!,
chainId: txData.chainId!.toInt(),
);

View file

@ -444,22 +444,24 @@ class ParticlWallet extends Bip39HDWallet
return txData.copyWith(
raw: hexString,
vSize: vSize,
tempTx: TransactionV2(
walletId: walletId,
blockHash: null,
hash: builtTx.getId(),
txid: builtTx.getId(),
height: null,
timestamp: DateTime.timestamp().millisecondsSinceEpoch ~/ 1000,
inputs: List.unmodifiable(tempInputs),
outputs: List.unmodifiable(tempOutputs),
version: version,
type: tempOutputs.map((e) => e.walletOwns).fold(true, (p, e) => p &= e)
? TransactionType.sentToSelf
: TransactionType.outgoing,
subType: TransactionSubType.none,
otherData: null,
),
tempTx: null,
// builtTx.getId() requires an isParticl flag as well but the lib does not support that yet
// tempTx: TransactionV2(
// walletId: walletId,
// blockHash: null,
// hash: builtTx.getId(),
// txid: builtTx.getId(),
// height: null,
// timestamp: DateTime.timestamp().millisecondsSinceEpoch ~/ 1000,
// inputs: List.unmodifiable(tempInputs),
// outputs: List.unmodifiable(tempOutputs),
// version: version,
// type: tempOutputs.map((e) => e.walletOwns).fold(true, (p, e) => p &= e)
// ? TransactionType.sentToSelf
// : TransactionType.outgoing,
// subType: TransactionSubType.none,
// otherData: null,
// ),
);
}

View file

@ -68,7 +68,9 @@ abstract class Wallet<T extends CryptoCurrency> {
final refreshMutex = Mutex();
WalletInfo get info => _walletInfo;
late final String _walletId;
WalletInfo get info =>
mainDB.isar.walletInfo.where().walletIdEqualTo(walletId).findFirstSync()!;
bool get isConnected => _isConnected;
bool get shouldAutoSync => _shouldAutoSync;
@ -88,9 +90,6 @@ abstract class Wallet<T extends CryptoCurrency> {
// ===== private properties ===========================================
late WalletInfo _walletInfo;
late final Stream<WalletInfo?> _walletInfoStream;
Timer? _periodicRefreshTimer;
Timer? _networkAliveTimer;
@ -106,7 +105,7 @@ abstract class Wallet<T extends CryptoCurrency> {
//============================================================================
// ========== Wallet Info Convenience Getters ================================
String get walletId => info.walletId;
String get walletId => _walletId;
/// Attempt to fetch the most recent chain height.
/// On failure return the last cached height.
@ -223,9 +222,7 @@ abstract class Wallet<T extends CryptoCurrency> {
wallet.secureStorageInterface = ethWallet.secureStorageInterface;
wallet.mainDB = ethWallet.mainDB;
return wallet
.._walletInfo = ethWallet.info
.._watchWalletInfo();
return wallet.._walletId = ethWallet.info.walletId;
}
//============================================================================
@ -275,8 +272,7 @@ abstract class Wallet<T extends CryptoCurrency> {
return wallet
..secureStorageInterface = secureStorageInterface
..mainDB = mainDB
.._walletInfo = walletInfo
.._watchWalletInfo();
.._walletId = walletInfo.walletId;
}
static Wallet _loadWallet({
@ -349,19 +345,6 @@ abstract class Wallet<T extends CryptoCurrency> {
}
}
// listen to changes in db and updated wallet info property as required
void _watchWalletInfo() {
_walletInfoStream = mainDB.isar.walletInfo.watchObject(
_walletInfo.id,
fireImmediately: true,
);
_walletInfoStream.forEach((element) {
if (element != null) {
_walletInfo = element;
}
});
}
void _startNetworkAlivePinging() {
// call once on start right away
_periodicPingCheck();

View file

@ -335,13 +335,15 @@ mixin CwBasedInterface<T extends CryptonoteCurrency> on CryptonoteWallet<T>
Future<void> checkReceivingAddressForTransactions() async {
try {
int highestIndex = -1;
for (var element
in cwWalletBase!.transactionHistory!.transactions!.entries) {
if (element.value.direction == TransactionDirection.incoming) {
int curAddressIndex =
element.value.additionalInfo!['addressIndex'] as int;
if (curAddressIndex > highestIndex) {
highestIndex = curAddressIndex;
final entries = cwWalletBase?.transactionHistory?.transactions?.entries;
if (entries != null) {
for (final element in entries) {
if (element.value.direction == TransactionDirection.incoming) {
int curAddressIndex =
element.value.additionalInfo!['addressIndex'] as int;
if (curAddressIndex > highestIndex) {
highestIndex = curAddressIndex;
}
}
}
}

View file

@ -489,6 +489,7 @@ mixin NanoInterface<T extends NanoCurrency> on Bip39Wallet<T> {
@override
Future<void> updateTransactions() async {
await updateChainHeight();
final receivingAddress =
(_cachedAddress ?? await getCurrentReceivingAddress())!;
final String publicAddress = receivingAddress.value;

View file

@ -1,15 +0,0 @@
import 'package:stackwallet/db/isar/main_db.dart';
import 'package:stackwallet/utilities/flutter_secure_storage_interface.dart';
class WalletsService {
late final SecureStorageInterface _secureStore;
late final MainDB _mainDB;
WalletsService({
required SecureStorageInterface secureStorageInterface,
required MainDB mainDB,
}) {
_secureStore = secureStorageInterface;
_mainDB = mainDB;
}
}

View file

@ -274,8 +274,8 @@ packages:
dependency: "direct overridden"
description:
path: coinlib
ref: f671c4fa93febf2ca155b44f182aa9cd55f5ee50
resolved-ref: f671c4fa93febf2ca155b44f182aa9cd55f5ee50
ref: "376d520b4516d4eb7c3f0bd4b1522f7769f3f2a7"
resolved-ref: "376d520b4516d4eb7c3f0bd4b1522f7769f3f2a7"
url: "https://github.com/cypherstack/coinlib.git"
source: git
version: "1.1.0"
@ -283,8 +283,8 @@ packages:
dependency: "direct main"
description:
path: coinlib_flutter
ref: f671c4fa93febf2ca155b44f182aa9cd55f5ee50
resolved-ref: f671c4fa93febf2ca155b44f182aa9cd55f5ee50
ref: "376d520b4516d4eb7c3f0bd4b1522f7769f3f2a7"
resolved-ref: "376d520b4516d4eb7c3f0bd4b1522f7769f3f2a7"
url: "https://github.com/cypherstack/coinlib.git"
source: git
version: "1.1.0"

View file

@ -172,7 +172,7 @@ dependencies:
git:
url: https://github.com/cypherstack/coinlib.git
path: coinlib_flutter
ref: f671c4fa93febf2ca155b44f182aa9cd55f5ee50
ref: 376d520b4516d4eb7c3f0bd4b1522f7769f3f2a7
dev_dependencies:
flutter_test:
@ -223,12 +223,12 @@ dependency_overrides:
git:
url: https://github.com/cypherstack/coinlib.git
path: coinlib_flutter
ref: f671c4fa93febf2ca155b44f182aa9cd55f5ee50
ref: 376d520b4516d4eb7c3f0bd4b1522f7769f3f2a7
coinlib:
git:
url: https://github.com/cypherstack/coinlib.git
path: coinlib
ref: f671c4fa93febf2ca155b44f182aa9cd55f5ee50
ref: 376d520b4516d4eb7c3f0bd4b1522f7769f3f2a7
# required for dart 3, at least until a fix is merged upstream
wakelock_windows:

View file

@ -2,13 +2,11 @@ import 'package:mockito/annotations.dart';
import 'package:stackwallet/services/locale_service.dart';
import 'package:stackwallet/services/node_service.dart';
import 'package:stackwallet/services/wallets.dart';
import 'package:stackwallet/services/wallets_service.dart';
import 'package:stackwallet/themes/theme_service.dart';
import 'package:stackwallet/utilities/prefs.dart';
@GenerateMocks([
Wallets,
WalletsService,
NodeService,
LocaleService,
ThemeService,

View file

@ -4,23 +4,22 @@
// ignore_for_file: no_leading_underscores_for_library_prefixes
import 'dart:async' as _i10;
import 'dart:typed_data' as _i20;
import 'dart:typed_data' as _i19;
import 'dart:ui' as _i15;
import 'package:mockito/mockito.dart' as _i1;
import 'package:stackwallet/db/isar/main_db.dart' as _i3;
import 'package:stackwallet/models/isar/stack_theme.dart' as _i19;
import 'package:stackwallet/models/node_model.dart' as _i16;
import 'package:stackwallet/models/isar/stack_theme.dart' as _i18;
import 'package:stackwallet/models/node_model.dart' as _i13;
import 'package:stackwallet/networking/http.dart' as _i7;
import 'package:stackwallet/services/locale_service.dart' as _i17;
import 'package:stackwallet/services/locale_service.dart' as _i16;
import 'package:stackwallet/services/node_service.dart' as _i2;
import 'package:stackwallet/services/wallets.dart' as _i9;
import 'package:stackwallet/services/wallets_service.dart' as _i13;
import 'package:stackwallet/themes/theme_service.dart' as _i18;
import 'package:stackwallet/utilities/amount/amount_unit.dart' as _i23;
import 'package:stackwallet/utilities/enums/backup_frequency_type.dart' as _i22;
import 'package:stackwallet/themes/theme_service.dart' as _i17;
import 'package:stackwallet/utilities/amount/amount_unit.dart' as _i22;
import 'package:stackwallet/utilities/enums/backup_frequency_type.dart' as _i21;
import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i14;
import 'package:stackwallet/utilities/enums/sync_type_enum.dart' as _i21;
import 'package:stackwallet/utilities/enums/sync_type_enum.dart' as _i20;
import 'package:stackwallet/utilities/flutter_secure_storage_interface.dart'
as _i6;
import 'package:stackwallet/utilities/prefs.dart' as _i12;
@ -208,6 +207,7 @@ class MockWallets extends _i1.Mock implements _i9.Wallets {
_i10.Future<void> loadAfterStackRestore(
_i12.Prefs? prefs,
List<_i5.Wallet<_i4.CryptoCurrency>>? wallets,
bool? isDesktop,
) =>
(super.noSuchMethod(
Invocation.method(
@ -215,6 +215,7 @@ class MockWallets extends _i1.Mock implements _i9.Wallets {
[
prefs,
wallets,
isDesktop,
],
),
returnValue: _i10.Future<void>.value(),
@ -222,240 +223,6 @@ class MockWallets extends _i1.Mock implements _i9.Wallets {
) as _i10.Future<void>);
}
/// A class which mocks [WalletsService].
///
/// See the documentation for Mockito's code generation for more information.
class MockWalletsService extends _i1.Mock implements _i13.WalletsService {
MockWalletsService() {
_i1.throwOnMissingStub(this);
}
@override
_i10.Future<Map<String, _i13.WalletInfo>> get walletNames =>
(super.noSuchMethod(
Invocation.getter(#walletNames),
returnValue: _i10.Future<Map<String, _i13.WalletInfo>>.value(
<String, _i13.WalletInfo>{}),
) as _i10.Future<Map<String, _i13.WalletInfo>>);
@override
bool get hasListeners => (super.noSuchMethod(
Invocation.getter(#hasListeners),
returnValue: false,
) as bool);
@override
_i10.Future<bool> renameWallet({
required String? from,
required String? to,
required bool? shouldNotifyListeners,
}) =>
(super.noSuchMethod(
Invocation.method(
#renameWallet,
[],
{
#from: from,
#to: to,
#shouldNotifyListeners: shouldNotifyListeners,
},
),
returnValue: _i10.Future<bool>.value(false),
) as _i10.Future<bool>);
@override
Map<String, _i13.WalletInfo> fetchWalletsData() => (super.noSuchMethod(
Invocation.method(
#fetchWalletsData,
[],
),
returnValue: <String, _i13.WalletInfo>{},
) as Map<String, _i13.WalletInfo>);
@override
_i10.Future<void> addExistingStackWallet({
required String? name,
required String? walletId,
required _i14.Coin? coin,
required bool? shouldNotifyListeners,
}) =>
(super.noSuchMethod(
Invocation.method(
#addExistingStackWallet,
[],
{
#name: name,
#walletId: walletId,
#coin: coin,
#shouldNotifyListeners: shouldNotifyListeners,
},
),
returnValue: _i10.Future<void>.value(),
returnValueForMissingStub: _i10.Future<void>.value(),
) as _i10.Future<void>);
@override
_i10.Future<String?> addNewWallet({
required String? name,
required _i14.Coin? coin,
required bool? shouldNotifyListeners,
}) =>
(super.noSuchMethod(
Invocation.method(
#addNewWallet,
[],
{
#name: name,
#coin: coin,
#shouldNotifyListeners: shouldNotifyListeners,
},
),
returnValue: _i10.Future<String?>.value(),
) as _i10.Future<String?>);
@override
_i10.Future<List<String>> getFavoriteWalletIds() => (super.noSuchMethod(
Invocation.method(
#getFavoriteWalletIds,
[],
),
returnValue: _i10.Future<List<String>>.value(<String>[]),
) as _i10.Future<List<String>>);
@override
_i10.Future<void> saveFavoriteWalletIds(List<String>? walletIds) =>
(super.noSuchMethod(
Invocation.method(
#saveFavoriteWalletIds,
[walletIds],
),
returnValue: _i10.Future<void>.value(),
returnValueForMissingStub: _i10.Future<void>.value(),
) as _i10.Future<void>);
@override
_i10.Future<void> addFavorite(String? walletId) => (super.noSuchMethod(
Invocation.method(
#addFavorite,
[walletId],
),
returnValue: _i10.Future<void>.value(),
returnValueForMissingStub: _i10.Future<void>.value(),
) as _i10.Future<void>);
@override
_i10.Future<void> removeFavorite(String? walletId) => (super.noSuchMethod(
Invocation.method(
#removeFavorite,
[walletId],
),
returnValue: _i10.Future<void>.value(),
returnValueForMissingStub: _i10.Future<void>.value(),
) as _i10.Future<void>);
@override
_i10.Future<void> moveFavorite({
required int? fromIndex,
required int? toIndex,
}) =>
(super.noSuchMethod(
Invocation.method(
#moveFavorite,
[],
{
#fromIndex: fromIndex,
#toIndex: toIndex,
},
),
returnValue: _i10.Future<void>.value(),
returnValueForMissingStub: _i10.Future<void>.value(),
) as _i10.Future<void>);
@override
_i10.Future<bool> checkForDuplicate(String? name) => (super.noSuchMethod(
Invocation.method(
#checkForDuplicate,
[name],
),
returnValue: _i10.Future<bool>.value(false),
) as _i10.Future<bool>);
@override
_i10.Future<String?> getWalletId(String? walletName) => (super.noSuchMethod(
Invocation.method(
#getWalletId,
[walletName],
),
returnValue: _i10.Future<String?>.value(),
) as _i10.Future<String?>);
@override
_i10.Future<bool> isMnemonicVerified({required String? walletId}) =>
(super.noSuchMethod(
Invocation.method(
#isMnemonicVerified,
[],
{#walletId: walletId},
),
returnValue: _i10.Future<bool>.value(false),
) as _i10.Future<bool>);
@override
_i10.Future<void> setMnemonicVerified({required String? walletId}) =>
(super.noSuchMethod(
Invocation.method(
#setMnemonicVerified,
[],
{#walletId: walletId},
),
returnValue: _i10.Future<void>.value(),
returnValueForMissingStub: _i10.Future<void>.value(),
) as _i10.Future<void>);
@override
_i10.Future<int> deleteWallet(
String? name,
bool? shouldNotifyListeners,
) =>
(super.noSuchMethod(
Invocation.method(
#deleteWallet,
[
name,
shouldNotifyListeners,
],
),
returnValue: _i10.Future<int>.value(0),
) as _i10.Future<int>);
@override
_i10.Future<void> refreshWallets(bool? shouldNotifyListeners) =>
(super.noSuchMethod(
Invocation.method(
#refreshWallets,
[shouldNotifyListeners],
),
returnValue: _i10.Future<void>.value(),
returnValueForMissingStub: _i10.Future<void>.value(),
) as _i10.Future<void>);
@override
void addListener(_i15.VoidCallback? listener) => super.noSuchMethod(
Invocation.method(
#addListener,
[listener],
),
returnValueForMissingStub: null,
);
@override
void removeListener(_i15.VoidCallback? listener) => super.noSuchMethod(
Invocation.method(
#removeListener,
[listener],
),
returnValueForMissingStub: null,
);
@override
void dispose() => super.noSuchMethod(
Invocation.method(
#dispose,
[],
),
returnValueForMissingStub: null,
);
@override
void notifyListeners() => super.noSuchMethod(
Invocation.method(
#notifyListeners,
[],
),
returnValueForMissingStub: null,
);
}
/// A class which mocks [NodeService].
///
/// See the documentation for Mockito's code generation for more information.
@ -473,15 +240,15 @@ class MockNodeService extends _i1.Mock implements _i2.NodeService {
),
) as _i6.SecureStorageInterface);
@override
List<_i16.NodeModel> get primaryNodes => (super.noSuchMethod(
List<_i13.NodeModel> get primaryNodes => (super.noSuchMethod(
Invocation.getter(#primaryNodes),
returnValue: <_i16.NodeModel>[],
) as List<_i16.NodeModel>);
returnValue: <_i13.NodeModel>[],
) as List<_i13.NodeModel>);
@override
List<_i16.NodeModel> get nodes => (super.noSuchMethod(
List<_i13.NodeModel> get nodes => (super.noSuchMethod(
Invocation.getter(#nodes),
returnValue: <_i16.NodeModel>[],
) as List<_i16.NodeModel>);
returnValue: <_i13.NodeModel>[],
) as List<_i13.NodeModel>);
@override
bool get hasListeners => (super.noSuchMethod(
Invocation.getter(#hasListeners),
@ -499,7 +266,7 @@ class MockNodeService extends _i1.Mock implements _i2.NodeService {
@override
_i10.Future<void> setPrimaryNodeFor({
required _i14.Coin? coin,
required _i16.NodeModel? node,
required _i13.NodeModel? node,
bool? shouldNotifyListeners = false,
}) =>
(super.noSuchMethod(
@ -516,40 +283,40 @@ class MockNodeService extends _i1.Mock implements _i2.NodeService {
returnValueForMissingStub: _i10.Future<void>.value(),
) as _i10.Future<void>);
@override
_i16.NodeModel? getPrimaryNodeFor({required _i14.Coin? coin}) =>
_i13.NodeModel? getPrimaryNodeFor({required _i14.Coin? coin}) =>
(super.noSuchMethod(Invocation.method(
#getPrimaryNodeFor,
[],
{#coin: coin},
)) as _i16.NodeModel?);
)) as _i13.NodeModel?);
@override
List<_i16.NodeModel> getNodesFor(_i14.Coin? coin) => (super.noSuchMethod(
List<_i13.NodeModel> getNodesFor(_i14.Coin? coin) => (super.noSuchMethod(
Invocation.method(
#getNodesFor,
[coin],
),
returnValue: <_i16.NodeModel>[],
) as List<_i16.NodeModel>);
returnValue: <_i13.NodeModel>[],
) as List<_i13.NodeModel>);
@override
_i16.NodeModel? getNodeById({required String? id}) =>
_i13.NodeModel? getNodeById({required String? id}) =>
(super.noSuchMethod(Invocation.method(
#getNodeById,
[],
{#id: id},
)) as _i16.NodeModel?);
)) as _i13.NodeModel?);
@override
List<_i16.NodeModel> failoverNodesFor({required _i14.Coin? coin}) =>
List<_i13.NodeModel> failoverNodesFor({required _i14.Coin? coin}) =>
(super.noSuchMethod(
Invocation.method(
#failoverNodesFor,
[],
{#coin: coin},
),
returnValue: <_i16.NodeModel>[],
) as List<_i16.NodeModel>);
returnValue: <_i13.NodeModel>[],
) as List<_i13.NodeModel>);
@override
_i10.Future<void> add(
_i16.NodeModel? node,
_i13.NodeModel? node,
String? password,
bool? shouldNotifyListeners,
) =>
@ -601,7 +368,7 @@ class MockNodeService extends _i1.Mock implements _i2.NodeService {
) as _i10.Future<void>);
@override
_i10.Future<void> edit(
_i16.NodeModel? editedNode,
_i13.NodeModel? editedNode,
String? password,
bool? shouldNotifyListeners,
) =>
@ -663,7 +430,7 @@ class MockNodeService extends _i1.Mock implements _i2.NodeService {
/// A class which mocks [LocaleService].
///
/// See the documentation for Mockito's code generation for more information.
class MockLocaleService extends _i1.Mock implements _i17.LocaleService {
class MockLocaleService extends _i1.Mock implements _i16.LocaleService {
MockLocaleService() {
_i1.throwOnMissingStub(this);
}
@ -725,7 +492,7 @@ class MockLocaleService extends _i1.Mock implements _i17.LocaleService {
/// A class which mocks [ThemeService].
///
/// See the documentation for Mockito's code generation for more information.
class MockThemeService extends _i1.Mock implements _i18.ThemeService {
class MockThemeService extends _i1.Mock implements _i17.ThemeService {
MockThemeService() {
_i1.throwOnMissingStub(this);
}
@ -755,10 +522,10 @@ class MockThemeService extends _i1.Mock implements _i18.ThemeService {
),
) as _i3.MainDB);
@override
List<_i19.StackTheme> get installedThemes => (super.noSuchMethod(
List<_i18.StackTheme> get installedThemes => (super.noSuchMethod(
Invocation.getter(#installedThemes),
returnValue: <_i19.StackTheme>[],
) as List<_i19.StackTheme>);
returnValue: <_i18.StackTheme>[],
) as List<_i18.StackTheme>);
@override
void init(_i3.MainDB? db) => super.noSuchMethod(
Invocation.method(
@ -768,7 +535,7 @@ class MockThemeService extends _i1.Mock implements _i18.ThemeService {
returnValueForMissingStub: null,
);
@override
_i10.Future<void> install({required _i20.Uint8List? themeArchiveData}) =>
_i10.Future<void> install({required _i19.Uint8List? themeArchiveData}) =>
(super.noSuchMethod(
Invocation.method(
#install,
@ -808,33 +575,33 @@ class MockThemeService extends _i1.Mock implements _i18.ThemeService {
returnValue: _i10.Future<bool>.value(false),
) as _i10.Future<bool>);
@override
_i10.Future<List<_i18.StackThemeMetaData>> fetchThemes() =>
_i10.Future<List<_i17.StackThemeMetaData>> fetchThemes() =>
(super.noSuchMethod(
Invocation.method(
#fetchThemes,
[],
),
returnValue: _i10.Future<List<_i18.StackThemeMetaData>>.value(
<_i18.StackThemeMetaData>[]),
) as _i10.Future<List<_i18.StackThemeMetaData>>);
returnValue: _i10.Future<List<_i17.StackThemeMetaData>>.value(
<_i17.StackThemeMetaData>[]),
) as _i10.Future<List<_i17.StackThemeMetaData>>);
@override
_i10.Future<_i20.Uint8List> fetchTheme(
{required _i18.StackThemeMetaData? themeMetaData}) =>
_i10.Future<_i19.Uint8List> fetchTheme(
{required _i17.StackThemeMetaData? themeMetaData}) =>
(super.noSuchMethod(
Invocation.method(
#fetchTheme,
[],
{#themeMetaData: themeMetaData},
),
returnValue: _i10.Future<_i20.Uint8List>.value(_i20.Uint8List(0)),
) as _i10.Future<_i20.Uint8List>);
returnValue: _i10.Future<_i19.Uint8List>.value(_i19.Uint8List(0)),
) as _i10.Future<_i19.Uint8List>);
@override
_i19.StackTheme? getTheme({required String? themeId}) =>
_i18.StackTheme? getTheme({required String? themeId}) =>
(super.noSuchMethod(Invocation.method(
#getTheme,
[],
{#themeId: themeId},
)) as _i19.StackTheme?);
)) as _i18.StackTheme?);
}
/// A class which mocks [Prefs].
@ -896,12 +663,12 @@ class MockPrefs extends _i1.Mock implements _i12.Prefs {
returnValueForMissingStub: null,
);
@override
_i21.SyncingType get syncType => (super.noSuchMethod(
_i20.SyncingType get syncType => (super.noSuchMethod(
Invocation.getter(#syncType),
returnValue: _i21.SyncingType.currentWalletOnly,
) as _i21.SyncingType);
returnValue: _i20.SyncingType.currentWalletOnly,
) as _i20.SyncingType);
@override
set syncType(_i21.SyncingType? syncType) => super.noSuchMethod(
set syncType(_i20.SyncingType? syncType) => super.noSuchMethod(
Invocation.setter(
#syncType,
syncType,
@ -1060,12 +827,12 @@ class MockPrefs extends _i1.Mock implements _i12.Prefs {
returnValueForMissingStub: null,
);
@override
_i22.BackupFrequencyType get backupFrequencyType => (super.noSuchMethod(
_i21.BackupFrequencyType get backupFrequencyType => (super.noSuchMethod(
Invocation.getter(#backupFrequencyType),
returnValue: _i22.BackupFrequencyType.everyTenMinutes,
) as _i22.BackupFrequencyType);
returnValue: _i21.BackupFrequencyType.everyTenMinutes,
) as _i21.BackupFrequencyType);
@override
set backupFrequencyType(_i22.BackupFrequencyType? backupFrequencyType) =>
set backupFrequencyType(_i21.BackupFrequencyType? backupFrequencyType) =>
super.noSuchMethod(
Invocation.setter(
#backupFrequencyType,
@ -1260,17 +1027,17 @@ class MockPrefs extends _i1.Mock implements _i12.Prefs {
returnValueForMissingStub: _i10.Future<void>.value(),
) as _i10.Future<void>);
@override
_i23.AmountUnit amountUnit(_i14.Coin? coin) => (super.noSuchMethod(
_i22.AmountUnit amountUnit(_i14.Coin? coin) => (super.noSuchMethod(
Invocation.method(
#amountUnit,
[coin],
),
returnValue: _i23.AmountUnit.normal,
) as _i23.AmountUnit);
returnValue: _i22.AmountUnit.normal,
) as _i22.AmountUnit);
@override
void updateAmountUnit({
required _i14.Coin? coin,
required _i23.AmountUnit? amountUnit,
required _i22.AmountUnit? amountUnit,
}) =>
super.noSuchMethod(
Invocation.method(

View file

@ -3,7 +3,6 @@ import 'package:mockito/annotations.dart';
import 'package:stackwallet/services/locale_service.dart';
import 'package:stackwallet/services/node_service.dart';
import 'package:stackwallet/services/wallets.dart';
import 'package:stackwallet/services/wallets_service.dart';
import 'package:stackwallet/themes/theme_service.dart';
import 'package:stackwallet/utilities/amount/amount.dart';
import 'package:stackwallet/utilities/prefs.dart';
@ -17,7 +16,6 @@ Amount _a(int i) => Amount.fromDecimal(
@GenerateMocks([
Wallets,
WalletsService,
ThemeService,
Prefs,
LocaleService

View file

@ -4,23 +4,22 @@
// ignore_for_file: no_leading_underscores_for_library_prefixes
import 'dart:async' as _i10;
import 'dart:typed_data' as _i18;
import 'dart:ui' as _i15;
import 'dart:typed_data' as _i15;
import 'dart:ui' as _i20;
import 'package:mockito/mockito.dart' as _i1;
import 'package:stackwallet/db/isar/main_db.dart' as _i3;
import 'package:stackwallet/models/isar/stack_theme.dart' as _i17;
import 'package:stackwallet/models/node_model.dart' as _i23;
import 'package:stackwallet/models/isar/stack_theme.dart' as _i14;
import 'package:stackwallet/models/node_model.dart' as _i22;
import 'package:stackwallet/networking/http.dart' as _i6;
import 'package:stackwallet/services/locale_service.dart' as _i22;
import 'package:stackwallet/services/locale_service.dart' as _i21;
import 'package:stackwallet/services/node_service.dart' as _i2;
import 'package:stackwallet/services/wallets.dart' as _i9;
import 'package:stackwallet/services/wallets_service.dart' as _i13;
import 'package:stackwallet/themes/theme_service.dart' as _i16;
import 'package:stackwallet/utilities/amount/amount_unit.dart' as _i21;
import 'package:stackwallet/utilities/enums/backup_frequency_type.dart' as _i20;
import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i14;
import 'package:stackwallet/utilities/enums/sync_type_enum.dart' as _i19;
import 'package:stackwallet/themes/theme_service.dart' as _i13;
import 'package:stackwallet/utilities/amount/amount_unit.dart' as _i18;
import 'package:stackwallet/utilities/enums/backup_frequency_type.dart' as _i17;
import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i19;
import 'package:stackwallet/utilities/enums/sync_type_enum.dart' as _i16;
import 'package:stackwallet/utilities/flutter_secure_storage_interface.dart'
as _i8;
import 'package:stackwallet/utilities/prefs.dart' as _i12;
@ -208,6 +207,7 @@ class MockWallets extends _i1.Mock implements _i9.Wallets {
_i10.Future<void> loadAfterStackRestore(
_i12.Prefs? prefs,
List<_i5.Wallet<_i4.CryptoCurrency>>? wallets,
bool? isDesktop,
) =>
(super.noSuchMethod(
Invocation.method(
@ -215,6 +215,7 @@ class MockWallets extends _i1.Mock implements _i9.Wallets {
[
prefs,
wallets,
isDesktop,
],
),
returnValue: _i10.Future<void>.value(),
@ -222,244 +223,10 @@ class MockWallets extends _i1.Mock implements _i9.Wallets {
) as _i10.Future<void>);
}
/// A class which mocks [WalletsService].
///
/// See the documentation for Mockito's code generation for more information.
class MockWalletsService extends _i1.Mock implements _i13.WalletsService {
MockWalletsService() {
_i1.throwOnMissingStub(this);
}
@override
_i10.Future<Map<String, _i13.WalletInfo>> get walletNames =>
(super.noSuchMethod(
Invocation.getter(#walletNames),
returnValue: _i10.Future<Map<String, _i13.WalletInfo>>.value(
<String, _i13.WalletInfo>{}),
) as _i10.Future<Map<String, _i13.WalletInfo>>);
@override
bool get hasListeners => (super.noSuchMethod(
Invocation.getter(#hasListeners),
returnValue: false,
) as bool);
@override
_i10.Future<bool> renameWallet({
required String? from,
required String? to,
required bool? shouldNotifyListeners,
}) =>
(super.noSuchMethod(
Invocation.method(
#renameWallet,
[],
{
#from: from,
#to: to,
#shouldNotifyListeners: shouldNotifyListeners,
},
),
returnValue: _i10.Future<bool>.value(false),
) as _i10.Future<bool>);
@override
Map<String, _i13.WalletInfo> fetchWalletsData() => (super.noSuchMethod(
Invocation.method(
#fetchWalletsData,
[],
),
returnValue: <String, _i13.WalletInfo>{},
) as Map<String, _i13.WalletInfo>);
@override
_i10.Future<void> addExistingStackWallet({
required String? name,
required String? walletId,
required _i14.Coin? coin,
required bool? shouldNotifyListeners,
}) =>
(super.noSuchMethod(
Invocation.method(
#addExistingStackWallet,
[],
{
#name: name,
#walletId: walletId,
#coin: coin,
#shouldNotifyListeners: shouldNotifyListeners,
},
),
returnValue: _i10.Future<void>.value(),
returnValueForMissingStub: _i10.Future<void>.value(),
) as _i10.Future<void>);
@override
_i10.Future<String?> addNewWallet({
required String? name,
required _i14.Coin? coin,
required bool? shouldNotifyListeners,
}) =>
(super.noSuchMethod(
Invocation.method(
#addNewWallet,
[],
{
#name: name,
#coin: coin,
#shouldNotifyListeners: shouldNotifyListeners,
},
),
returnValue: _i10.Future<String?>.value(),
) as _i10.Future<String?>);
@override
_i10.Future<List<String>> getFavoriteWalletIds() => (super.noSuchMethod(
Invocation.method(
#getFavoriteWalletIds,
[],
),
returnValue: _i10.Future<List<String>>.value(<String>[]),
) as _i10.Future<List<String>>);
@override
_i10.Future<void> saveFavoriteWalletIds(List<String>? walletIds) =>
(super.noSuchMethod(
Invocation.method(
#saveFavoriteWalletIds,
[walletIds],
),
returnValue: _i10.Future<void>.value(),
returnValueForMissingStub: _i10.Future<void>.value(),
) as _i10.Future<void>);
@override
_i10.Future<void> addFavorite(String? walletId) => (super.noSuchMethod(
Invocation.method(
#addFavorite,
[walletId],
),
returnValue: _i10.Future<void>.value(),
returnValueForMissingStub: _i10.Future<void>.value(),
) as _i10.Future<void>);
@override
_i10.Future<void> removeFavorite(String? walletId) => (super.noSuchMethod(
Invocation.method(
#removeFavorite,
[walletId],
),
returnValue: _i10.Future<void>.value(),
returnValueForMissingStub: _i10.Future<void>.value(),
) as _i10.Future<void>);
@override
_i10.Future<void> moveFavorite({
required int? fromIndex,
required int? toIndex,
}) =>
(super.noSuchMethod(
Invocation.method(
#moveFavorite,
[],
{
#fromIndex: fromIndex,
#toIndex: toIndex,
},
),
returnValue: _i10.Future<void>.value(),
returnValueForMissingStub: _i10.Future<void>.value(),
) as _i10.Future<void>);
@override
_i10.Future<bool> checkForDuplicate(String? name) => (super.noSuchMethod(
Invocation.method(
#checkForDuplicate,
[name],
),
returnValue: _i10.Future<bool>.value(false),
) as _i10.Future<bool>);
@override
_i10.Future<String?> getWalletId(String? walletName) => (super.noSuchMethod(
Invocation.method(
#getWalletId,
[walletName],
),
returnValue: _i10.Future<String?>.value(),
) as _i10.Future<String?>);
@override
_i10.Future<bool> isMnemonicVerified({required String? walletId}) =>
(super.noSuchMethod(
Invocation.method(
#isMnemonicVerified,
[],
{#walletId: walletId},
),
returnValue: _i10.Future<bool>.value(false),
) as _i10.Future<bool>);
@override
_i10.Future<void> setMnemonicVerified({required String? walletId}) =>
(super.noSuchMethod(
Invocation.method(
#setMnemonicVerified,
[],
{#walletId: walletId},
),
returnValue: _i10.Future<void>.value(),
returnValueForMissingStub: _i10.Future<void>.value(),
) as _i10.Future<void>);
@override
_i10.Future<int> deleteWallet(
String? name,
bool? shouldNotifyListeners,
) =>
(super.noSuchMethod(
Invocation.method(
#deleteWallet,
[
name,
shouldNotifyListeners,
],
),
returnValue: _i10.Future<int>.value(0),
) as _i10.Future<int>);
@override
_i10.Future<void> refreshWallets(bool? shouldNotifyListeners) =>
(super.noSuchMethod(
Invocation.method(
#refreshWallets,
[shouldNotifyListeners],
),
returnValue: _i10.Future<void>.value(),
returnValueForMissingStub: _i10.Future<void>.value(),
) as _i10.Future<void>);
@override
void addListener(_i15.VoidCallback? listener) => super.noSuchMethod(
Invocation.method(
#addListener,
[listener],
),
returnValueForMissingStub: null,
);
@override
void removeListener(_i15.VoidCallback? listener) => super.noSuchMethod(
Invocation.method(
#removeListener,
[listener],
),
returnValueForMissingStub: null,
);
@override
void dispose() => super.noSuchMethod(
Invocation.method(
#dispose,
[],
),
returnValueForMissingStub: null,
);
@override
void notifyListeners() => super.noSuchMethod(
Invocation.method(
#notifyListeners,
[],
),
returnValueForMissingStub: null,
);
}
/// A class which mocks [ThemeService].
///
/// See the documentation for Mockito's code generation for more information.
class MockThemeService extends _i1.Mock implements _i16.ThemeService {
class MockThemeService extends _i1.Mock implements _i13.ThemeService {
MockThemeService() {
_i1.throwOnMissingStub(this);
}
@ -489,10 +256,10 @@ class MockThemeService extends _i1.Mock implements _i16.ThemeService {
),
) as _i3.MainDB);
@override
List<_i17.StackTheme> get installedThemes => (super.noSuchMethod(
List<_i14.StackTheme> get installedThemes => (super.noSuchMethod(
Invocation.getter(#installedThemes),
returnValue: <_i17.StackTheme>[],
) as List<_i17.StackTheme>);
returnValue: <_i14.StackTheme>[],
) as List<_i14.StackTheme>);
@override
void init(_i3.MainDB? db) => super.noSuchMethod(
Invocation.method(
@ -502,7 +269,7 @@ class MockThemeService extends _i1.Mock implements _i16.ThemeService {
returnValueForMissingStub: null,
);
@override
_i10.Future<void> install({required _i18.Uint8List? themeArchiveData}) =>
_i10.Future<void> install({required _i15.Uint8List? themeArchiveData}) =>
(super.noSuchMethod(
Invocation.method(
#install,
@ -542,33 +309,33 @@ class MockThemeService extends _i1.Mock implements _i16.ThemeService {
returnValue: _i10.Future<bool>.value(false),
) as _i10.Future<bool>);
@override
_i10.Future<List<_i16.StackThemeMetaData>> fetchThemes() =>
_i10.Future<List<_i13.StackThemeMetaData>> fetchThemes() =>
(super.noSuchMethod(
Invocation.method(
#fetchThemes,
[],
),
returnValue: _i10.Future<List<_i16.StackThemeMetaData>>.value(
<_i16.StackThemeMetaData>[]),
) as _i10.Future<List<_i16.StackThemeMetaData>>);
returnValue: _i10.Future<List<_i13.StackThemeMetaData>>.value(
<_i13.StackThemeMetaData>[]),
) as _i10.Future<List<_i13.StackThemeMetaData>>);
@override
_i10.Future<_i18.Uint8List> fetchTheme(
{required _i16.StackThemeMetaData? themeMetaData}) =>
_i10.Future<_i15.Uint8List> fetchTheme(
{required _i13.StackThemeMetaData? themeMetaData}) =>
(super.noSuchMethod(
Invocation.method(
#fetchTheme,
[],
{#themeMetaData: themeMetaData},
),
returnValue: _i10.Future<_i18.Uint8List>.value(_i18.Uint8List(0)),
) as _i10.Future<_i18.Uint8List>);
returnValue: _i10.Future<_i15.Uint8List>.value(_i15.Uint8List(0)),
) as _i10.Future<_i15.Uint8List>);
@override
_i17.StackTheme? getTheme({required String? themeId}) =>
_i14.StackTheme? getTheme({required String? themeId}) =>
(super.noSuchMethod(Invocation.method(
#getTheme,
[],
{#themeId: themeId},
)) as _i17.StackTheme?);
)) as _i14.StackTheme?);
}
/// A class which mocks [Prefs].
@ -630,12 +397,12 @@ class MockPrefs extends _i1.Mock implements _i12.Prefs {
returnValueForMissingStub: null,
);
@override
_i19.SyncingType get syncType => (super.noSuchMethod(
_i16.SyncingType get syncType => (super.noSuchMethod(
Invocation.getter(#syncType),
returnValue: _i19.SyncingType.currentWalletOnly,
) as _i19.SyncingType);
returnValue: _i16.SyncingType.currentWalletOnly,
) as _i16.SyncingType);
@override
set syncType(_i19.SyncingType? syncType) => super.noSuchMethod(
set syncType(_i16.SyncingType? syncType) => super.noSuchMethod(
Invocation.setter(
#syncType,
syncType,
@ -794,12 +561,12 @@ class MockPrefs extends _i1.Mock implements _i12.Prefs {
returnValueForMissingStub: null,
);
@override
_i20.BackupFrequencyType get backupFrequencyType => (super.noSuchMethod(
_i17.BackupFrequencyType get backupFrequencyType => (super.noSuchMethod(
Invocation.getter(#backupFrequencyType),
returnValue: _i20.BackupFrequencyType.everyTenMinutes,
) as _i20.BackupFrequencyType);
returnValue: _i17.BackupFrequencyType.everyTenMinutes,
) as _i17.BackupFrequencyType);
@override
set backupFrequencyType(_i20.BackupFrequencyType? backupFrequencyType) =>
set backupFrequencyType(_i17.BackupFrequencyType? backupFrequencyType) =>
super.noSuchMethod(
Invocation.setter(
#backupFrequencyType,
@ -994,17 +761,17 @@ class MockPrefs extends _i1.Mock implements _i12.Prefs {
returnValueForMissingStub: _i10.Future<void>.value(),
) as _i10.Future<void>);
@override
_i21.AmountUnit amountUnit(_i14.Coin? coin) => (super.noSuchMethod(
_i18.AmountUnit amountUnit(_i19.Coin? coin) => (super.noSuchMethod(
Invocation.method(
#amountUnit,
[coin],
),
returnValue: _i21.AmountUnit.normal,
) as _i21.AmountUnit);
returnValue: _i18.AmountUnit.normal,
) as _i18.AmountUnit);
@override
void updateAmountUnit({
required _i14.Coin? coin,
required _i21.AmountUnit? amountUnit,
required _i19.Coin? coin,
required _i18.AmountUnit? amountUnit,
}) =>
super.noSuchMethod(
Invocation.method(
@ -1018,7 +785,7 @@ class MockPrefs extends _i1.Mock implements _i12.Prefs {
returnValueForMissingStub: null,
);
@override
int maxDecimals(_i14.Coin? coin) => (super.noSuchMethod(
int maxDecimals(_i19.Coin? coin) => (super.noSuchMethod(
Invocation.method(
#maxDecimals,
[coin],
@ -1027,7 +794,7 @@ class MockPrefs extends _i1.Mock implements _i12.Prefs {
) as int);
@override
void updateMaxDecimals({
required _i14.Coin? coin,
required _i19.Coin? coin,
required int? maxDecimals,
}) =>
super.noSuchMethod(
@ -1042,7 +809,7 @@ class MockPrefs extends _i1.Mock implements _i12.Prefs {
returnValueForMissingStub: null,
);
@override
_i7.FusionInfo getFusionServerInfo(_i14.Coin? coin) => (super.noSuchMethod(
_i7.FusionInfo getFusionServerInfo(_i19.Coin? coin) => (super.noSuchMethod(
Invocation.method(
#getFusionServerInfo,
[coin],
@ -1057,7 +824,7 @@ class MockPrefs extends _i1.Mock implements _i12.Prefs {
) as _i7.FusionInfo);
@override
void setFusionServerInfo(
_i14.Coin? coin,
_i19.Coin? coin,
_i7.FusionInfo? fusionServerInfo,
) =>
super.noSuchMethod(
@ -1071,7 +838,7 @@ class MockPrefs extends _i1.Mock implements _i12.Prefs {
returnValueForMissingStub: null,
);
@override
void addListener(_i15.VoidCallback? listener) => super.noSuchMethod(
void addListener(_i20.VoidCallback? listener) => super.noSuchMethod(
Invocation.method(
#addListener,
[listener],
@ -1079,7 +846,7 @@ class MockPrefs extends _i1.Mock implements _i12.Prefs {
returnValueForMissingStub: null,
);
@override
void removeListener(_i15.VoidCallback? listener) => super.noSuchMethod(
void removeListener(_i20.VoidCallback? listener) => super.noSuchMethod(
Invocation.method(
#removeListener,
[listener],
@ -1107,7 +874,7 @@ class MockPrefs extends _i1.Mock implements _i12.Prefs {
/// A class which mocks [LocaleService].
///
/// See the documentation for Mockito's code generation for more information.
class MockLocaleService extends _i1.Mock implements _i22.LocaleService {
class MockLocaleService extends _i1.Mock implements _i21.LocaleService {
MockLocaleService() {
_i1.throwOnMissingStub(this);
}
@ -1133,7 +900,7 @@ class MockLocaleService extends _i1.Mock implements _i22.LocaleService {
returnValueForMissingStub: _i10.Future<void>.value(),
) as _i10.Future<void>);
@override
void addListener(_i15.VoidCallback? listener) => super.noSuchMethod(
void addListener(_i20.VoidCallback? listener) => super.noSuchMethod(
Invocation.method(
#addListener,
[listener],
@ -1141,7 +908,7 @@ class MockLocaleService extends _i1.Mock implements _i22.LocaleService {
returnValueForMissingStub: null,
);
@override
void removeListener(_i15.VoidCallback? listener) => super.noSuchMethod(
void removeListener(_i20.VoidCallback? listener) => super.noSuchMethod(
Invocation.method(
#removeListener,
[listener],
@ -1179,15 +946,15 @@ class MockNodeService extends _i1.Mock implements _i2.NodeService {
),
) as _i8.SecureStorageInterface);
@override
List<_i23.NodeModel> get primaryNodes => (super.noSuchMethod(
List<_i22.NodeModel> get primaryNodes => (super.noSuchMethod(
Invocation.getter(#primaryNodes),
returnValue: <_i23.NodeModel>[],
) as List<_i23.NodeModel>);
returnValue: <_i22.NodeModel>[],
) as List<_i22.NodeModel>);
@override
List<_i23.NodeModel> get nodes => (super.noSuchMethod(
List<_i22.NodeModel> get nodes => (super.noSuchMethod(
Invocation.getter(#nodes),
returnValue: <_i23.NodeModel>[],
) as List<_i23.NodeModel>);
returnValue: <_i22.NodeModel>[],
) as List<_i22.NodeModel>);
@override
bool get hasListeners => (super.noSuchMethod(
Invocation.getter(#hasListeners),
@ -1204,8 +971,8 @@ class MockNodeService extends _i1.Mock implements _i2.NodeService {
) as _i10.Future<void>);
@override
_i10.Future<void> setPrimaryNodeFor({
required _i14.Coin? coin,
required _i23.NodeModel? node,
required _i19.Coin? coin,
required _i22.NodeModel? node,
bool? shouldNotifyListeners = false,
}) =>
(super.noSuchMethod(
@ -1222,40 +989,40 @@ class MockNodeService extends _i1.Mock implements _i2.NodeService {
returnValueForMissingStub: _i10.Future<void>.value(),
) as _i10.Future<void>);
@override
_i23.NodeModel? getPrimaryNodeFor({required _i14.Coin? coin}) =>
_i22.NodeModel? getPrimaryNodeFor({required _i19.Coin? coin}) =>
(super.noSuchMethod(Invocation.method(
#getPrimaryNodeFor,
[],
{#coin: coin},
)) as _i23.NodeModel?);
)) as _i22.NodeModel?);
@override
List<_i23.NodeModel> getNodesFor(_i14.Coin? coin) => (super.noSuchMethod(
List<_i22.NodeModel> getNodesFor(_i19.Coin? coin) => (super.noSuchMethod(
Invocation.method(
#getNodesFor,
[coin],
),
returnValue: <_i23.NodeModel>[],
) as List<_i23.NodeModel>);
returnValue: <_i22.NodeModel>[],
) as List<_i22.NodeModel>);
@override
_i23.NodeModel? getNodeById({required String? id}) =>
_i22.NodeModel? getNodeById({required String? id}) =>
(super.noSuchMethod(Invocation.method(
#getNodeById,
[],
{#id: id},
)) as _i23.NodeModel?);
)) as _i22.NodeModel?);
@override
List<_i23.NodeModel> failoverNodesFor({required _i14.Coin? coin}) =>
List<_i22.NodeModel> failoverNodesFor({required _i19.Coin? coin}) =>
(super.noSuchMethod(
Invocation.method(
#failoverNodesFor,
[],
{#coin: coin},
),
returnValue: <_i23.NodeModel>[],
) as List<_i23.NodeModel>);
returnValue: <_i22.NodeModel>[],
) as List<_i22.NodeModel>);
@override
_i10.Future<void> add(
_i23.NodeModel? node,
_i22.NodeModel? node,
String? password,
bool? shouldNotifyListeners,
) =>
@ -1307,7 +1074,7 @@ class MockNodeService extends _i1.Mock implements _i2.NodeService {
) as _i10.Future<void>);
@override
_i10.Future<void> edit(
_i23.NodeModel? editedNode,
_i22.NodeModel? editedNode,
String? password,
bool? shouldNotifyListeners,
) =>
@ -1333,7 +1100,7 @@ class MockNodeService extends _i1.Mock implements _i2.NodeService {
returnValueForMissingStub: _i10.Future<void>.value(),
) as _i10.Future<void>);
@override
void addListener(_i15.VoidCallback? listener) => super.noSuchMethod(
void addListener(_i20.VoidCallback? listener) => super.noSuchMethod(
Invocation.method(
#addListener,
[listener],
@ -1341,7 +1108,7 @@ class MockNodeService extends _i1.Mock implements _i2.NodeService {
returnValueForMissingStub: null,
);
@override
void removeListener(_i15.VoidCallback? listener) => super.noSuchMethod(
void removeListener(_i20.VoidCallback? listener) => super.noSuchMethod(
Invocation.method(
#removeListener,
[listener],

View file

@ -208,6 +208,7 @@ class MockWallets extends _i1.Mock implements _i9.Wallets {
_i10.Future<void> loadAfterStackRestore(
_i12.Prefs? prefs,
List<_i5.Wallet<_i4.CryptoCurrency>>? wallets,
bool? isDesktop,
) =>
(super.noSuchMethod(
Invocation.method(
@ -215,6 +216,7 @@ class MockWallets extends _i1.Mock implements _i9.Wallets {
[
prefs,
wallets,
isDesktop,
],
),
returnValue: _i10.Future<void>.value(),

View file

@ -1,11 +1,9 @@
import 'package:mockito/annotations.dart';
import 'package:stackwallet/services/wallets.dart';
import 'package:stackwallet/services/wallets_service.dart';
import 'package:stackwallet/themes/theme_service.dart';
@GenerateMocks([
Wallets,
WalletsService,
ThemeService,
], customMocks: [])
void main() {

View file

@ -4,18 +4,15 @@
// ignore_for_file: no_leading_underscores_for_library_prefixes
import 'dart:async' as _i8;
import 'dart:typed_data' as _i17;
import 'dart:ui' as _i14;
import 'dart:typed_data' as _i14;
import 'package:mockito/mockito.dart' as _i1;
import 'package:stackwallet/db/isar/main_db.dart' as _i3;
import 'package:stackwallet/models/isar/stack_theme.dart' as _i16;
import 'package:stackwallet/models/isar/stack_theme.dart' as _i13;
import 'package:stackwallet/networking/http.dart' as _i6;
import 'package:stackwallet/services/node_service.dart' as _i2;
import 'package:stackwallet/services/wallets.dart' as _i7;
import 'package:stackwallet/services/wallets_service.dart' as _i12;
import 'package:stackwallet/themes/theme_service.dart' as _i15;
import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i13;
import 'package:stackwallet/themes/theme_service.dart' as _i12;
import 'package:stackwallet/utilities/flutter_secure_storage_interface.dart'
as _i10;
import 'package:stackwallet/utilities/prefs.dart' as _i11;
@ -180,6 +177,7 @@ class MockWallets extends _i1.Mock implements _i7.Wallets {
_i8.Future<void> loadAfterStackRestore(
_i11.Prefs? prefs,
List<_i5.Wallet<_i4.CryptoCurrency>>? wallets,
bool? isDesktop,
) =>
(super.noSuchMethod(
Invocation.method(
@ -187,6 +185,7 @@ class MockWallets extends _i1.Mock implements _i7.Wallets {
[
prefs,
wallets,
isDesktop,
],
),
returnValue: _i8.Future<void>.value(),
@ -194,244 +193,10 @@ class MockWallets extends _i1.Mock implements _i7.Wallets {
) as _i8.Future<void>);
}
/// A class which mocks [WalletsService].
///
/// See the documentation for Mockito's code generation for more information.
class MockWalletsService extends _i1.Mock implements _i12.WalletsService {
MockWalletsService() {
_i1.throwOnMissingStub(this);
}
@override
_i8.Future<Map<String, _i12.WalletInfo>> get walletNames =>
(super.noSuchMethod(
Invocation.getter(#walletNames),
returnValue: _i8.Future<Map<String, _i12.WalletInfo>>.value(
<String, _i12.WalletInfo>{}),
) as _i8.Future<Map<String, _i12.WalletInfo>>);
@override
bool get hasListeners => (super.noSuchMethod(
Invocation.getter(#hasListeners),
returnValue: false,
) as bool);
@override
_i8.Future<bool> renameWallet({
required String? from,
required String? to,
required bool? shouldNotifyListeners,
}) =>
(super.noSuchMethod(
Invocation.method(
#renameWallet,
[],
{
#from: from,
#to: to,
#shouldNotifyListeners: shouldNotifyListeners,
},
),
returnValue: _i8.Future<bool>.value(false),
) as _i8.Future<bool>);
@override
Map<String, _i12.WalletInfo> fetchWalletsData() => (super.noSuchMethod(
Invocation.method(
#fetchWalletsData,
[],
),
returnValue: <String, _i12.WalletInfo>{},
) as Map<String, _i12.WalletInfo>);
@override
_i8.Future<void> addExistingStackWallet({
required String? name,
required String? walletId,
required _i13.Coin? coin,
required bool? shouldNotifyListeners,
}) =>
(super.noSuchMethod(
Invocation.method(
#addExistingStackWallet,
[],
{
#name: name,
#walletId: walletId,
#coin: coin,
#shouldNotifyListeners: shouldNotifyListeners,
},
),
returnValue: _i8.Future<void>.value(),
returnValueForMissingStub: _i8.Future<void>.value(),
) as _i8.Future<void>);
@override
_i8.Future<String?> addNewWallet({
required String? name,
required _i13.Coin? coin,
required bool? shouldNotifyListeners,
}) =>
(super.noSuchMethod(
Invocation.method(
#addNewWallet,
[],
{
#name: name,
#coin: coin,
#shouldNotifyListeners: shouldNotifyListeners,
},
),
returnValue: _i8.Future<String?>.value(),
) as _i8.Future<String?>);
@override
_i8.Future<List<String>> getFavoriteWalletIds() => (super.noSuchMethod(
Invocation.method(
#getFavoriteWalletIds,
[],
),
returnValue: _i8.Future<List<String>>.value(<String>[]),
) as _i8.Future<List<String>>);
@override
_i8.Future<void> saveFavoriteWalletIds(List<String>? walletIds) =>
(super.noSuchMethod(
Invocation.method(
#saveFavoriteWalletIds,
[walletIds],
),
returnValue: _i8.Future<void>.value(),
returnValueForMissingStub: _i8.Future<void>.value(),
) as _i8.Future<void>);
@override
_i8.Future<void> addFavorite(String? walletId) => (super.noSuchMethod(
Invocation.method(
#addFavorite,
[walletId],
),
returnValue: _i8.Future<void>.value(),
returnValueForMissingStub: _i8.Future<void>.value(),
) as _i8.Future<void>);
@override
_i8.Future<void> removeFavorite(String? walletId) => (super.noSuchMethod(
Invocation.method(
#removeFavorite,
[walletId],
),
returnValue: _i8.Future<void>.value(),
returnValueForMissingStub: _i8.Future<void>.value(),
) as _i8.Future<void>);
@override
_i8.Future<void> moveFavorite({
required int? fromIndex,
required int? toIndex,
}) =>
(super.noSuchMethod(
Invocation.method(
#moveFavorite,
[],
{
#fromIndex: fromIndex,
#toIndex: toIndex,
},
),
returnValue: _i8.Future<void>.value(),
returnValueForMissingStub: _i8.Future<void>.value(),
) as _i8.Future<void>);
@override
_i8.Future<bool> checkForDuplicate(String? name) => (super.noSuchMethod(
Invocation.method(
#checkForDuplicate,
[name],
),
returnValue: _i8.Future<bool>.value(false),
) as _i8.Future<bool>);
@override
_i8.Future<String?> getWalletId(String? walletName) => (super.noSuchMethod(
Invocation.method(
#getWalletId,
[walletName],
),
returnValue: _i8.Future<String?>.value(),
) as _i8.Future<String?>);
@override
_i8.Future<bool> isMnemonicVerified({required String? walletId}) =>
(super.noSuchMethod(
Invocation.method(
#isMnemonicVerified,
[],
{#walletId: walletId},
),
returnValue: _i8.Future<bool>.value(false),
) as _i8.Future<bool>);
@override
_i8.Future<void> setMnemonicVerified({required String? walletId}) =>
(super.noSuchMethod(
Invocation.method(
#setMnemonicVerified,
[],
{#walletId: walletId},
),
returnValue: _i8.Future<void>.value(),
returnValueForMissingStub: _i8.Future<void>.value(),
) as _i8.Future<void>);
@override
_i8.Future<int> deleteWallet(
String? name,
bool? shouldNotifyListeners,
) =>
(super.noSuchMethod(
Invocation.method(
#deleteWallet,
[
name,
shouldNotifyListeners,
],
),
returnValue: _i8.Future<int>.value(0),
) as _i8.Future<int>);
@override
_i8.Future<void> refreshWallets(bool? shouldNotifyListeners) =>
(super.noSuchMethod(
Invocation.method(
#refreshWallets,
[shouldNotifyListeners],
),
returnValue: _i8.Future<void>.value(),
returnValueForMissingStub: _i8.Future<void>.value(),
) as _i8.Future<void>);
@override
void addListener(_i14.VoidCallback? listener) => super.noSuchMethod(
Invocation.method(
#addListener,
[listener],
),
returnValueForMissingStub: null,
);
@override
void removeListener(_i14.VoidCallback? listener) => super.noSuchMethod(
Invocation.method(
#removeListener,
[listener],
),
returnValueForMissingStub: null,
);
@override
void dispose() => super.noSuchMethod(
Invocation.method(
#dispose,
[],
),
returnValueForMissingStub: null,
);
@override
void notifyListeners() => super.noSuchMethod(
Invocation.method(
#notifyListeners,
[],
),
returnValueForMissingStub: null,
);
}
/// A class which mocks [ThemeService].
///
/// See the documentation for Mockito's code generation for more information.
class MockThemeService extends _i1.Mock implements _i15.ThemeService {
class MockThemeService extends _i1.Mock implements _i12.ThemeService {
MockThemeService() {
_i1.throwOnMissingStub(this);
}
@ -461,10 +226,10 @@ class MockThemeService extends _i1.Mock implements _i15.ThemeService {
),
) as _i3.MainDB);
@override
List<_i16.StackTheme> get installedThemes => (super.noSuchMethod(
List<_i13.StackTheme> get installedThemes => (super.noSuchMethod(
Invocation.getter(#installedThemes),
returnValue: <_i16.StackTheme>[],
) as List<_i16.StackTheme>);
returnValue: <_i13.StackTheme>[],
) as List<_i13.StackTheme>);
@override
void init(_i3.MainDB? db) => super.noSuchMethod(
Invocation.method(
@ -474,7 +239,7 @@ class MockThemeService extends _i1.Mock implements _i15.ThemeService {
returnValueForMissingStub: null,
);
@override
_i8.Future<void> install({required _i17.Uint8List? themeArchiveData}) =>
_i8.Future<void> install({required _i14.Uint8List? themeArchiveData}) =>
(super.noSuchMethod(
Invocation.method(
#install,
@ -514,31 +279,31 @@ class MockThemeService extends _i1.Mock implements _i15.ThemeService {
returnValue: _i8.Future<bool>.value(false),
) as _i8.Future<bool>);
@override
_i8.Future<List<_i15.StackThemeMetaData>> fetchThemes() =>
_i8.Future<List<_i12.StackThemeMetaData>> fetchThemes() =>
(super.noSuchMethod(
Invocation.method(
#fetchThemes,
[],
),
returnValue: _i8.Future<List<_i15.StackThemeMetaData>>.value(
<_i15.StackThemeMetaData>[]),
) as _i8.Future<List<_i15.StackThemeMetaData>>);
returnValue: _i8.Future<List<_i12.StackThemeMetaData>>.value(
<_i12.StackThemeMetaData>[]),
) as _i8.Future<List<_i12.StackThemeMetaData>>);
@override
_i8.Future<_i17.Uint8List> fetchTheme(
{required _i15.StackThemeMetaData? themeMetaData}) =>
_i8.Future<_i14.Uint8List> fetchTheme(
{required _i12.StackThemeMetaData? themeMetaData}) =>
(super.noSuchMethod(
Invocation.method(
#fetchTheme,
[],
{#themeMetaData: themeMetaData},
),
returnValue: _i8.Future<_i17.Uint8List>.value(_i17.Uint8List(0)),
) as _i8.Future<_i17.Uint8List>);
returnValue: _i8.Future<_i14.Uint8List>.value(_i14.Uint8List(0)),
) as _i8.Future<_i14.Uint8List>);
@override
_i16.StackTheme? getTheme({required String? themeId}) =>
_i13.StackTheme? getTheme({required String? themeId}) =>
(super.noSuchMethod(Invocation.method(
#getTheme,
[],
{#themeId: themeId},
)) as _i16.StackTheme?);
)) as _i13.StackTheme?);
}

View file

@ -246,6 +246,7 @@ class MockWallets extends _i1.Mock implements _i10.Wallets {
_i11.Future<void> loadAfterStackRestore(
_i14.Prefs? prefs,
List<_i5.Wallet<_i4.CryptoCurrency>>? wallets,
bool? isDesktop,
) =>
(super.noSuchMethod(
Invocation.method(
@ -253,6 +254,7 @@ class MockWallets extends _i1.Mock implements _i10.Wallets {
[
prefs,
wallets,
isDesktop,
],
),
returnValue: _i11.Future<void>.value(),
@ -877,11 +879,6 @@ class MockPriceService extends _i1.Mock implements _i21.PriceService {
returnValueForMissingStub: null,
);
@override
Set<String> get tokenContractAddressesToCheck => (super.noSuchMethod(
Invocation.getter(#tokenContractAddressesToCheck),
returnValue: <String>{},
) as Set<String>);
@override
Duration get updateInterval => (super.noSuchMethod(
Invocation.getter(#updateInterval),
returnValue: _FakeDuration_4(
@ -890,6 +887,12 @@ class MockPriceService extends _i1.Mock implements _i21.PriceService {
),
) as Duration);
@override
_i11.Future<Set<String>> get tokenContractAddressesToCheck =>
(super.noSuchMethod(
Invocation.getter(#tokenContractAddressesToCheck),
returnValue: _i11.Future<Set<String>>.value(<String>{}),
) as _i11.Future<Set<String>>);
@override
bool get hasListeners => (super.noSuchMethod(
Invocation.getter(#hasListeners),
returnValue: false,

View file

@ -179,6 +179,7 @@ class MockWallets extends _i1.Mock implements _i7.Wallets {
_i8.Future<void> loadAfterStackRestore(
_i11.Prefs? prefs,
List<_i5.Wallet<_i4.CryptoCurrency>>? wallets,
bool? isDesktop,
) =>
(super.noSuchMethod(
Invocation.method(
@ -186,6 +187,7 @@ class MockWallets extends _i1.Mock implements _i7.Wallets {
[
prefs,
wallets,
isDesktop,
],
),
returnValue: _i8.Future<void>.value(),

View file

@ -1,11 +1,9 @@
import 'package:mockito/annotations.dart';
import 'package:stackwallet/services/node_service.dart';
import 'package:stackwallet/services/wallets.dart';
import 'package:stackwallet/services/wallets_service.dart';
@GenerateMocks([
Wallets,
WalletsService,
], customMocks: [
MockSpec<NodeService>(returnNullOnMissingStub: true),
// MockSpec<WalletsService>(returnNullOnMissingStub: true),

View file

@ -8,10 +8,9 @@ import 'dart:ui' as _i13;
import 'package:mockito/mockito.dart' as _i1;
import 'package:stackwallet/db/isar/main_db.dart' as _i3;
import 'package:stackwallet/models/node_model.dart' as _i14;
import 'package:stackwallet/models/node_model.dart' as _i11;
import 'package:stackwallet/services/node_service.dart' as _i2;
import 'package:stackwallet/services/wallets.dart' as _i7;
import 'package:stackwallet/services/wallets_service.dart' as _i11;
import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i12;
import 'package:stackwallet/utilities/flutter_secure_storage_interface.dart'
as _i6;
@ -178,6 +177,7 @@ class MockWallets extends _i1.Mock implements _i7.Wallets {
_i8.Future<void> loadAfterStackRestore(
_i10.Prefs? prefs,
List<_i5.Wallet<_i4.CryptoCurrency>>? wallets,
bool? isDesktop,
) =>
(super.noSuchMethod(
Invocation.method(
@ -185,6 +185,7 @@ class MockWallets extends _i1.Mock implements _i7.Wallets {
[
prefs,
wallets,
isDesktop,
],
),
returnValue: _i8.Future<void>.value(),
@ -192,240 +193,6 @@ class MockWallets extends _i1.Mock implements _i7.Wallets {
) as _i8.Future<void>);
}
/// A class which mocks [WalletsService].
///
/// See the documentation for Mockito's code generation for more information.
class MockWalletsService extends _i1.Mock implements _i11.WalletsService {
MockWalletsService() {
_i1.throwOnMissingStub(this);
}
@override
_i8.Future<Map<String, _i11.WalletInfo>> get walletNames =>
(super.noSuchMethod(
Invocation.getter(#walletNames),
returnValue: _i8.Future<Map<String, _i11.WalletInfo>>.value(
<String, _i11.WalletInfo>{}),
) as _i8.Future<Map<String, _i11.WalletInfo>>);
@override
bool get hasListeners => (super.noSuchMethod(
Invocation.getter(#hasListeners),
returnValue: false,
) as bool);
@override
_i8.Future<bool> renameWallet({
required String? from,
required String? to,
required bool? shouldNotifyListeners,
}) =>
(super.noSuchMethod(
Invocation.method(
#renameWallet,
[],
{
#from: from,
#to: to,
#shouldNotifyListeners: shouldNotifyListeners,
},
),
returnValue: _i8.Future<bool>.value(false),
) as _i8.Future<bool>);
@override
Map<String, _i11.WalletInfo> fetchWalletsData() => (super.noSuchMethod(
Invocation.method(
#fetchWalletsData,
[],
),
returnValue: <String, _i11.WalletInfo>{},
) as Map<String, _i11.WalletInfo>);
@override
_i8.Future<void> addExistingStackWallet({
required String? name,
required String? walletId,
required _i12.Coin? coin,
required bool? shouldNotifyListeners,
}) =>
(super.noSuchMethod(
Invocation.method(
#addExistingStackWallet,
[],
{
#name: name,
#walletId: walletId,
#coin: coin,
#shouldNotifyListeners: shouldNotifyListeners,
},
),
returnValue: _i8.Future<void>.value(),
returnValueForMissingStub: _i8.Future<void>.value(),
) as _i8.Future<void>);
@override
_i8.Future<String?> addNewWallet({
required String? name,
required _i12.Coin? coin,
required bool? shouldNotifyListeners,
}) =>
(super.noSuchMethod(
Invocation.method(
#addNewWallet,
[],
{
#name: name,
#coin: coin,
#shouldNotifyListeners: shouldNotifyListeners,
},
),
returnValue: _i8.Future<String?>.value(),
) as _i8.Future<String?>);
@override
_i8.Future<List<String>> getFavoriteWalletIds() => (super.noSuchMethod(
Invocation.method(
#getFavoriteWalletIds,
[],
),
returnValue: _i8.Future<List<String>>.value(<String>[]),
) as _i8.Future<List<String>>);
@override
_i8.Future<void> saveFavoriteWalletIds(List<String>? walletIds) =>
(super.noSuchMethod(
Invocation.method(
#saveFavoriteWalletIds,
[walletIds],
),
returnValue: _i8.Future<void>.value(),
returnValueForMissingStub: _i8.Future<void>.value(),
) as _i8.Future<void>);
@override
_i8.Future<void> addFavorite(String? walletId) => (super.noSuchMethod(
Invocation.method(
#addFavorite,
[walletId],
),
returnValue: _i8.Future<void>.value(),
returnValueForMissingStub: _i8.Future<void>.value(),
) as _i8.Future<void>);
@override
_i8.Future<void> removeFavorite(String? walletId) => (super.noSuchMethod(
Invocation.method(
#removeFavorite,
[walletId],
),
returnValue: _i8.Future<void>.value(),
returnValueForMissingStub: _i8.Future<void>.value(),
) as _i8.Future<void>);
@override
_i8.Future<void> moveFavorite({
required int? fromIndex,
required int? toIndex,
}) =>
(super.noSuchMethod(
Invocation.method(
#moveFavorite,
[],
{
#fromIndex: fromIndex,
#toIndex: toIndex,
},
),
returnValue: _i8.Future<void>.value(),
returnValueForMissingStub: _i8.Future<void>.value(),
) as _i8.Future<void>);
@override
_i8.Future<bool> checkForDuplicate(String? name) => (super.noSuchMethod(
Invocation.method(
#checkForDuplicate,
[name],
),
returnValue: _i8.Future<bool>.value(false),
) as _i8.Future<bool>);
@override
_i8.Future<String?> getWalletId(String? walletName) => (super.noSuchMethod(
Invocation.method(
#getWalletId,
[walletName],
),
returnValue: _i8.Future<String?>.value(),
) as _i8.Future<String?>);
@override
_i8.Future<bool> isMnemonicVerified({required String? walletId}) =>
(super.noSuchMethod(
Invocation.method(
#isMnemonicVerified,
[],
{#walletId: walletId},
),
returnValue: _i8.Future<bool>.value(false),
) as _i8.Future<bool>);
@override
_i8.Future<void> setMnemonicVerified({required String? walletId}) =>
(super.noSuchMethod(
Invocation.method(
#setMnemonicVerified,
[],
{#walletId: walletId},
),
returnValue: _i8.Future<void>.value(),
returnValueForMissingStub: _i8.Future<void>.value(),
) as _i8.Future<void>);
@override
_i8.Future<int> deleteWallet(
String? name,
bool? shouldNotifyListeners,
) =>
(super.noSuchMethod(
Invocation.method(
#deleteWallet,
[
name,
shouldNotifyListeners,
],
),
returnValue: _i8.Future<int>.value(0),
) as _i8.Future<int>);
@override
_i8.Future<void> refreshWallets(bool? shouldNotifyListeners) =>
(super.noSuchMethod(
Invocation.method(
#refreshWallets,
[shouldNotifyListeners],
),
returnValue: _i8.Future<void>.value(),
returnValueForMissingStub: _i8.Future<void>.value(),
) as _i8.Future<void>);
@override
void addListener(_i13.VoidCallback? listener) => super.noSuchMethod(
Invocation.method(
#addListener,
[listener],
),
returnValueForMissingStub: null,
);
@override
void removeListener(_i13.VoidCallback? listener) => super.noSuchMethod(
Invocation.method(
#removeListener,
[listener],
),
returnValueForMissingStub: null,
);
@override
void dispose() => super.noSuchMethod(
Invocation.method(
#dispose,
[],
),
returnValueForMissingStub: null,
);
@override
void notifyListeners() => super.noSuchMethod(
Invocation.method(
#notifyListeners,
[],
),
returnValueForMissingStub: null,
);
}
/// A class which mocks [NodeService].
///
/// See the documentation for Mockito's code generation for more information.
@ -439,15 +206,15 @@ class MockNodeService extends _i1.Mock implements _i2.NodeService {
),
) as _i6.SecureStorageInterface);
@override
List<_i14.NodeModel> get primaryNodes => (super.noSuchMethod(
List<_i11.NodeModel> get primaryNodes => (super.noSuchMethod(
Invocation.getter(#primaryNodes),
returnValue: <_i14.NodeModel>[],
) as List<_i14.NodeModel>);
returnValue: <_i11.NodeModel>[],
) as List<_i11.NodeModel>);
@override
List<_i14.NodeModel> get nodes => (super.noSuchMethod(
List<_i11.NodeModel> get nodes => (super.noSuchMethod(
Invocation.getter(#nodes),
returnValue: <_i14.NodeModel>[],
) as List<_i14.NodeModel>);
returnValue: <_i11.NodeModel>[],
) as List<_i11.NodeModel>);
@override
bool get hasListeners => (super.noSuchMethod(
Invocation.getter(#hasListeners),
@ -465,7 +232,7 @@ class MockNodeService extends _i1.Mock implements _i2.NodeService {
@override
_i8.Future<void> setPrimaryNodeFor({
required _i12.Coin? coin,
required _i14.NodeModel? node,
required _i11.NodeModel? node,
bool? shouldNotifyListeners = false,
}) =>
(super.noSuchMethod(
@ -482,40 +249,40 @@ class MockNodeService extends _i1.Mock implements _i2.NodeService {
returnValueForMissingStub: _i8.Future<void>.value(),
) as _i8.Future<void>);
@override
_i14.NodeModel? getPrimaryNodeFor({required _i12.Coin? coin}) =>
_i11.NodeModel? getPrimaryNodeFor({required _i12.Coin? coin}) =>
(super.noSuchMethod(Invocation.method(
#getPrimaryNodeFor,
[],
{#coin: coin},
)) as _i14.NodeModel?);
)) as _i11.NodeModel?);
@override
List<_i14.NodeModel> getNodesFor(_i12.Coin? coin) => (super.noSuchMethod(
List<_i11.NodeModel> getNodesFor(_i12.Coin? coin) => (super.noSuchMethod(
Invocation.method(
#getNodesFor,
[coin],
),
returnValue: <_i14.NodeModel>[],
) as List<_i14.NodeModel>);
returnValue: <_i11.NodeModel>[],
) as List<_i11.NodeModel>);
@override
_i14.NodeModel? getNodeById({required String? id}) =>
_i11.NodeModel? getNodeById({required String? id}) =>
(super.noSuchMethod(Invocation.method(
#getNodeById,
[],
{#id: id},
)) as _i14.NodeModel?);
)) as _i11.NodeModel?);
@override
List<_i14.NodeModel> failoverNodesFor({required _i12.Coin? coin}) =>
List<_i11.NodeModel> failoverNodesFor({required _i12.Coin? coin}) =>
(super.noSuchMethod(
Invocation.method(
#failoverNodesFor,
[],
{#coin: coin},
),
returnValue: <_i14.NodeModel>[],
) as List<_i14.NodeModel>);
returnValue: <_i11.NodeModel>[],
) as List<_i11.NodeModel>);
@override
_i8.Future<void> add(
_i14.NodeModel? node,
_i11.NodeModel? node,
String? password,
bool? shouldNotifyListeners,
) =>
@ -567,7 +334,7 @@ class MockNodeService extends _i1.Mock implements _i2.NodeService {
) as _i8.Future<void>);
@override
_i8.Future<void> edit(
_i14.NodeModel? editedNode,
_i11.NodeModel? editedNode,
String? password,
bool? shouldNotifyListeners,
) =>

View file

@ -6,7 +6,6 @@ import 'package:stackwallet/themes/theme_service.dart';
@GenerateMocks([
Wallets,
WalletsService,
ThemeService,
], customMocks: [
MockSpec<NodeService>(returnNullOnMissingStub: true),

View file

@ -4,19 +4,18 @@
// ignore_for_file: no_leading_underscores_for_library_prefixes
import 'dart:async' as _i9;
import 'dart:typed_data' as _i17;
import 'dart:ui' as _i14;
import 'dart:typed_data' as _i14;
import 'dart:ui' as _i17;
import 'package:mockito/mockito.dart' as _i1;
import 'package:stackwallet/db/isar/main_db.dart' as _i3;
import 'package:stackwallet/models/isar/stack_theme.dart' as _i16;
import 'package:stackwallet/models/node_model.dart' as _i18;
import 'package:stackwallet/models/isar/stack_theme.dart' as _i13;
import 'package:stackwallet/models/node_model.dart' as _i15;
import 'package:stackwallet/networking/http.dart' as _i6;
import 'package:stackwallet/services/node_service.dart' as _i2;
import 'package:stackwallet/services/wallets.dart' as _i8;
import 'package:stackwallet/services/wallets_service.dart' as _i12;
import 'package:stackwallet/themes/theme_service.dart' as _i15;
import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i13;
import 'package:stackwallet/themes/theme_service.dart' as _i12;
import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i16;
import 'package:stackwallet/utilities/flutter_secure_storage_interface.dart'
as _i7;
import 'package:stackwallet/utilities/prefs.dart' as _i11;
@ -192,6 +191,7 @@ class MockWallets extends _i1.Mock implements _i8.Wallets {
_i9.Future<void> loadAfterStackRestore(
_i11.Prefs? prefs,
List<_i5.Wallet<_i4.CryptoCurrency>>? wallets,
bool? isDesktop,
) =>
(super.noSuchMethod(
Invocation.method(
@ -199,6 +199,7 @@ class MockWallets extends _i1.Mock implements _i8.Wallets {
[
prefs,
wallets,
isDesktop,
],
),
returnValue: _i9.Future<void>.value(),
@ -206,244 +207,10 @@ class MockWallets extends _i1.Mock implements _i8.Wallets {
) as _i9.Future<void>);
}
/// A class which mocks [WalletsService].
///
/// See the documentation for Mockito's code generation for more information.
class MockWalletsService extends _i1.Mock implements _i12.WalletsService {
MockWalletsService() {
_i1.throwOnMissingStub(this);
}
@override
_i9.Future<Map<String, _i12.WalletInfo>> get walletNames =>
(super.noSuchMethod(
Invocation.getter(#walletNames),
returnValue: _i9.Future<Map<String, _i12.WalletInfo>>.value(
<String, _i12.WalletInfo>{}),
) as _i9.Future<Map<String, _i12.WalletInfo>>);
@override
bool get hasListeners => (super.noSuchMethod(
Invocation.getter(#hasListeners),
returnValue: false,
) as bool);
@override
_i9.Future<bool> renameWallet({
required String? from,
required String? to,
required bool? shouldNotifyListeners,
}) =>
(super.noSuchMethod(
Invocation.method(
#renameWallet,
[],
{
#from: from,
#to: to,
#shouldNotifyListeners: shouldNotifyListeners,
},
),
returnValue: _i9.Future<bool>.value(false),
) as _i9.Future<bool>);
@override
Map<String, _i12.WalletInfo> fetchWalletsData() => (super.noSuchMethod(
Invocation.method(
#fetchWalletsData,
[],
),
returnValue: <String, _i12.WalletInfo>{},
) as Map<String, _i12.WalletInfo>);
@override
_i9.Future<void> addExistingStackWallet({
required String? name,
required String? walletId,
required _i13.Coin? coin,
required bool? shouldNotifyListeners,
}) =>
(super.noSuchMethod(
Invocation.method(
#addExistingStackWallet,
[],
{
#name: name,
#walletId: walletId,
#coin: coin,
#shouldNotifyListeners: shouldNotifyListeners,
},
),
returnValue: _i9.Future<void>.value(),
returnValueForMissingStub: _i9.Future<void>.value(),
) as _i9.Future<void>);
@override
_i9.Future<String?> addNewWallet({
required String? name,
required _i13.Coin? coin,
required bool? shouldNotifyListeners,
}) =>
(super.noSuchMethod(
Invocation.method(
#addNewWallet,
[],
{
#name: name,
#coin: coin,
#shouldNotifyListeners: shouldNotifyListeners,
},
),
returnValue: _i9.Future<String?>.value(),
) as _i9.Future<String?>);
@override
_i9.Future<List<String>> getFavoriteWalletIds() => (super.noSuchMethod(
Invocation.method(
#getFavoriteWalletIds,
[],
),
returnValue: _i9.Future<List<String>>.value(<String>[]),
) as _i9.Future<List<String>>);
@override
_i9.Future<void> saveFavoriteWalletIds(List<String>? walletIds) =>
(super.noSuchMethod(
Invocation.method(
#saveFavoriteWalletIds,
[walletIds],
),
returnValue: _i9.Future<void>.value(),
returnValueForMissingStub: _i9.Future<void>.value(),
) as _i9.Future<void>);
@override
_i9.Future<void> addFavorite(String? walletId) => (super.noSuchMethod(
Invocation.method(
#addFavorite,
[walletId],
),
returnValue: _i9.Future<void>.value(),
returnValueForMissingStub: _i9.Future<void>.value(),
) as _i9.Future<void>);
@override
_i9.Future<void> removeFavorite(String? walletId) => (super.noSuchMethod(
Invocation.method(
#removeFavorite,
[walletId],
),
returnValue: _i9.Future<void>.value(),
returnValueForMissingStub: _i9.Future<void>.value(),
) as _i9.Future<void>);
@override
_i9.Future<void> moveFavorite({
required int? fromIndex,
required int? toIndex,
}) =>
(super.noSuchMethod(
Invocation.method(
#moveFavorite,
[],
{
#fromIndex: fromIndex,
#toIndex: toIndex,
},
),
returnValue: _i9.Future<void>.value(),
returnValueForMissingStub: _i9.Future<void>.value(),
) as _i9.Future<void>);
@override
_i9.Future<bool> checkForDuplicate(String? name) => (super.noSuchMethod(
Invocation.method(
#checkForDuplicate,
[name],
),
returnValue: _i9.Future<bool>.value(false),
) as _i9.Future<bool>);
@override
_i9.Future<String?> getWalletId(String? walletName) => (super.noSuchMethod(
Invocation.method(
#getWalletId,
[walletName],
),
returnValue: _i9.Future<String?>.value(),
) as _i9.Future<String?>);
@override
_i9.Future<bool> isMnemonicVerified({required String? walletId}) =>
(super.noSuchMethod(
Invocation.method(
#isMnemonicVerified,
[],
{#walletId: walletId},
),
returnValue: _i9.Future<bool>.value(false),
) as _i9.Future<bool>);
@override
_i9.Future<void> setMnemonicVerified({required String? walletId}) =>
(super.noSuchMethod(
Invocation.method(
#setMnemonicVerified,
[],
{#walletId: walletId},
),
returnValue: _i9.Future<void>.value(),
returnValueForMissingStub: _i9.Future<void>.value(),
) as _i9.Future<void>);
@override
_i9.Future<int> deleteWallet(
String? name,
bool? shouldNotifyListeners,
) =>
(super.noSuchMethod(
Invocation.method(
#deleteWallet,
[
name,
shouldNotifyListeners,
],
),
returnValue: _i9.Future<int>.value(0),
) as _i9.Future<int>);
@override
_i9.Future<void> refreshWallets(bool? shouldNotifyListeners) =>
(super.noSuchMethod(
Invocation.method(
#refreshWallets,
[shouldNotifyListeners],
),
returnValue: _i9.Future<void>.value(),
returnValueForMissingStub: _i9.Future<void>.value(),
) as _i9.Future<void>);
@override
void addListener(_i14.VoidCallback? listener) => super.noSuchMethod(
Invocation.method(
#addListener,
[listener],
),
returnValueForMissingStub: null,
);
@override
void removeListener(_i14.VoidCallback? listener) => super.noSuchMethod(
Invocation.method(
#removeListener,
[listener],
),
returnValueForMissingStub: null,
);
@override
void dispose() => super.noSuchMethod(
Invocation.method(
#dispose,
[],
),
returnValueForMissingStub: null,
);
@override
void notifyListeners() => super.noSuchMethod(
Invocation.method(
#notifyListeners,
[],
),
returnValueForMissingStub: null,
);
}
/// A class which mocks [ThemeService].
///
/// See the documentation for Mockito's code generation for more information.
class MockThemeService extends _i1.Mock implements _i15.ThemeService {
class MockThemeService extends _i1.Mock implements _i12.ThemeService {
MockThemeService() {
_i1.throwOnMissingStub(this);
}
@ -473,10 +240,10 @@ class MockThemeService extends _i1.Mock implements _i15.ThemeService {
),
) as _i3.MainDB);
@override
List<_i16.StackTheme> get installedThemes => (super.noSuchMethod(
List<_i13.StackTheme> get installedThemes => (super.noSuchMethod(
Invocation.getter(#installedThemes),
returnValue: <_i16.StackTheme>[],
) as List<_i16.StackTheme>);
returnValue: <_i13.StackTheme>[],
) as List<_i13.StackTheme>);
@override
void init(_i3.MainDB? db) => super.noSuchMethod(
Invocation.method(
@ -486,7 +253,7 @@ class MockThemeService extends _i1.Mock implements _i15.ThemeService {
returnValueForMissingStub: null,
);
@override
_i9.Future<void> install({required _i17.Uint8List? themeArchiveData}) =>
_i9.Future<void> install({required _i14.Uint8List? themeArchiveData}) =>
(super.noSuchMethod(
Invocation.method(
#install,
@ -526,33 +293,33 @@ class MockThemeService extends _i1.Mock implements _i15.ThemeService {
returnValue: _i9.Future<bool>.value(false),
) as _i9.Future<bool>);
@override
_i9.Future<List<_i15.StackThemeMetaData>> fetchThemes() =>
_i9.Future<List<_i12.StackThemeMetaData>> fetchThemes() =>
(super.noSuchMethod(
Invocation.method(
#fetchThemes,
[],
),
returnValue: _i9.Future<List<_i15.StackThemeMetaData>>.value(
<_i15.StackThemeMetaData>[]),
) as _i9.Future<List<_i15.StackThemeMetaData>>);
returnValue: _i9.Future<List<_i12.StackThemeMetaData>>.value(
<_i12.StackThemeMetaData>[]),
) as _i9.Future<List<_i12.StackThemeMetaData>>);
@override
_i9.Future<_i17.Uint8List> fetchTheme(
{required _i15.StackThemeMetaData? themeMetaData}) =>
_i9.Future<_i14.Uint8List> fetchTheme(
{required _i12.StackThemeMetaData? themeMetaData}) =>
(super.noSuchMethod(
Invocation.method(
#fetchTheme,
[],
{#themeMetaData: themeMetaData},
),
returnValue: _i9.Future<_i17.Uint8List>.value(_i17.Uint8List(0)),
) as _i9.Future<_i17.Uint8List>);
returnValue: _i9.Future<_i14.Uint8List>.value(_i14.Uint8List(0)),
) as _i9.Future<_i14.Uint8List>);
@override
_i16.StackTheme? getTheme({required String? themeId}) =>
_i13.StackTheme? getTheme({required String? themeId}) =>
(super.noSuchMethod(Invocation.method(
#getTheme,
[],
{#themeId: themeId},
)) as _i16.StackTheme?);
)) as _i13.StackTheme?);
}
/// A class which mocks [NodeService].
@ -568,15 +335,15 @@ class MockNodeService extends _i1.Mock implements _i2.NodeService {
),
) as _i7.SecureStorageInterface);
@override
List<_i18.NodeModel> get primaryNodes => (super.noSuchMethod(
List<_i15.NodeModel> get primaryNodes => (super.noSuchMethod(
Invocation.getter(#primaryNodes),
returnValue: <_i18.NodeModel>[],
) as List<_i18.NodeModel>);
returnValue: <_i15.NodeModel>[],
) as List<_i15.NodeModel>);
@override
List<_i18.NodeModel> get nodes => (super.noSuchMethod(
List<_i15.NodeModel> get nodes => (super.noSuchMethod(
Invocation.getter(#nodes),
returnValue: <_i18.NodeModel>[],
) as List<_i18.NodeModel>);
returnValue: <_i15.NodeModel>[],
) as List<_i15.NodeModel>);
@override
bool get hasListeners => (super.noSuchMethod(
Invocation.getter(#hasListeners),
@ -593,8 +360,8 @@ class MockNodeService extends _i1.Mock implements _i2.NodeService {
) as _i9.Future<void>);
@override
_i9.Future<void> setPrimaryNodeFor({
required _i13.Coin? coin,
required _i18.NodeModel? node,
required _i16.Coin? coin,
required _i15.NodeModel? node,
bool? shouldNotifyListeners = false,
}) =>
(super.noSuchMethod(
@ -611,40 +378,40 @@ class MockNodeService extends _i1.Mock implements _i2.NodeService {
returnValueForMissingStub: _i9.Future<void>.value(),
) as _i9.Future<void>);
@override
_i18.NodeModel? getPrimaryNodeFor({required _i13.Coin? coin}) =>
_i15.NodeModel? getPrimaryNodeFor({required _i16.Coin? coin}) =>
(super.noSuchMethod(Invocation.method(
#getPrimaryNodeFor,
[],
{#coin: coin},
)) as _i18.NodeModel?);
)) as _i15.NodeModel?);
@override
List<_i18.NodeModel> getNodesFor(_i13.Coin? coin) => (super.noSuchMethod(
List<_i15.NodeModel> getNodesFor(_i16.Coin? coin) => (super.noSuchMethod(
Invocation.method(
#getNodesFor,
[coin],
),
returnValue: <_i18.NodeModel>[],
) as List<_i18.NodeModel>);
returnValue: <_i15.NodeModel>[],
) as List<_i15.NodeModel>);
@override
_i18.NodeModel? getNodeById({required String? id}) =>
_i15.NodeModel? getNodeById({required String? id}) =>
(super.noSuchMethod(Invocation.method(
#getNodeById,
[],
{#id: id},
)) as _i18.NodeModel?);
)) as _i15.NodeModel?);
@override
List<_i18.NodeModel> failoverNodesFor({required _i13.Coin? coin}) =>
List<_i15.NodeModel> failoverNodesFor({required _i16.Coin? coin}) =>
(super.noSuchMethod(
Invocation.method(
#failoverNodesFor,
[],
{#coin: coin},
),
returnValue: <_i18.NodeModel>[],
) as List<_i18.NodeModel>);
returnValue: <_i15.NodeModel>[],
) as List<_i15.NodeModel>);
@override
_i9.Future<void> add(
_i18.NodeModel? node,
_i15.NodeModel? node,
String? password,
bool? shouldNotifyListeners,
) =>
@ -696,7 +463,7 @@ class MockNodeService extends _i1.Mock implements _i2.NodeService {
) as _i9.Future<void>);
@override
_i9.Future<void> edit(
_i18.NodeModel? editedNode,
_i15.NodeModel? editedNode,
String? password,
bool? shouldNotifyListeners,
) =>
@ -722,7 +489,7 @@ class MockNodeService extends _i1.Mock implements _i2.NodeService {
returnValueForMissingStub: _i9.Future<void>.value(),
) as _i9.Future<void>);
@override
void addListener(_i14.VoidCallback? listener) => super.noSuchMethod(
void addListener(_i17.VoidCallback? listener) => super.noSuchMethod(
Invocation.method(
#addListener,
[listener],
@ -730,7 +497,7 @@ class MockNodeService extends _i1.Mock implements _i2.NodeService {
returnValueForMissingStub: null,
);
@override
void removeListener(_i14.VoidCallback? listener) => super.noSuchMethod(
void removeListener(_i17.VoidCallback? listener) => super.noSuchMethod(
Invocation.method(
#removeListener,
[listener],