diff --git a/assets/default_themes/dark.zip b/assets/default_themes/dark.zip index 70bc24340..9823262a9 100644 Binary files a/assets/default_themes/dark.zip and b/assets/default_themes/dark.zip differ diff --git a/assets/default_themes/light.zip b/assets/default_themes/light.zip index f4544f179..649716126 100644 Binary files a/assets/default_themes/light.zip and b/assets/default_themes/light.zip differ diff --git a/crypto_plugins/flutter_libepiccash b/crypto_plugins/flutter_libepiccash index 01bad9471..c34af5aad 160000 --- a/crypto_plugins/flutter_libepiccash +++ b/crypto_plugins/flutter_libepiccash @@ -1 +1 @@ -Subproject commit 01bad9471c4b41392cd2aa98f5655dc14dedc997 +Subproject commit c34af5aadd0c986023a1ab998ca6972582142c4c diff --git a/lib/main.dart b/lib/main.dart index e075e10b7..852ffc9c0 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -205,6 +205,27 @@ void main() async { // check and update or install default themes await ThemeService.instance.checkDefaultThemesOnStartup(); + // verify current user preference theme and revert to default + // if problems are found to prevent app being unusable + if (!(await ThemeService.instance + .verifyInstalled(themeId: Prefs.instance.themeId))) { + Prefs.instance.themeId = "light"; + } + + // verify current user preference light brightness theme and revert to default + // if problems are found to prevent app being unusable + if (!(await ThemeService.instance + .verifyInstalled(themeId: Prefs.instance.systemBrightnessLightThemeId))) { + Prefs.instance.systemBrightnessLightThemeId = "light"; + } + + // verify current user preference dark brightness theme and revert to default + // if problems are found to prevent app being unusable + if (!(await ThemeService.instance + .verifyInstalled(themeId: Prefs.instance.systemBrightnessDarkThemeId))) { + Prefs.instance.systemBrightnessDarkThemeId = "dark"; + } + runApp(const ProviderScope(child: MyApp())); } diff --git a/lib/models/isar/stack_theme.dart b/lib/models/isar/stack_theme.dart index d5c1bb1a9..d68494d3b 100644 --- a/lib/models/isar/stack_theme.dart +++ b/lib/models/isar/stack_theme.dart @@ -1939,7 +1939,9 @@ class ThemeAssets implements IThemeAssets { @override late final String? background; - // todo: add all assets expected in json + @override + @ignore + String? get walletSummaryCardBackground => null; ThemeAssets(); @@ -2102,6 +2104,8 @@ class ThemeAssetsV2 implements IThemeAssets { late final String? loadingGif; @override late final String? background; + @override + late final String? walletSummaryCardBackground; late final String coinPlaceholder; @@ -2196,6 +2200,10 @@ class ThemeAssetsV2 implements IThemeAssets { : null ..background = json["background"] is String ? "$applicationThemesDirectoryPath/$themeId/assets/${json["background"] as String}" + : null + ..walletSummaryCardBackground = json["walletSummaryCardBackground"] + is String + ? "$applicationThemesDirectoryPath/$themeId/assets/${json["walletSummaryCardBackground"] as String}" : null; } @@ -2246,6 +2254,7 @@ class ThemeAssetsV2 implements IThemeAssets { 'txExchangeFailed: $txExchangeFailed, ' 'loadingGif: $loadingGif, ' 'background: $background, ' + 'walletSummaryCardBackground: $walletSummaryCardBackground, ' 'coinPlaceholder: $coinPlaceholder, ' 'coinIcons: $coinIcons, ' 'coinImages: $coinImages, ' @@ -2276,4 +2285,5 @@ abstract class IThemeAssets { String? get loadingGif; String? get background; + String? get walletSummaryCardBackground; } diff --git a/lib/models/isar/stack_theme.g.dart b/lib/models/isar/stack_theme.g.dart index ad6f905bd..13c01d906 100644 --- a/lib/models/isar/stack_theme.g.dart +++ b/lib/models/isar/stack_theme.g.dart @@ -25895,6 +25895,11 @@ const ThemeAssetsV2Schema = Schema( id: 23, name: r'txExchangePending', type: IsarType.string, + ), + r'walletSummaryCardBackground': PropertySchema( + id: 24, + name: r'walletSummaryCardBackground', + type: IsarType.string, ) }, estimateSize: _themeAssetsV2EstimateSize, @@ -25943,6 +25948,12 @@ int _themeAssetsV2EstimateSize( bytesCount += 3 + object.txExchange.length * 3; bytesCount += 3 + object.txExchangeFailed.length * 3; bytesCount += 3 + object.txExchangePending.length * 3; + { + final value = object.walletSummaryCardBackground; + if (value != null) { + bytesCount += 3 + value.length * 3; + } + } return bytesCount; } @@ -25976,6 +25987,7 @@ void _themeAssetsV2Serialize( writer.writeString(offsets[21], object.txExchange); writer.writeString(offsets[22], object.txExchangeFailed); writer.writeString(offsets[23], object.txExchangePending); + writer.writeString(offsets[24], object.walletSummaryCardBackground); } ThemeAssetsV2 _themeAssetsV2Deserialize( @@ -26009,6 +26021,7 @@ ThemeAssetsV2 _themeAssetsV2Deserialize( object.txExchange = reader.readString(offsets[21]); object.txExchangeFailed = reader.readString(offsets[22]); object.txExchangePending = reader.readString(offsets[23]); + object.walletSummaryCardBackground = reader.readStringOrNull(offsets[24]); return object; } @@ -26067,6 +26080,8 @@ P _themeAssetsV2DeserializeProp

( return (reader.readString(offset)) as P; case 23: return (reader.readString(offset)) as P; + case 24: + return (reader.readStringOrNull(offset)) as P; default: throw IsarError('Unknown property with id $propertyId'); } @@ -29372,6 +29387,162 @@ extension ThemeAssetsV2QueryFilter )); }); } + + QueryBuilder + walletSummaryCardBackgroundIsNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNull( + property: r'walletSummaryCardBackground', + )); + }); + } + + QueryBuilder + walletSummaryCardBackgroundIsNotNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNotNull( + property: r'walletSummaryCardBackground', + )); + }); + } + + QueryBuilder + walletSummaryCardBackgroundEqualTo( + String? value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'walletSummaryCardBackground', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + walletSummaryCardBackgroundGreaterThan( + String? value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'walletSummaryCardBackground', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + walletSummaryCardBackgroundLessThan( + String? value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'walletSummaryCardBackground', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + walletSummaryCardBackgroundBetween( + String? lower, + String? upper, { + bool includeLower = true, + bool includeUpper = true, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'walletSummaryCardBackground', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + walletSummaryCardBackgroundStartsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.startsWith( + property: r'walletSummaryCardBackground', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + walletSummaryCardBackgroundEndsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.endsWith( + property: r'walletSummaryCardBackground', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + walletSummaryCardBackgroundContains(String value, + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.contains( + property: r'walletSummaryCardBackground', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + walletSummaryCardBackgroundMatches(String pattern, + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.matches( + property: r'walletSummaryCardBackground', + wildcard: pattern, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + walletSummaryCardBackgroundIsEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'walletSummaryCardBackground', + value: '', + )); + }); + } + + QueryBuilder + walletSummaryCardBackgroundIsNotEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + property: r'walletSummaryCardBackground', + value: '', + )); + }); + } } extension ThemeAssetsV2QueryObject diff --git a/lib/pages/send_view/send_view.dart b/lib/pages/send_view/send_view.dart index 246f9dd5e..9309600d6 100644 --- a/lib/pages/send_view/send_view.dart +++ b/lib/pages/send_view/send_view.dart @@ -978,21 +978,27 @@ class _SendViewState extends ConsumerState { mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Text( - isPaynymSend ? "Send to PayNym address" : "Send to", + isPaynymSend + ? "Send to PayNym address" + : "Send to", style: STextStyles.smallMed12(context), textAlign: TextAlign.left, ), - if (coin == Coin.monero) - CustomTextButton( - text: "Use OpenAlias", - onTap: () async { - await showModalBottomSheet(context: context, builder: (context) => OpenAliasBottomSheet( - onSelected: (address) { - sendToController.text = address; - }, - )); - }, - ) + // if (coin == Coin.monero) + // CustomTextButton( + // text: "Use OpenAlias", + // onTap: () async { + // await showModalBottomSheet( + // context: context, + // builder: (context) => + // OpenAliasBottomSheet( + // onSelected: (address) { + // sendToController.text = address; + // }, + // ), + // ); + // }, + // ), ], ), const SizedBox( diff --git a/lib/pages/send_view/sub_widgets/openalias_sheet.dart b/lib/pages/send_view/sub_widgets/openalias_sheet.dart index a19265bcb..d2bf5d302 100644 --- a/lib/pages/send_view/sub_widgets/openalias_sheet.dart +++ b/lib/pages/send_view/sub_widgets/openalias_sheet.dart @@ -1,148 +1,151 @@ -/* - * This file is part of Stack Wallet. - * - * Copyright (c) 2023 Cypher Stack - * All Rights Reserved. - * The code is distributed under GPLv3 license, see LICENSE file for details. - * Generated by Cypher Stack on 2023-05-26 - * - */ - -import 'package:flutter/cupertino.dart'; -import 'package:flutter/material.dart'; -import 'package:flutter_riverpod/flutter_riverpod.dart'; - -import '../../../themes/stack_colors.dart'; -import '../../../utilities/constants.dart'; -import '../../../utilities/text_styles.dart'; - -import 'package:basic_utils/basic_utils.dart'; - -class OpenAliasBottomSheet extends ConsumerStatefulWidget { - const OpenAliasBottomSheet({ - Key? key, - required this.onSelected, - }) : super(key: key); - - final Null Function(String) onSelected; - - @override - ConsumerState createState() => - _OpenAliasBottomSheetState(); -} - -class _OpenAliasBottomSheetState extends ConsumerState { - late TextEditingController textEditingController; - - @override - void initState() { - super.initState(); - textEditingController = TextEditingController(); - } - - @override - Widget build(BuildContext context) { - return SingleChildScrollView( - child: Padding( - padding: EdgeInsets.only(bottom: MediaQuery.of(context).viewInsets.bottom), - child: Container( - decoration: BoxDecoration( - color: Theme.of(context).extension()!.popupBG, - borderRadius: const BorderRadius.vertical( - top: Radius.circular(20), - ), - ), - child: Padding( - padding: const EdgeInsets.only( - top: 20, - left: 20, - right: 20, - bottom: 20, - ), - child: Column( - mainAxisSize: MainAxisSize.min, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Center( - child: Container( - decoration: BoxDecoration( - color: Theme.of(context) - .extension()! - .textFieldDefaultBG, - borderRadius: BorderRadius.circular( - Constants.size.circularBorderRadius, - ), - ), - width: 60, - height: 4, - ), - ), - const SizedBox( - height: 36, - ), - Text( - 'OpenAlias Address', - style: STextStyles.smallMed12(context), - textAlign: TextAlign.left, - ), - const SizedBox( - height: 8, - ), - TextField( - controller: textEditingController, - decoration: const InputDecoration( - border: OutlineInputBorder(), - ), - ), - const SizedBox( - height: 16, - ), - Align( - alignment: Alignment.bottomCenter, - child: ConstrainedBox( - constraints: const BoxConstraints( - minWidth: 480, - minHeight: 70, - ), - child: TextButton( - style: Theme.of(context) - .extension()! - .getPrimaryEnabledButtonStyle(context), - onPressed: () async { - String text = textEditingController.text.trim().replaceAll("@", "."); - List? result = await DnsUtils.lookupRecord(text, RRecordType.TXT); - String address = ""; - if (result != null && result.isNotEmpty) { - for (RRecord record in result) { - if (record.data.startsWith("oa1:xmr")) { - List datas = record.data.split(" "); - for (String data in datas) { - if (data.startsWith("recipient_address=")) { - address = data.substring("recipient_address=".length).replaceAll(";", ""); - break; - } - } - break; - } - } - } - widget.onSelected(address!); - Navigator.of(context).pop(); - }, - child: Text( - "Enter", - style: STextStyles.button(context), - ), - ), - ), - ) - ], - ), - ), - ), - ), - ); - } -} - - +// /* +// * This file is part of Stack Wallet. +// * +// * Copyright (c) 2023 Cypher Stack +// * All Rights Reserved. +// * The code is distributed under GPLv3 license, see LICENSE file for details. +// * Generated by Cypher Stack on 2023-05-26 +// * +// */ +// +// import 'package:basic_utils/basic_utils.dart'; +// import 'package:flutter/material.dart'; +// import 'package:flutter_riverpod/flutter_riverpod.dart'; +// import 'package:stackwallet/themes/stack_colors.dart'; +// import 'package:stackwallet/utilities/constants.dart'; +// import 'package:stackwallet/utilities/text_styles.dart'; +// +// class OpenAliasBottomSheet extends ConsumerStatefulWidget { +// const OpenAliasBottomSheet({ +// Key? key, +// required this.onSelected, +// }) : super(key: key); +// +// final Null Function(String) onSelected; +// +// @override +// ConsumerState createState() => +// _OpenAliasBottomSheetState(); +// } +// +// class _OpenAliasBottomSheetState extends ConsumerState { +// late TextEditingController textEditingController; +// +// @override +// void initState() { +// super.initState(); +// textEditingController = TextEditingController(); +// } +// +// @override +// Widget build(BuildContext context) { +// return SingleChildScrollView( +// child: Padding( +// padding: +// EdgeInsets.only(bottom: MediaQuery.of(context).viewInsets.bottom), +// child: Container( +// decoration: BoxDecoration( +// color: Theme.of(context).extension()!.popupBG, +// borderRadius: const BorderRadius.vertical( +// top: Radius.circular(20), +// ), +// ), +// child: Padding( +// padding: const EdgeInsets.only( +// top: 20, +// left: 20, +// right: 20, +// bottom: 20, +// ), +// child: Column( +// mainAxisSize: MainAxisSize.min, +// crossAxisAlignment: CrossAxisAlignment.start, +// children: [ +// Center( +// child: Container( +// decoration: BoxDecoration( +// color: Theme.of(context) +// .extension()! +// .textFieldDefaultBG, +// borderRadius: BorderRadius.circular( +// Constants.size.circularBorderRadius, +// ), +// ), +// width: 60, +// height: 4, +// ), +// ), +// const SizedBox( +// height: 36, +// ), +// Text( +// 'OpenAlias Address', +// style: STextStyles.smallMed12(context), +// textAlign: TextAlign.left, +// ), +// const SizedBox( +// height: 8, +// ), +// TextField( +// controller: textEditingController, +// decoration: const InputDecoration( +// border: OutlineInputBorder(), +// ), +// ), +// const SizedBox( +// height: 16, +// ), +// Align( +// alignment: Alignment.bottomCenter, +// child: ConstrainedBox( +// constraints: const BoxConstraints( +// minWidth: 480, +// minHeight: 70, +// ), +// child: TextButton( +// style: Theme.of(context) +// .extension()! +// .getPrimaryEnabledButtonStyle(context), +// onPressed: () async { +// String text = textEditingController.text +// .trim() +// .replaceAll("@", "."); +// List? result = +// await DnsUtils.lookupRecord(text, RRecordType.TXT); +// String address = ""; +// if (result != null && result.isNotEmpty) { +// for (RRecord record in result) { +// if (record.data.startsWith("oa1:xmr")) { +// List datas = record.data.split(" "); +// for (String data in datas) { +// if (data.startsWith("recipient_address=")) { +// address = data +// .substring("recipient_address=".length) +// .replaceAll(";", ""); +// break; +// } +// } +// break; +// } +// } +// } +// widget.onSelected(address); +// if (mounted) { +// Navigator.of(context).pop(); +// } +// }, +// child: Text( +// "Enter", +// style: STextStyles.button(context), +// ), +// ), +// ), +// ) +// ], +// ), +// ), +// ), +// ), +// ); +// } +// } diff --git a/lib/pages/settings_views/global_settings_view/advanced_views/manage_coin_units/choose_unit_sheet.dart b/lib/pages/settings_views/global_settings_view/advanced_views/manage_coin_units/choose_unit_sheet.dart index f7d67f44e..d5ef002b7 100644 --- a/lib/pages/settings_views/global_settings_view/advanced_views/manage_coin_units/choose_unit_sheet.dart +++ b/lib/pages/settings_views/global_settings_view/advanced_views/manage_coin_units/choose_unit_sheet.dart @@ -46,95 +46,97 @@ class _ChooseUnitSheetState extends ConsumerState { top: 10, bottom: 0, ), - child: Column( - mainAxisSize: MainAxisSize.min, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Center( - child: Container( - decoration: BoxDecoration( - color: Theme.of(context) - .extension()! - .textFieldDefaultBG, - borderRadius: BorderRadius.circular( - Constants.size.circularBorderRadius, + child: SingleChildScrollView( + child: Column( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Center( + child: Container( + decoration: BoxDecoration( + color: Theme.of(context) + .extension()! + .textFieldDefaultBG, + borderRadius: BorderRadius.circular( + Constants.size.circularBorderRadius, + ), ), + width: 60, + height: 4, ), - width: 60, - height: 4, ), - ), - const SizedBox( - height: 36, - ), - Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - "Phrase length", - style: STextStyles.pageTitleH2(context), - textAlign: TextAlign.left, - ), - const SizedBox( - height: 16, - ), - for (int i = 0; i < values.length; i++) - Column( - children: [ - GestureDetector( - onTap: () { - setState(() { - _current = values[i]; - }); + const SizedBox( + height: 36, + ), + Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + "Coin units", + style: STextStyles.pageTitleH2(context), + textAlign: TextAlign.left, + ), + const SizedBox( + height: 16, + ), + for (int i = 0; i < values.length; i++) + Column( + children: [ + GestureDetector( + onTap: () { + setState(() { + _current = values[i]; + }); - Navigator.of(context).pop(_current); - }, - child: Container( - color: Colors.transparent, - child: Row( - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - SizedBox( - width: 20, - height: 20, - child: Radio( - activeColor: Theme.of(context) - .extension()! - .radioButtonIconEnabled, - value: values[i], - groupValue: _current, - onChanged: (x) { - setState(() { - _current = values[i]; - }); + Navigator.of(context).pop(_current); + }, + child: Container( + color: Colors.transparent, + child: Row( + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + SizedBox( + width: 20, + height: 20, + child: Radio( + activeColor: Theme.of(context) + .extension()! + .radioButtonIconEnabled, + value: values[i], + groupValue: _current, + onChanged: (x) { + setState(() { + _current = values[i]; + }); - Navigator.of(context).pop(_current); - }, + Navigator.of(context).pop(_current); + }, + ), ), - ), - const SizedBox( - width: 12, - ), - Text( - values[i].unitForCoin(widget.coin), - style: STextStyles.titleBold12(context), - textAlign: TextAlign.left, - ), - ], + const SizedBox( + width: 12, + ), + Text( + values[i].unitForCoin(widget.coin), + style: STextStyles.titleBold12(context), + textAlign: TextAlign.left, + ), + ], + ), ), ), - ), - const SizedBox( - height: 16, - ), - ], + const SizedBox( + height: 16, + ), + ], + ), + const SizedBox( + height: 8, ), - const SizedBox( - height: 8, - ), - ], - ), - ], + ], + ), + ], + ), ), ), ); diff --git a/lib/pages/wallet_view/sub_widgets/wallet_refresh_button.dart b/lib/pages/wallet_view/sub_widgets/wallet_refresh_button.dart index c8bd1549d..2f03a1b21 100644 --- a/lib/pages/wallet_view/sub_widgets/wallet_refresh_button.dart +++ b/lib/pages/wallet_view/sub_widgets/wallet_refresh_button.dart @@ -66,26 +66,38 @@ class _RefreshButtonState extends ConsumerState { widget.tokenContractAddress == null) { switch (event.newStatus) { case WalletSyncStatus.unableToSync: - _spinController.stop?.call(); + if (_spinController.hasLoadedAnimation) { + _spinController.stop?.call(); + } break; case WalletSyncStatus.synced: - _spinController.stop?.call(); + if (_spinController.hasLoadedAnimation) { + _spinController.stop?.call(); + } break; case WalletSyncStatus.syncing: - _spinController.repeat?.call(); + if (_spinController.hasLoadedAnimation) { + _spinController.repeat?.call(); + } break; } } else if (widget.tokenContractAddress != null && event.walletId == widget.walletId + widget.tokenContractAddress!) { switch (event.newStatus) { case WalletSyncStatus.unableToSync: - _spinController.stop?.call(); + if (_spinController.hasLoadedAnimation) { + _spinController.stop?.call(); + } break; case WalletSyncStatus.synced: - _spinController.stop?.call(); + if (_spinController.hasLoadedAnimation) { + _spinController.stop?.call(); + } break; case WalletSyncStatus.syncing: - _spinController.repeat?.call(); + if (_spinController.hasLoadedAnimation) { + _spinController.repeat?.call(); + } break; } } diff --git a/lib/services/coins/banano/banano_wallet.dart b/lib/services/coins/banano/banano_wallet.dart index 23c219b00..abba2a86f 100644 --- a/lib/services/coins/banano/banano_wallet.dart +++ b/lib/services/coins/banano/banano_wallet.dart @@ -174,7 +174,7 @@ class BananoWallet extends CoinServiceAPI Future confirmSend({required Map txData}) async { try { // our address: - final String publicAddress = await getAddressFromMnemonic(); + final String publicAddress = await currentReceivingAddress; // first get the account balance: final balanceBody = jsonEncode({ @@ -276,8 +276,18 @@ class BananoWallet extends CoinServiceAPI } } + Future get _currentReceivingAddress => db + .getAddresses(walletId) + .filter() + .typeEqualTo(AddressType.banano) + .and() + .subTypeEqualTo(AddressSubType.receiving) + .sortByDerivationIndexDesc() + .findFirst(); + @override - Future get currentReceivingAddress => getAddressFromMnemonic(); + Future get currentReceivingAddress async => + (await _currentReceivingAddress)?.value ?? await getAddressFromMnemonic(); @override Future estimateFeeFor(Amount amount, int feeRate) { @@ -298,7 +308,7 @@ class BananoWallet extends CoinServiceAPI Future updateBalance() async { final body = jsonEncode({ "action": "account_balance", - "account": await getAddressFromMnemonic(), + "account": await currentReceivingAddress, }); final headers = { "Content-Type": "application/json", @@ -333,7 +343,7 @@ class BananoWallet extends CoinServiceAPI }; // our address: - final String publicAddress = await getAddressFromMnemonic(); + final String publicAddress = await currentReceivingAddress; // first check if the account is open: // get the account info (we need the frontier and representative): @@ -452,7 +462,7 @@ class BananoWallet extends CoinServiceAPI body: jsonEncode({ "action": "receivable", "source": "true", - "account": await getAddressFromMnemonic(), + "account": await currentReceivingAddress, "count": "-1", })); @@ -474,7 +484,8 @@ class BananoWallet extends CoinServiceAPI Future updateTransactions() async { await confirmAllReceivable(); - final String publicAddress = await getAddressFromMnemonic(); + final receivingAddress = (await _currentReceivingAddress)!; + final String publicAddress = receivingAddress.value; final response = await http.post(Uri.parse(getCurrentNode().host), headers: {"Content-Type": "application/json"}, body: jsonEncode({ @@ -483,7 +494,8 @@ class BananoWallet extends CoinServiceAPI "count": "-1", })); final data = await jsonDecode(response.body); - final transactions = data["history"] as List; + final transactions = + data["history"] is List ? data["history"] as List : []; if (transactions.isEmpty) { return; } else { @@ -521,21 +533,17 @@ class BananoWallet extends CoinServiceAPI numberOfMessages: null, ); - Address address = Address( - walletId: walletId, - publicKey: [], - value: transactionType == TransactionType.incoming - ? publicAddress - : tx["account"].toString(), - derivationIndex: 0, - derivationPath: null, - type: transactionType == TransactionType.incoming - ? AddressType.nonWallet - : AddressType.banano, - subType: transactionType == TransactionType.incoming - ? AddressSubType.receiving - : AddressSubType.nonWallet, - ); + Address address = transactionType == TransactionType.incoming + ? receivingAddress + : Address( + walletId: walletId, + publicKey: [], + value: tx["account"].toString(), + derivationIndex: 0, + derivationPath: null, + type: AddressType.banano, + subType: AddressSubType.nonWallet, + ); Tuple2 tuple = Tuple2(transaction, address); transactionList.add(tuple); } @@ -599,7 +607,7 @@ class BananoWallet extends CoinServiceAPI publicKey: [], // TODO: add public key derivationIndex: 0, derivationPath: null, - type: AddressType.unknown, + type: AddressType.banano, subType: AddressSubType.receiving, ); @@ -694,10 +702,10 @@ class BananoWallet extends CoinServiceAPI final address = Address( walletId: walletId, value: publicAddress, - publicKey: [], // TODO: add public key + publicKey: [], derivationIndex: 0, derivationPath: null, - type: AddressType.unknown, + type: AddressType.banano, subType: AddressSubType.receiving, ); @@ -734,7 +742,11 @@ class BananoWallet extends CoinServiceAPI coin, ), ); - } catch (e) { + } catch (e, s) { + Logging.instance.log( + "Failed to refresh banano wallet \'$walletName\': $e\n$s", + level: LogLevel.Warning, + ); GlobalEventBus.instance.fire( WalletSyncStatusChangedEvent( WalletSyncStatus.unableToSync, @@ -756,15 +768,20 @@ class BananoWallet extends CoinServiceAPI } @override - Future testNetworkConnection() { - http - .get(Uri.parse("${getCurrentNode().host}?action=version")) - .then((response) { - if (response.statusCode == 200) { - return true; - } - }); - return Future.value(false); + Future testNetworkConnection() async { + final uri = Uri.parse(getCurrentNode().host); + + final response = await http.post( + uri, + headers: {"Content-Type": "application/json"}, + body: jsonEncode( + { + "action": "version", + }, + ), + ); + + return response.statusCode == 200; } Timer? _networkAliveTimer; @@ -841,7 +858,7 @@ class BananoWallet extends CoinServiceAPI } Future updateChainHeight() async { - final String publicAddress = await getAddressFromMnemonic(); + final String publicAddress = await currentReceivingAddress; // first get the account balance: final infoBody = jsonEncode({ "action": "account_info", @@ -857,7 +874,9 @@ class BananoWallet extends CoinServiceAPI ); final infoData = jsonDecode(infoResponse.body); - final int height = int.parse(infoData["confirmation_height"].toString()); - await updateCachedChainHeight(height); + final int? height = int.tryParse( + infoData["confirmation_height"].toString(), + ); + await updateCachedChainHeight(height ?? 0); } } diff --git a/lib/services/coins/nano/nano_wallet.dart b/lib/services/coins/nano/nano_wallet.dart index 2bfd42db6..c0a5eb853 100644 --- a/lib/services/coins/nano/nano_wallet.dart +++ b/lib/services/coins/nano/nano_wallet.dart @@ -504,7 +504,8 @@ class NanoWallet extends CoinServiceAPI "count": "-1", })); final data = await jsonDecode(response.body); - final transactions = data["history"] as List; + final transactions = + data["history"] is List ? data["history"] as List : []; if (transactions.isEmpty) { return; } else { @@ -775,15 +776,20 @@ class NanoWallet extends CoinServiceAPI } @override - Future testNetworkConnection() { - http - .get(Uri.parse("${getCurrentNode().host}?action=version")) - .then((response) { - if (response.statusCode == 200) { - return true; - } - }); - return Future.value(false); + Future testNetworkConnection() async { + final uri = Uri.parse(getCurrentNode().host); + + final response = await http.post( + uri, + headers: {"Content-Type": "application/json"}, + body: jsonEncode( + { + "action": "version", + }, + ), + ); + + return response.statusCode == 200; } Timer? _networkAliveTimer; @@ -876,7 +882,9 @@ class NanoWallet extends CoinServiceAPI ); final infoData = jsonDecode(infoResponse.body); - final int height = int.parse(infoData["confirmation_height"].toString()); - await updateCachedChainHeight(height); + final int? height = int.tryParse( + infoData["confirmation_height"].toString(), + ); + await updateCachedChainHeight(height ?? 0); } } diff --git a/lib/themes/theme_service.dart b/lib/themes/theme_service.dart index 95a7475f7..f384a0f19 100644 --- a/lib/themes/theme_service.dart +++ b/lib/themes/theme_service.dart @@ -58,6 +58,12 @@ class ThemeService { applicationThemesDirectoryPath: themesDir.path, ); + try { + theme.assets; + } catch (_) { + throw Exception("Invalid theme: Failed to create assets object"); + } + final String assetsPath = "${themesDir.path}/${theme.themeId}"; for (final file in archive.files) { @@ -167,9 +173,15 @@ class ThemeService { // TODO more thorough check/verification of theme Future verifyInstalled({required String themeId}) async { - final dbHasTheme = - await db.isar.stackThemes.where().themeIdEqualTo(themeId).count() > 0; - if (dbHasTheme) { + final theme = + await db.isar.stackThemes.where().themeIdEqualTo(themeId).findFirst(); + if (theme != null) { + try { + theme.assets; + } catch (_) { + return false; + } + final themesDir = await StackFileSystem.applicationThemesDirectory(); final jsonFileExists = await File("${themesDir.path}/$themeId/theme.json").exists(); diff --git a/lib/utilities/amount/amount_unit.dart b/lib/utilities/amount/amount_unit.dart index 6a03c8f0f..ee54f6d1a 100644 --- a/lib/utilities/amount/amount_unit.dart +++ b/lib/utilities/amount/amount_unit.dart @@ -81,7 +81,8 @@ extension AmountUnitExt on AmountUnit { return "gwei"; } else if (coin == Coin.wownero || coin == Coin.monero || - coin == Coin.nano) { + coin == Coin.nano || + coin == Coin.banano) { return "n${coin.ticker}"; } else { return "sats"; @@ -91,7 +92,8 @@ extension AmountUnitExt on AmountUnit { return "mwei"; } else if (coin == Coin.wownero || coin == Coin.monero || - coin == Coin.nano) { + coin == Coin.nano || + coin == Coin.banano) { return "p${coin.ticker}"; } else { return "invalid"; @@ -99,7 +101,7 @@ extension AmountUnitExt on AmountUnit { case AmountUnit.femto: if (coin == Coin.ethereum) { return "kwei"; - } else if (coin == Coin.nano) { + } else if (coin == Coin.nano || coin == Coin.banano) { return "f${coin.ticker}"; } else { return "invalid"; @@ -107,31 +109,31 @@ extension AmountUnitExt on AmountUnit { case AmountUnit.atto: if (coin == Coin.ethereum) { return "wei"; - } else if (coin == Coin.nano) { + } else if (coin == Coin.nano || coin == Coin.banano) { return "a${coin.ticker}"; } else { return "invalid"; } case AmountUnit.zepto: - if (coin == Coin.nano) { + if (coin == Coin.nano || coin == Coin.banano) { return "z${coin.ticker}"; } else { return "invalid"; } case AmountUnit.yocto: - if (coin == Coin.nano) { + if (coin == Coin.nano || coin == Coin.banano) { return "y${coin.ticker}"; } else { return "invalid"; } case AmountUnit.ronto: - if (coin == Coin.nano) { + if (coin == Coin.nano || coin == Coin.banano) { return "r${coin.ticker}"; } else { return "invalid"; } case AmountUnit.quecto: - if (coin == Coin.nano) { + if (coin == Coin.nano || coin == Coin.banano) { return "q${coin.ticker}"; } else { return "invalid"; diff --git a/lib/utilities/enums/coin_enum.dart b/lib/utilities/enums/coin_enum.dart index 590525b49..2a803cc56 100644 --- a/lib/utilities/enums/coin_enum.dart +++ b/lib/utilities/enums/coin_enum.dart @@ -31,6 +31,7 @@ import 'package:stackwallet/services/coins/wownero/wownero_wallet.dart' as wow; import 'package:stackwallet/utilities/constants.dart'; enum Coin { + banano, bitcoin, bitcoincash, dogecoin, @@ -41,10 +42,9 @@ enum Coin { litecoin, monero, namecoin, + nano, particl, wownero, - nano, - banano, /// @@ -52,10 +52,10 @@ enum Coin { /// bitcoinTestNet, - litecoinTestNet, bitcoincashTestnet, dogecoinTestNet, firoTestNet, + litecoinTestNet, } final int kTestNetCoinCount = 4; // Util.isDesktop ? 5 : 4; diff --git a/lib/utilities/prefs.dart b/lib/utilities/prefs.dart index 1c2d20c71..7c306bfe5 100644 --- a/lib/utilities/prefs.dart +++ b/lib/utilities/prefs.dart @@ -8,8 +8,6 @@ * */ -import 'dart:math'; - import 'package:flutter/cupertino.dart'; import 'package:stackwallet/db/hive/db.dart'; import 'package:stackwallet/utilities/amount/amount_unit.dart'; @@ -866,8 +864,8 @@ class Prefs extends ChangeNotifier { boxName: DB.boxNamePrefs, key: "maxDecimalsFor${coin.name}", ) as int? ?? - max(coin.decimals, - 18); // use some sane max rather than up to 30 that nano uses + (coin.decimals > 18 ? 18 : coin.decimals); + // use some sane max rather than up to 30 that nano uses _amountDecimals[coin] = decimals; } } diff --git a/lib/widgets/animated_widgets/rotating_arrows.dart b/lib/widgets/animated_widgets/rotating_arrows.dart index 04d6d0394..df7c72897 100644 --- a/lib/widgets/animated_widgets/rotating_arrows.dart +++ b/lib/widgets/animated_widgets/rotating_arrows.dart @@ -17,6 +17,8 @@ class RotatingArrowsController { VoidCallback? forward; VoidCallback? repeat; VoidCallback? stop; + + bool hasLoadedAnimation = false; } class RotatingArrows extends StatefulWidget { @@ -86,6 +88,7 @@ class _RotatingArrowsState extends State ), onLoaded: (composition) { animationController.duration = composition.duration; + widget.controller?.hasLoadedAnimation = true; // if controller was not set just assume continuous repeat if (widget.spinByDefault) { diff --git a/pubspec.lock b/pubspec.lock index 01209ce91..0fd25520b 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -17,14 +17,6 @@ packages: url: "https://pub.dev" source: hosted version: "5.13.0" - animations: - dependency: "direct main" - description: - name: animations - sha256: fe8a6bdca435f718bb1dc8a11661b2c22504c6da40ef934cee8327ed77934164 - url: "https://pub.dev" - source: hosted - version: "2.0.7" another_flushbar: dependency: "direct main" description: @@ -33,14 +25,6 @@ packages: url: "https://pub.dev" source: hosted version: "1.12.30" - app_settings: - dependency: "direct main" - description: - name: app_settings - sha256: "66715a323ac36d6c8201035ba678777c0d2ea869e4d7064300d95af10c3bb8cb" - url: "https://pub.dev" - source: hosted - version: "4.2.0" archive: dependency: "direct main" description: @@ -93,8 +77,8 @@ packages: dependency: "direct main" description: path: "." - ref: "9e3927a53a606cc3f87f98c5cba36e9fd59917a5" - resolved-ref: "9e3927a53a606cc3f87f98c5cba36e9fd59917a5" + ref: b6d2a5b4cd17311d917787c0f9505f04932659b1 + resolved-ref: b6d2a5b4cd17311d917787c0f9505f04932659b1 url: "https://github.com/cypherstack/bech32.git" source: git version: "0.2.1" @@ -110,8 +94,8 @@ packages: dependency: "direct main" description: path: "." - ref: "787814bfea1af30ecf9d90c2c416846def1801f1" - resolved-ref: "787814bfea1af30ecf9d90c2c416846def1801f1" + ref: "0cd6d54e2860bea68fc50c801cb9db2a760192fb" + resolved-ref: "0cd6d54e2860bea68fc50c801cb9db2a760192fb" url: "https://github.com/cypherstack/stack-bip39.git" source: git version: "1.0.6" @@ -119,8 +103,8 @@ packages: dependency: "direct main" description: path: "." - ref: f0e50250f84438a11364018f8ed3dd5c09ab2e7b - resolved-ref: f0e50250f84438a11364018f8ed3dd5c09ab2e7b + ref: "081ca1863c2feba00c35bb5b297902f12f499941" + resolved-ref: "081ca1863c2feba00c35bb5b297902f12f499941" url: "https://github.com/cypherstack/bip47.git" source: git version: "2.0.0" @@ -137,8 +121,8 @@ packages: dependency: "direct main" description: path: "." - ref: "6136230e660fd1f681d18c75d38ca7de4d81187c" - resolved-ref: "6136230e660fd1f681d18c75d38ca7de4d81187c" + ref: af6d6c27edfe2e7cc35772ed2684eb4cc826f0e4 + resolved-ref: af6d6c27edfe2e7cc35772ed2684eb4cc826f0e4 url: "https://github.com/cypherstack/bitcoindart.git" source: git version: "3.0.1" @@ -950,14 +934,6 @@ packages: url: "https://pub.dev" source: hosted version: "3.0.2" - jsonrpc2: - dependency: "direct main" - description: - name: jsonrpc2 - sha256: "98a71b834240ca6d003499ab8f28d1c35aa8ca90235b51e972e0f70596b86bd3" - url: "https://pub.dev" - source: hosted - version: "3.0.1" keyboard_dismisser: dependency: "direct main" description: @@ -1341,22 +1317,6 @@ packages: url: "https://pub.dev" source: hosted version: "1.0.3" - rpc_dispatcher: - dependency: transitive - description: - name: rpc_dispatcher - sha256: b6ddcae58b3fbc1172a7c2dc8ab30d2f1090db8c7a728e4405bd10142dc48a47 - url: "https://pub.dev" - source: hosted - version: "1.0.1" - rpc_exceptions: - dependency: transitive - description: - name: rpc_exceptions - sha256: "09b2e5f3f805b65a262b40e3410d79fb916ff5be2a65e2f6b8b0eeef7aa965b7" - url: "https://pub.dev" - source: hosted - version: "1.0.1" rxdart: dependency: "direct main" description: @@ -1571,14 +1531,6 @@ packages: url: "https://pub.dev" source: hosted version: "1.2.0" - string_to_hex: - dependency: "direct main" - description: - name: string_to_hex - sha256: "63e5dc1f4821a2449d505033fbd4569f7020ebf30ddffb54d00ebaba8e144a49" - url: "https://pub.dev" - source: hosted - version: "0.2.2" string_validator: dependency: "direct main" description: @@ -1807,7 +1759,7 @@ packages: dependency: "direct overridden" description: path: wakelock_windows - ref: win32-v5 + ref: "2a9bca63a540771f241d688562351482b2cf234c" resolved-ref: "2a9bca63a540771f241d688562351482b2cf234c" url: "https://github.com/timsneath/wakelock" source: git diff --git a/pubspec.yaml b/pubspec.yaml index 01b42ae08..685c10267 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -11,7 +11,7 @@ description: Stack Wallet # In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion. # Read more about iOS versioning at # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html -version: 1.7.12+177 +version: 1.7.13+178 environment: sdk: ">=3.0.2 <4.0.0" @@ -42,16 +42,10 @@ dependencies: flutter_libepiccash: path: ./crypto_plugins/flutter_libepiccash -# firo_flutter: -# git: -# url: https://github.com/cypherstack/firo_flutter.git -# ref: update - # path: ./crypto_plugins/firo_flutter - bitcoindart: git: url: https://github.com/cypherstack/bitcoindart.git - ref: 6136230e660fd1f681d18c75d38ca7de4d81187c + ref: af6d6c27edfe2e7cc35772ed2684eb4cc826f0e4 stack_wallet_backup: git: @@ -61,7 +55,7 @@ dependencies: bip47: git: url: https://github.com/cypherstack/bip47.git - ref: f0e50250f84438a11364018f8ed3dd5c09ab2e7b + ref: 081ca1863c2feba00c35bb5b297902f12f499941 # Utility plugins http: ^0.13.0 @@ -69,7 +63,6 @@ dependencies: permission_handler: ^10.0.0 flutter_local_notifications: ^9.4.0 rxdart: ^0.27.3 -# filesystem_picker: ^3.0.0-beta.1 zxcvbn: ^1.0.0 dart_numerics: ^0.0.6 @@ -82,7 +75,7 @@ dependencies: bip39: git: url: https://github.com/cypherstack/stack-bip39.git - ref: 787814bfea1af30ecf9d90c2c416846def1801f1 + ref: 0cd6d54e2860bea68fc50c801cb9db2a760192fb bitbox: git: url: https://github.com/PiRK/bitbox-flutter.git @@ -91,12 +84,11 @@ dependencies: bech32: git: url: https://github.com/cypherstack/bech32.git - ref: 9e3927a53a606cc3f87f98c5cba36e9fd59917a5 + ref: b6d2a5b4cd17311d917787c0f9505f04932659b1 bs58check: ^1.0.2 # Eth Plugins web3dart: 2.6.1 - string_to_hex: 0.2.2 ethereum_addresses: 1.0.2 # Storage plugins @@ -107,7 +99,6 @@ dependencies: # UI/Component plugins flutter_native_splash: ^2.2.4 - animations: ^2.0.2 google_fonts: ^4.0.4 url_launcher: ^6.0.5 flutter_svg: ^1.0.1 @@ -117,9 +108,7 @@ dependencies: uuid: ^3.0.5 flutter_rounded_date_picker: ^3.0.1 crypto: ^3.0.2 - jsonrpc2: ^3.0.1 barcode_scan2: ^4.2.0 - app_settings: ^4.1.1 wakelock: ^0.6.2 intl: ^0.17.0 devicelocale: ^0.6.0 @@ -134,11 +123,8 @@ dependencies: pointycastle: ^3.6.0 package_info_plus: ^4.0.2 lottie: ^2.3.2 -# shared_preferences: ^2.0.15 file_picker: ^5.3.1 -# connectivity_plus: 2.3.6+1 connectivity_plus: ^4.0.1 -# document_file_save_plus: ^1.0.5 isar: 3.0.5 isar_flutter_libs: 3.0.5 # contains the binaries dropdown_button2: ^2.1.3 @@ -192,25 +178,27 @@ flutter_native_splash: android_disable_fullscreen: true dependency_overrides: + + # required for dart 3, at least until a fix is merged upstream wakelock_windows: git: url: https://github.com/timsneath/wakelock - ref: win32-v5 + ref: 2a9bca63a540771f241d688562351482b2cf234c path: wakelock_windows + + # required for libmonero - can remove once libmonero has been updated, PR has been merged in swb stack_wallet_backup: git: url: https://github.com/cypherstack/stack_wallet_backup.git ref: ee1da8a9ba1cbeb50c5b354ea1fd5a25b7c5a3ed - bech32: - git: - url: https://github.com/cypherstack/bech32.git - ref: 9e3927a53a606cc3f87f98c5cba36e9fd59917a5 + + # required override for nanodart bip39: git: url: https://github.com/cypherstack/stack-bip39.git - ref: 787814bfea1af30ecf9d90c2c416846def1801f1 - crypto: 3.0.2 - flutter_secure_storage: ^8.0.0 + ref: 0cd6d54e2860bea68fc50c801cb9db2a760192fb + + # For information on the generic Dart part of this file, see the # following page: https://dart.dev/tools/pub/pubspec diff --git a/test/pages/send_view/send_view_test.dart b/test/pages/send_view/send_view_test.dart index fed61f2e4..1747ddc17 100644 --- a/test/pages/send_view/send_view_test.dart +++ b/test/pages/send_view/send_view_test.dart @@ -16,6 +16,7 @@ import 'package:stackwallet/services/wallets.dart'; import 'package:stackwallet/services/wallets_service.dart'; import 'package:stackwallet/themes/stack_colors.dart'; import 'package:stackwallet/themes/theme_service.dart'; +import 'package:stackwallet/utilities/amount/amount_unit.dart'; import 'package:stackwallet/utilities/enums/coin_enum.dart'; import 'package:stackwallet/utilities/prefs.dart'; @@ -35,155 +36,161 @@ import 'send_view_test.mocks.dart'; MockSpec(returnNullOnMissingStub: true), ]) void main() { - // testWidgets("Send to valid address", (widgetTester) async { - // final mockWallets = MockWallets(); - // final mockWalletsService = MockWalletsService(); - // final mockNodeService = MockNodeService(); - // final CoinServiceAPI wallet = MockBitcoinWallet(); - // final mockLocaleService = MockLocaleService(); - // final mockThemeService = MockThemeService(); - // final mockPrefs = MockPrefs(); - // - // when(wallet.coin).thenAnswer((_) => Coin.bitcoin); - // when(wallet.walletName).thenAnswer((_) => "some wallet"); - // when(wallet.walletId).thenAnswer((_) => "wallet id"); - // - // final manager = Manager(wallet); - // when(mockWallets.getManagerProvider("wallet id")).thenAnswer( - // (realInvocation) => ChangeNotifierProvider((ref) => manager)); - // when(mockWallets.getManager("wallet id")) - // .thenAnswer((realInvocation) => manager); - // - // when(mockLocaleService.locale).thenAnswer((_) => "en_US"); - // when(mockThemeService.getTheme(themeId: "light")).thenAnswer( - // (_) => StackTheme.fromJson( - // json: lightThemeJsonMap, - // applicationThemesDirectoryPath: "test", - // ), - // ); - // when(mockPrefs.currency).thenAnswer((_) => "USD"); - // when(mockPrefs.enableCoinControl).thenAnswer((_) => false); - // when(wallet.validateAddress("send to address")) - // .thenAnswer((realInvocation) => true); - // - // await widgetTester.pumpWidget( - // ProviderScope( - // overrides: [ - // walletsChangeNotifierProvider.overrideWithValue(mockWallets), - // walletsServiceChangeNotifierProvider - // .overrideWithValue(mockWalletsService), - // nodeServiceChangeNotifierProvider.overrideWithValue(mockNodeService), - // localeServiceChangeNotifierProvider - // .overrideWithValue(mockLocaleService), - // prefsChangeNotifierProvider.overrideWithValue(mockPrefs), - // pThemeService.overrideWithValue(mockThemeService), - // // previewTxButtonStateProvider - // ], - // child: MaterialApp( - // theme: ThemeData( - // extensions: [ - // StackColors.fromStackColorTheme( - // StackTheme.fromJson( - // json: lightThemeJsonMap, - // applicationThemesDirectoryPath: "test", - // ), - // ), - // ], - // ), - // home: SendView( - // walletId: "wallet id", - // coin: Coin.bitcoin, - // autoFillData: SendViewAutoFillData( - // address: "send to address", contactLabel: "contact label"), - // ), - // ), - // ), - // ); - // - // await widgetTester.pumpAndSettle(); - // - // expect(find.text("Send to"), findsOneWidget); - // expect(find.text("Amount"), findsOneWidget); - // expect(find.text("Note (optional)"), findsOneWidget); - // expect(find.text("Transaction fee (estimated)"), findsOneWidget); - // verify(manager.validateAddress("send to address")).called(1); - // }); + testWidgets("Send to valid address", (widgetTester) async { + final mockWallets = MockWallets(); + final mockWalletsService = MockWalletsService(); + final mockNodeService = MockNodeService(); + final CoinServiceAPI wallet = MockBitcoinWallet(); + final mockLocaleService = MockLocaleService(); + final mockThemeService = MockThemeService(); + final mockPrefs = MockPrefs(); - // testWidgets("Send to invalid address", (widgetTester) async { - // final mockWallets = MockWallets(); - // final mockWalletsService = MockWalletsService(); - // final mockNodeService = MockNodeService(); - // final CoinServiceAPI wallet = MockBitcoinWallet(); - // final mockLocaleService = MockLocaleService(); - // final mockPrefs = MockPrefs(); - // final mockThemeService = MockThemeService(); - // - // when(wallet.coin).thenAnswer((_) => Coin.bitcoin); - // when(wallet.walletName).thenAnswer((_) => "some wallet"); - // when(wallet.walletId).thenAnswer((_) => "wallet id"); - // - // final manager = Manager(wallet); - // when(mockWallets.getManagerProvider("wallet id")).thenAnswer( - // (realInvocation) => ChangeNotifierProvider((ref) => manager)); - // when(mockWallets.getManager("wallet id")) - // .thenAnswer((realInvocation) => manager); - // - // when(mockLocaleService.locale).thenAnswer((_) => "en_US"); - // when(mockPrefs.currency).thenAnswer((_) => "USD"); - // when(mockPrefs.enableCoinControl).thenAnswer((_) => false); - // when(wallet.validateAddress("send to address")) - // .thenAnswer((realInvocation) => false); - // when(mockThemeService.getTheme(themeId: "light")).thenAnswer( - // (_) => StackTheme.fromJson( - // json: lightThemeJsonMap, - // applicationThemesDirectoryPath: "test", - // ), - // ); - // - // // when(manager.isOwnAddress("send to address")) - // // .thenAnswer((realInvocation) => Future(() => true)); - // - // await widgetTester.pumpWidget( - // ProviderScope( - // overrides: [ - // walletsChangeNotifierProvider.overrideWithValue(mockWallets), - // walletsServiceChangeNotifierProvider - // .overrideWithValue(mockWalletsService), - // nodeServiceChangeNotifierProvider.overrideWithValue(mockNodeService), - // localeServiceChangeNotifierProvider - // .overrideWithValue(mockLocaleService), - // prefsChangeNotifierProvider.overrideWithValue(mockPrefs), - // pThemeService.overrideWithValue(mockThemeService) - // // previewTxButtonStateProvider - // ], - // child: MaterialApp( - // theme: ThemeData( - // extensions: [ - // StackColors.fromStackColorTheme( - // StackTheme.fromJson( - // json: lightThemeJsonMap, - // applicationThemesDirectoryPath: "test", - // ), - // ), - // ], - // ), - // home: SendView( - // walletId: "wallet id", - // coin: Coin.bitcoin, - // autoFillData: SendViewAutoFillData( - // address: "send to address", contactLabel: "contact label"), - // ), - // ), - // ), - // ); - // - // await widgetTester.pumpAndSettle(); - // - // expect(find.text("Send to"), findsOneWidget); - // expect(find.text("Amount"), findsOneWidget); - // expect(find.text("Note (optional)"), findsOneWidget); - // expect(find.text("Transaction fee (estimated)"), findsOneWidget); - // expect(find.text("Invalid address"), findsOneWidget); - // verify(manager.validateAddress("send to address")).called(1); - // }); + when(wallet.coin).thenAnswer((_) => Coin.bitcoin); + when(wallet.walletName).thenAnswer((_) => "some wallet"); + when(wallet.walletId).thenAnswer((_) => "wallet id"); + + final manager = Manager(wallet); + when(mockWallets.getManagerProvider("wallet id")).thenAnswer( + (realInvocation) => ChangeNotifierProvider((ref) => manager)); + when(mockWallets.getManager("wallet id")) + .thenAnswer((realInvocation) => manager); + + when(mockLocaleService.locale).thenAnswer((_) => "en_US"); + when(mockThemeService.getTheme(themeId: "light")).thenAnswer( + (_) => StackTheme.fromJson( + json: lightThemeJsonMap, + applicationThemesDirectoryPath: "test", + ), + ); + when(mockPrefs.currency).thenAnswer((_) => "USD"); + when(mockPrefs.enableCoinControl).thenAnswer((_) => false); + when(mockPrefs.amountUnit(Coin.bitcoin)).thenAnswer( + (_) => AmountUnit.normal, + ); + when(wallet.validateAddress("send to address")) + .thenAnswer((realInvocation) => true); + + await widgetTester.pumpWidget( + ProviderScope( + overrides: [ + walletsChangeNotifierProvider.overrideWithValue(mockWallets), + walletsServiceChangeNotifierProvider + .overrideWithValue(mockWalletsService), + nodeServiceChangeNotifierProvider.overrideWithValue(mockNodeService), + localeServiceChangeNotifierProvider + .overrideWithValue(mockLocaleService), + prefsChangeNotifierProvider.overrideWithValue(mockPrefs), + pThemeService.overrideWithValue(mockThemeService), + // previewTxButtonStateProvider + ], + child: MaterialApp( + theme: ThemeData( + extensions: [ + StackColors.fromStackColorTheme( + StackTheme.fromJson( + json: lightThemeJsonMap, + applicationThemesDirectoryPath: "test", + ), + ), + ], + ), + home: SendView( + walletId: "wallet id", + coin: Coin.bitcoin, + autoFillData: SendViewAutoFillData( + address: "send to address", contactLabel: "contact label"), + ), + ), + ), + ); + + await widgetTester.pumpAndSettle(); + + expect(find.text("Send to"), findsOneWidget); + expect(find.text("Amount"), findsOneWidget); + expect(find.text("Note (optional)"), findsOneWidget); + expect(find.text("Transaction fee (estimated)"), findsOneWidget); + verify(manager.validateAddress("send to address")).called(1); + }); + + testWidgets("Send to invalid address", (widgetTester) async { + final mockWallets = MockWallets(); + final mockWalletsService = MockWalletsService(); + final mockNodeService = MockNodeService(); + final CoinServiceAPI wallet = MockBitcoinWallet(); + final mockLocaleService = MockLocaleService(); + final mockPrefs = MockPrefs(); + final mockThemeService = MockThemeService(); + + when(wallet.coin).thenAnswer((_) => Coin.bitcoin); + when(wallet.walletName).thenAnswer((_) => "some wallet"); + when(wallet.walletId).thenAnswer((_) => "wallet id"); + + final manager = Manager(wallet); + when(mockWallets.getManagerProvider("wallet id")).thenAnswer( + (realInvocation) => ChangeNotifierProvider((ref) => manager)); + when(mockWallets.getManager("wallet id")) + .thenAnswer((realInvocation) => manager); + + when(mockLocaleService.locale).thenAnswer((_) => "en_US"); + when(mockPrefs.currency).thenAnswer((_) => "USD"); + when(mockPrefs.enableCoinControl).thenAnswer((_) => false); + when(mockPrefs.amountUnit(Coin.bitcoin)).thenAnswer( + (_) => AmountUnit.normal, + ); + when(wallet.validateAddress("send to address")) + .thenAnswer((realInvocation) => false); + when(mockThemeService.getTheme(themeId: "light")).thenAnswer( + (_) => StackTheme.fromJson( + json: lightThemeJsonMap, + applicationThemesDirectoryPath: "test", + ), + ); + + // when(manager.isOwnAddress("send to address")) + // .thenAnswer((realInvocation) => Future(() => true)); + + await widgetTester.pumpWidget( + ProviderScope( + overrides: [ + walletsChangeNotifierProvider.overrideWithValue(mockWallets), + walletsServiceChangeNotifierProvider + .overrideWithValue(mockWalletsService), + nodeServiceChangeNotifierProvider.overrideWithValue(mockNodeService), + localeServiceChangeNotifierProvider + .overrideWithValue(mockLocaleService), + prefsChangeNotifierProvider.overrideWithValue(mockPrefs), + pThemeService.overrideWithValue(mockThemeService) + // previewTxButtonStateProvider + ], + child: MaterialApp( + theme: ThemeData( + extensions: [ + StackColors.fromStackColorTheme( + StackTheme.fromJson( + json: lightThemeJsonMap, + applicationThemesDirectoryPath: "test", + ), + ), + ], + ), + home: SendView( + walletId: "wallet id", + coin: Coin.bitcoin, + autoFillData: SendViewAutoFillData( + address: "send to address", contactLabel: "contact label"), + ), + ), + ), + ); + + await widgetTester.pumpAndSettle(); + + expect(find.text("Send to"), findsOneWidget); + expect(find.text("Amount"), findsOneWidget); + expect(find.text("Note (optional)"), findsOneWidget); + expect(find.text("Transaction fee (estimated)"), findsOneWidget); + expect(find.text("Invalid address"), findsOneWidget); + verify(manager.validateAddress("send to address")).called(1); + }); } diff --git a/test/pages/send_view/send_view_test.mocks.dart b/test/pages/send_view/send_view_test.mocks.dart index cf222589e..631b28ca5 100644 --- a/test/pages/send_view/send_view_test.mocks.dart +++ b/test/pages/send_view/send_view_test.mocks.dart @@ -987,7 +987,7 @@ class MockBitcoinWallet extends _i1.Mock implements _i27.BitcoinWallet { @override _i22.Coin get coin => (super.noSuchMethod( Invocation.getter(#coin), - returnValue: _i22.Coin.bitcoin, + returnValue: _i22.Coin.banano, ) as _i22.Coin); @override _i23.Future> get utxos => (super.noSuchMethod( @@ -2837,7 +2837,7 @@ class MockManager extends _i1.Mock implements _i6.Manager { @override _i22.Coin get coin => (super.noSuchMethod( Invocation.getter(#coin), - returnValue: _i22.Coin.bitcoin, + returnValue: _i22.Coin.banano, ) as _i22.Coin); @override bool get isRefreshing => (super.noSuchMethod( @@ -3205,7 +3205,7 @@ class MockCoinServiceAPI extends _i1.Mock implements _i20.CoinServiceAPI { @override _i22.Coin get coin => (super.noSuchMethod( Invocation.getter(#coin), - returnValue: _i22.Coin.bitcoin, + returnValue: _i22.Coin.banano, ) as _i22.Coin); @override bool get isRefreshing => (super.noSuchMethod( diff --git a/test/price_test.dart b/test/price_test.dart index 58dc797e4..dfca4e212 100644 --- a/test/price_test.dart +++ b/test/price_test.dart @@ -21,328 +21,383 @@ void main() { boxName: DB.boxNamePrefs, key: "externalCalls", value: true); }); - // test("getPricesAnd24hChange fetch", () async { - // final client = MockClient(); - // - // when(client.get( - // Uri.parse( - // "https://api.coingecko.com/api/v3/coins/markets?vs_currency=btc&ids" - // "=monero,bitcoin,litecoin,ecash,epic-cash,zcoin,dogecoin,bitcoin-cash" - // ",namecoin,wownero,ethereum,particl&order=market_cap_desc&per_page=50" - // "&page=1&sparkline=false"), - // headers: { - // 'Content-Type': 'application/json' - // })).thenAnswer((_) async => Response( - // '[{"id":"bitcoin","symbol":"btc","name":"Bitcoin","image":"https://asse' - // 'ts.coingecko.com/coins/images/1/large/bitcoin.png?1547033579","curr' - // 'ent_price":1.0,"market_cap":19128800,"market_cap_rank":1,"fully_dil' - // 'uted_valuation":21000000,"total_volume":1272132,"high_24h":1.0,"low' - // '_24h":1.0,"price_change_24h":0.0,"price_change_percentage_24h":0.0,' - // '"market_cap_change_24h":950.0,"market_cap_change_percentage_24h":0.0' - // '0497,"circulating_supply":19128800.0,"total_supply":21000000.0,"max' - // '_supply":21000000.0,"ath":1.003301,"ath_change_percentage":-0.32896' - // ',"ath_date":"2019-10-15T16:00:56.136Z","atl":0.99895134,"atl_change_' - // 'percentage":0.10498,"atl_date":"2019-10-21T00:00:00.000Z","roi":nul' - // 'l,"last_updated":"2022-08-22T16:37:59.237Z"},{"id":"dogecoin","symb' - // 'ol":"doge","name":"Dogecoin","image":"https://assets.coingecko.com/' - // 'coins/images/5/large/dogecoin.png?1547792256","current_price":3.15e' - // '-06,"market_cap":417916,"market_cap_rank":10,"fully_diluted_valuati' - // 'on":null,"total_volume":27498,"high_24h":3.26e-06,"low_24h":3.13e-0' - // '6,"price_change_24h":-8.6889947714e-08,"price_change_percentage_24h' - // '":-2.68533,"market_cap_change_24h":-11370.894861206936,"market_cap_c' - // 'hange_percentage_24h":-2.64879,"circulating_supply":132670764299.89' - // '4,"total_supply":null,"max_supply":null,"ath":1.264e-05,"ath_change' - // '_percentage":-75.05046,"ath_date":"2021-05-07T23:04:53.026Z","atl":' - // '1.50936e-07,"atl_change_percentage":1989.69346,"atl_date":"2020-12-' - // '17T09:18:05.654Z","roi":null,"last_updated":"2022-08-22T16:38:15.11' - // '3Z"},{"id":"monero","symbol":"xmr","name":"Monero","image":"https:/' - // '/assets.coingecko.com/coins/images/69/large/monero_logo.png?1547033' - // '729","current_price":0.00717236,"market_cap":130002,"market_cap_ran' - // 'k":29,"fully_diluted_valuation":null,"total_volume":4901,"high_24h":' - // '0.00731999,"low_24h":0.00707511,"price_change_24h":-5.6133543212467' - // 'e-05,"price_change_percentage_24h":-0.77656,"market_cap_change_24h"' - // ':-1007.8447677436197,"market_cap_change_percentage_24h":-0.76929,"c' - // 'irculating_supply":18147820.3764146,"total_supply":null,"max_supply' - // '":null,"ath":0.03475393,"ath_change_percentage":-79.32037,"ath_date' - // '":"2018-01-09T00:00:00.000Z","atl":0.00101492,"atl_change_percentag' - // 'e":608.13327,"atl_date":"2014-12-18T00:00:00.000Z","roi":null,"las' - // 't_updated":"2022-08-22T16:38:26.347Z"},{"id":"zcoin","symbol":"firo' - // '","name":"Firo","image":"https://assets.coingecko.com/coins/images/' - // '479/large/firocoingecko.png?1636537544","current_price":0.0001096,"' - // 'market_cap":1252,"market_cap_rank":604,"fully_diluted_valuation":234' - // '9,"total_volume":90.573,"high_24h":0.00011148,"low_24h":0.00010834,' - // '"price_change_24h":-9.87561775002e-07,"price_change_percentage_24h' - // '":-0.89304,"market_cap_change_24h":-10.046635178462793,"market_cap_' - // 'change_percentage_24h":-0.79578,"circulating_supply":11411043.83546' - // '97,"total_supply":21400000.0,"max_supply":21400000.0,"ath":0.016162' - // '72,"ath_change_percentage":-99.3208,"ath_date":"2018-04-04T16:04:48.' - // '408Z","atl":4.268e-05,"atl_change_percentage":157.22799,"atl_date":"' - // '2022-05-12T07:28:47.088Z","roi":null,"last_updated":"2022-08-22T16' - // ':38:47.229Z"},{"id":"epic-cash","symbol":"epic","name":"Epic Cash",' - // '"image":"https://assets.coingecko.com/coins/images/9520/large/Epic_C' - // 'oin_NO_drop_shadow.png?1620122642","current_price":2.803e-05,"marke' - // 't_cap":415.109,"market_cap_rank":953,"fully_diluted_valuation":null' - // ',"total_volume":0.2371557,"high_24h":3.053e-05,"low_24h":2.581e-05' - // ',"price_change_24h":1.9e-06,"price_change_percentage_24h":7.27524,"' - // 'market_cap_change_24h":28.26753,"market_cap_change_percentage_24h":' - // '7.30726,"circulating_supply":14808052.0,"total_supply":21000000.0,"' - // 'max_supply":null,"ath":0.00013848,"ath_change_percentage":-79.75864' - // ',"ath_date":"2021-12-11T08:39:41.129Z","atl":5.74028e-07,"atl_chang' - // 'e_percentage":4783.08078,"atl_date":"2020-03-13T16:55:01.177Z","roi' - // '":null,"last_updated":"2022-08-22T16:38:32.826Z"}]', - // 200)); - // - // final priceAPI = PriceAPI(client); - // priceAPI.resetLastCalledToForceNextCallToUpdateCache(); - // - // final price = await priceAPI.getPricesAnd24hChange(baseCurrency: "btc"); - // - // expect( - // price.toString(), - // '{Coin.bitcoin: [1, 0.0], Coin.bitcoincash: [0, 0.0], ' - // 'Coin.dogecoin: [0.00000315, -2.68533], ' - // 'Coin.eCash: [0, 0.0], Coin.epicCash: [0.00002803, 7.27524], ' - // 'Coin.ethereum: [0, 0.0], ' - // 'Coin.firo: [0.0001096, -0.89304], Coin.litecoin: [0, 0.0], ' - // 'Coin.monero: [0.00717236, -0.77656], Coin.namecoin: [0, 0.0], ' - // 'Coin.particl: [0, 0.0], Coin.wownero: [0, 0.0], ' - // 'Coin.bitcoinTestNet: [0, 0.0],' - // ' Coin.litecoinTestNet: [0, 0.0], Coin.bitcoincashTestnet: [0, 0.0], ' - // 'Coin.dogecoinTestNet: [0, 0.0], Coin.firoTestNet: [0, 0.0]}', - // ); - // verify(client.get( - // Uri.parse( - // "https://api.coingecko.com/api/v3/coins/markets?vs_currency=btc" - // "&ids=monero,bitcoin,litecoin,ecash,epic-cash,zcoin,dogecoin," - // "bitcoin-cash,namecoin,wownero,ethereum,particl" - // "&order=market_cap_desc&per_page=50&page=1&sparkline=false", - // ), - // headers: {'Content-Type': 'application/json'})).called(1); - // - // verifyNoMoreInteractions(client); - // }); + test("getPricesAnd24hChange fetch", () async { + final client = MockClient(); - // test("cached price fetch", () async { - // final client = MockClient(); - // - // when(client.get( - // Uri.parse( - // "https://api.coingecko.com/api/v3/coins/markets?vs_currency=btc&" - // "ids=monero,bitcoin,litecoin,ecash,epic-cash,zcoin,dogecoin," - // "bitcoin-cash,namecoin,wownero,ethereum,particl" - // "&order=market_cap_desc&per_page=50&page=1&sparkline=false"), - // headers: { - // 'Content-Type': 'application/json' - // })).thenAnswer((_) async => Response( - // '[{"id":"bitcoin","symbol":"btc","name":"Bitcoin","image":"https://a' - // 'ssets.coingecko.com/coins/images/1/large/bitcoin.png?1547033579","c' - // 'urrent_price":1.0,"market_cap":19128800,"market_cap_rank":1,"fully_' - // 'diluted_valuation":21000000,"total_volume":1272132,"high_24h":1.0,"' - // 'low_24h":1.0,"price_change_24h":0.0,"price_change_percentage_24h":0' - // '.0,"market_cap_change_24h":950.0,"market_cap_change_percentage_24h"' - // ':0.00497,"circulating_supply":19128800.0,"total_supply":21000000.0,"' - // 'max_supply":21000000.0,"ath":1.003301,"ath_change_percentage":-0.32' - // '896,"ath_date":"2019-10-15T16:00:56.136Z","atl":0.99895134,"atl_cha' - // 'nge_percentage":0.10498,"atl_date":"2019-10-21T00:00:00.000Z","roi"' - // ':null,"last_updated":"2022-08-22T16:37:59.237Z"},{"id":"dogecoin","' - // 'symbol":"doge","name":"Dogecoin","image":"https://assets.coingecko.' - // 'com/coins/images/5/large/dogecoin.png?1547792256","current_price":3' - // '.15e-06,"market_cap":417916,"market_cap_rank":10,"fully_diluted_val' - // 'uation":null,"total_volume":27498,"high_24h":3.26e-06,"low_24h":3.1' - // '3e-06,"price_change_24h":-8.6889947714e-08,"price_change_percentage' - // '_24h":-2.68533,"market_cap_change_24h":-11370.894861206936,"market_' - // 'cap_change_percentage_24h":-2.64879,"circulating_supply":1326707642' - // '99.894,"total_supply":null,"max_supply":null,"ath":1.264e-05,"ath_c' - // 'hange_percentage":-75.05046,"ath_date":"2021-05-07T23:04:53.026Z","' - // 'atl":1.50936e-07,"atl_change_percentage":1989.69346,"atl_date":"202' - // '0-12-17T09:18:05.654Z","roi":null,"last_updated":"2022-08-22T16:38:' - // '15.113Z"},{"id":"monero","symbol":"xmr","name":"Monero","image":"ht' - // 'tps://assets.coingecko.com/coins/images/69/large/monero_logo.png?15' - // '47033729","current_price":0.00717236,"market_cap":130002,"market_cap' - // '_rank":29,"fully_diluted_valuation":null,"total_volume":4901,"high' - // '_24h":0.00731999,"low_24h":0.00707511,"price_change_24h":-5.613354' - // '3212467e-05,"price_change_percentage_24h":-0.77656,"market_cap_chan' - // 'ge_24h":-1007.8447677436197,"market_cap_change_percentage_24h":-0.7' - // '6929,"circulating_supply":18147820.3764146,"total_supply":null,"ma' - // 'x_supply":null,"ath":0.03475393,"ath_change_percentage":-79.32037,"' - // 'ath_date":"2018-01-09T00:00:00.000Z","atl":0.00101492,"atl_change_' - // 'percentage":608.13327,"atl_date":"2014-12-18T00:00:00.000Z","roi":n' - // 'ull,"last_updated":"2022-08-22T16:38:26.347Z"},{"id":"zcoin","symbo' - // 'l":"firo","name":"Firo","image":"https://assets.coingecko.com/coins' - // '/images/479/large/firocoingecko.png?1636537544","current_price":0.0' - // '001096,"market_cap":1252,"market_cap_rank":604,"fully_diluted_valu' - // 'ation":2349,"total_volume":90.573,"high_24h":0.00011148,"low_24h":0' - // '.00010834,"price_change_24h":-9.87561775002e-07,"price_change_perce' - // 'ntage_24h":-0.89304,"market_cap_change_24h":-10.046635178462793,"ma' - // 'rket_cap_change_percentage_24h":-0.79578,"circulating_supply":11411' - // '043.8354697,"total_supply":21400000.0,"max_supply":21400000.0,"ath"' - // ':0.01616272,"ath_change_percentage":-99.3208,"ath_date":"2018-04-04' - // 'T16:04:48.408Z","atl":4.268e-05,"atl_change_percentage":157.22799,' - // '"atl_date":"2022-05-12T07:28:47.088Z","roi":null,"last_updated":"2' - // '022-08-22T16:38:47.229Z"},{"id":"epic-cash","symbol":"epic","name":"' - // 'Epic Cash","image":"https://assets.coingecko.com/coins/images/9520/' - // 'large/Epic_Coin_NO_drop_shadow.png?1620122642","current_price":2.80' - // '3e-05,"market_cap":415.109,"market_cap_rank":953,"fully_diluted_val' - // 'uation":null,"total_volume":0.2371557,"high_24h":3.053e-05,"low_24h' - // '":2.581e-05,"price_change_24h":1.9e-06,"price_change_percentage_24' - // 'h":7.27524,"market_cap_change_24h":28.26753,"market_cap_change_perc' - // 'entage_24h":7.30726,"circulating_supply":14808052.0,"total_supply":' - // '21000000.0,"max_supply":null,"ath":0.00013848,"ath_change_percentag' - // 'e":-79.75864,"ath_date":"2021-12-11T08:39:41.129Z","atl":5.74028e-0' - // '7,"atl_change_percentage":4783.08078,"atl_date":"2020-03-13T16:55:01' - // '.177Z","roi":null,"last_updated":"2022-08-22T16:38:32.826Z"}]', - // 200)); - // - // final priceAPI = PriceAPI(client); - // priceAPI.resetLastCalledToForceNextCallToUpdateCache(); - // - // // initial fetch to fill cache - // await priceAPI.getPricesAnd24hChange(baseCurrency: "btc"); - // - // // now this time it should grab from cache instead of http.get - // final cachedPrice = - // await priceAPI.getPricesAnd24hChange(baseCurrency: "btc"); - // - // expect( - // cachedPrice.toString(), - // '{Coin.bitcoin: [1, 0.0], Coin.bitcoincash: [0, 0.0],' - // ' Coin.dogecoin: [0.00000315, -2.68533], Coin.eCash: [0, 0.0], Coin.epicCash: [0.00002803, 7.27524],' - // ' Coin.ethereum: [0, 0.0], Coin.firo: [0.0001096, -0.89304], ' - // 'Coin.litecoin: [0, 0.0], Coin.monero: [0.00717236, -0.77656], ' - // 'Coin.namecoin: [0, 0.0], Coin.particl: [0, 0.0], Coin.wownero: [0, 0.0], ' - // 'Coin.bitcoinTestNet: [0, 0.0], Coin.litecoinTestNet: [0, 0.0], ' - // 'Coin.bitcoincashTestnet: [0, 0.0], Coin.dogecoinTestNet: [0, 0.0], ' - // 'Coin.firoTestNet: [0, 0.0]}'); - // - // // verify only called once during filling of cache - // verify(client.get( - // Uri.parse( - // "https://api.coingecko.com/api/v3/coins/markets?vs_currency=btc&ids" - // "=monero,bitcoin,litecoin,ecash,epic-cash,zcoin,dogecoin," - // "bitcoin-cash,namecoin,wownero,ethereum,particl" - // "&order=market_cap_desc&per_page=50&page=1&sparkline=false"), - // headers: {'Content-Type': 'application/json'})).called(1); - // - // verifyNoMoreInteractions(client); - // }); + when(client.get( + Uri.parse( + "https://api.coingecko.com/api/v3/coins/markets?vs_currency=btc&ids" + "=monero,bitcoin,litecoin,ecash,epic-cash,zcoin,dogecoin,bitcoin-cash" + ",namecoin,wownero,ethereum,particl,nano,ban&order=market_cap_desc&per_page=50" + "&page=1&sparkline=false"), + headers: { + 'Content-Type': 'application/json' + })).thenAnswer((_) async => Response( + '[{"id":"bitcoin","symbol":"btc","name":"Bitcoin","image":"https://asse' + 'ts.coingecko.com/coins/images/1/large/bitcoin.png?1547033579","curr' + 'ent_price":1.0,"market_cap":19128800,"market_cap_rank":1,"fully_dil' + 'uted_valuation":21000000,"total_volume":1272132,"high_24h":1.0,"low' + '_24h":1.0,"price_change_24h":0.0,"price_change_percentage_24h":0.0,' + '"market_cap_change_24h":950.0,"market_cap_change_percentage_24h":0.0' + '0497,"circulating_supply":19128800.0,"total_supply":21000000.0,"max' + '_supply":21000000.0,"ath":1.003301,"ath_change_percentage":-0.32896' + ',"ath_date":"2019-10-15T16:00:56.136Z","atl":0.99895134,"atl_change_' + 'percentage":0.10498,"atl_date":"2019-10-21T00:00:00.000Z","roi":nul' + 'l,"last_updated":"2022-08-22T16:37:59.237Z"},{"id":"dogecoin","symb' + 'ol":"doge","name":"Dogecoin","image":"https://assets.coingecko.com/' + 'coins/images/5/large/dogecoin.png?1547792256","current_price":3.15e' + '-06,"market_cap":417916,"market_cap_rank":10,"fully_diluted_valuati' + 'on":null,"total_volume":27498,"high_24h":3.26e-06,"low_24h":3.13e-0' + '6,"price_change_24h":-8.6889947714e-08,"price_change_percentage_24h' + '":-2.68533,"market_cap_change_24h":-11370.894861206936,"market_cap_c' + 'hange_percentage_24h":-2.64879,"circulating_supply":132670764299.89' + '4,"total_supply":null,"max_supply":null,"ath":1.264e-05,"ath_change' + '_percentage":-75.05046,"ath_date":"2021-05-07T23:04:53.026Z","atl":' + '1.50936e-07,"atl_change_percentage":1989.69346,"atl_date":"2020-12-' + '17T09:18:05.654Z","roi":null,"last_updated":"2022-08-22T16:38:15.11' + '3Z"},{"id":"monero","symbol":"xmr","name":"Monero","image":"https:/' + '/assets.coingecko.com/coins/images/69/large/monero_logo.png?1547033' + '729","current_price":0.00717236,"market_cap":130002,"market_cap_ran' + 'k":29,"fully_diluted_valuation":null,"total_volume":4901,"high_24h":' + '0.00731999,"low_24h":0.00707511,"price_change_24h":-5.6133543212467' + 'e-05,"price_change_percentage_24h":-0.77656,"market_cap_change_24h"' + ':-1007.8447677436197,"market_cap_change_percentage_24h":-0.76929,"c' + 'irculating_supply":18147820.3764146,"total_supply":null,"max_supply' + '":null,"ath":0.03475393,"ath_change_percentage":-79.32037,"ath_date' + '":"2018-01-09T00:00:00.000Z","atl":0.00101492,"atl_change_percentag' + 'e":608.13327,"atl_date":"2014-12-18T00:00:00.000Z","roi":null,"las' + 't_updated":"2022-08-22T16:38:26.347Z"},{"id":"zcoin","symbol":"firo' + '","name":"Firo","image":"https://assets.coingecko.com/coins/images/' + '479/large/firocoingecko.png?1636537544","current_price":0.0001096,"' + 'market_cap":1252,"market_cap_rank":604,"fully_diluted_valuation":234' + '9,"total_volume":90.573,"high_24h":0.00011148,"low_24h":0.00010834,' + '"price_change_24h":-9.87561775002e-07,"price_change_percentage_24h' + '":-0.89304,"market_cap_change_24h":-10.046635178462793,"market_cap_' + 'change_percentage_24h":-0.79578,"circulating_supply":11411043.83546' + '97,"total_supply":21400000.0,"max_supply":21400000.0,"ath":0.016162' + '72,"ath_change_percentage":-99.3208,"ath_date":"2018-04-04T16:04:48.' + '408Z","atl":4.268e-05,"atl_change_percentage":157.22799,"atl_date":"' + '2022-05-12T07:28:47.088Z","roi":null,"last_updated":"2022-08-22T16' + ':38:47.229Z"},{"id":"epic-cash","symbol":"epic","name":"Epic Cash",' + '"image":"https://assets.coingecko.com/coins/images/9520/large/Epic_C' + 'oin_NO_drop_shadow.png?1620122642","current_price":2.803e-05,"marke' + 't_cap":415.109,"market_cap_rank":953,"fully_diluted_valuation":null' + ',"total_volume":0.2371557,"high_24h":3.053e-05,"low_24h":2.581e-05' + ',"price_change_24h":1.9e-06,"price_change_percentage_24h":7.27524,"' + 'market_cap_change_24h":28.26753,"market_cap_change_percentage_24h":' + '7.30726,"circulating_supply":14808052.0,"total_supply":21000000.0,"' + 'max_supply":null,"ath":0.00013848,"ath_change_percentage":-79.75864' + ',"ath_date":"2021-12-11T08:39:41.129Z","atl":5.74028e-07,"atl_chang' + 'e_percentage":4783.08078,"atl_date":"2020-03-13T16:55:01.177Z","roi' + '":null,"last_updated":"2022-08-22T16:38:32.826Z"}]', + 200)); - // test("response parse failure", () async { - // final client = MockClient(); - // - // when(client.get( - // Uri.parse( - // "https://api.coingecko.com/api/v3/coins/markets?vs_currency=btc" - // "&ids=monero,bitcoin,litecoin,ecash,epic-cash,zcoin,dogecoin," - // "bitcoin-cash,namecoin,wownero,ethereum,particl" - // "&order=market_cap_desc&per_page=50&page=1&sparkline=false"), - // headers: { - // 'Content-Type': 'application/json' - // })).thenAnswer((_) async => Response( - // '[{"id":"bitcoin","symbol":"btc","name":com/coins/images/1/large/' - // 'bitcoin.png?1547033579","current_price":1.0,"market_cap":19128800' - // ',"market_cap_rank":1,"fully_diluted_valuation":21000000,"total_volum' - // 'e":1272132,"high_24h":1.0,"low_24h":1.0,"price_change_24h":0.0,"pri' - // 'ce_change_percentage_24h":0.0,"market_cap_change_24h":950.0,"market_' - // 'cap_change_percentage_24h":0.00497,"circulating_supply":19128800.0,"t' - // 'otal_supply":21000000.0,"max_supply":21000000.0,"ath":1.003301,"ath' - // '_change_percentage":-0.32896,"ath_date":"2019-10-15T16:00:56.136Z",' - // '"atl":0.99895134,"atl_change_percentage":0.10498,"atl_date":' - // '"2019-10-21T00:00:00.000Z","roi":null,' - // '"last_updated":"2022-08-22T16:37:59.237Z"},{"id":"dogecoin"' - // ',"symbol":"doge","name":"Dogecoin","image":' - // '"https://assets.coingecko.com/coins/images/5/large/dogecoin.png?1547792256",' - // '"current_price":3.15e-06,"market_cap":417916,"market_cap_rank":10' - // ',"fully_diluted_valuation":null,"total_volume":27498,"high_24h":3' - // '.26e-06,"low_24h":3.13e-06,"price_change_24h":-8.6889947714e-08,"' - // 'price_change_percentage_24h":-2.68533,"market_cap_change_24h":-11' - // '370.894861206936,"market_cap_change_percentage_24h":-2.64879,"cir' - // 'culating_supply":132670764299.894,"total_supply":null,"max_supply' - // '":null,"ath":1.264e-05,"ath_change_percentage":-75.05046,"ath_date' - // '":"2021-05-07T23:04:53.026Z","atl":1.50936e-07,"atl_change_percen' - // 'tage":1989.69346,"atl_date":"2020-12-17T09:18:05.654Z","roi":null,' - // '"last_updated":"2022-08-22T16:38:15.113Z"},{"id":"monero","symbol"' - // ':"xmr","name":"Monero","image":"https://assets.coingecko.com/coins' - // '/images/69/large/monero_logo.png?1547033729","current_price":0.007' - // '17236,"market_cap":130002,"market_cap_rank":29,"fully_diluted_valu' - // 'ation":null,"total_volume":4901,"high_24h":0.00731999,"low_24h":0.' - // '00707511,"price_change_24h":-5.6133543212467e-05,"price_change_per' - // 'centage_24h":-0.77656,"market_cap_change_24h":-1007.8447677436197' - // ',"market_cap_change_percentage_24h":-0.76929,"circulating_supply":' - // '18147820.3764146,"total_supply":null,"max_supply":null,"ath":0.034' - // '75393,"ath_change_percentage":-79.32037,"ath_date":"2018-01-09T00:' - // '00:00.000Z","atl":0.00101492,"atl_change_percentage":608.13327,"at' - // 'l_date":"2014-12-18T00:00:00.000Z","roi":null,"last_updated":"2022' - // '-08-22T16:38:26.347Z"},{"id":"zcoin","symbol":"firo","name":"Firo"' - // ',"image":"https://assets.coingecko.com/coins/images/479/large/firo' - // 'coingecko.png?1636537544","current_price":0.0001096,"market_cap":1' - // '252,"market_cap_rank":604,"fully_diluted_valuation":2349,"total_vo' - // 'lume":90.573,"high_24h":0.00011148,"low_24h":0.00010834,"price_chang' - // 'e_24h":-9.87561775002e-07,"price_change_percentage_24h":-0.89304,' - // '"market_cap_change_24h":-10.046635178462793,"market_cap_change_per' - // 'centage_24h":-0.79578,"circulating_supply":11411043.8354697,"tota' - // 'l_supply":21400000.0,"max_supply":21400000.0,"ath":0.01616272,"ath' - // '_change_percentage":-99.3208,"ath_date":"2018-04-04T16:04:48.408Z"' - // ',"atl":4.268e-05,"atl_change_percentage":157.22799,"atl_date":"202' - // '2-05-12T07:28:47.088Z","roi":null,"last_updated":"2022-08-22T16:3' - // '8:47.229Z"},{"id":"epic-cash","symbol":"epic","name":"Epic Cash",' - // '"image":"https://assets.coingecko.com/coins/images/9520/large/' - // 'Epic_Coin_NO_drop_shadow.png?1620122642","current_price":2.803e-0' - // '5,"market_cap":415.109,"market_cap_rank":953,"fully_diluted_valuat' - // 'ion":null,"total_volume":0.2371557,"high_24h":3.053e-05,"low_24h":' - // '2.581e-05,"price_change_24h":1.9e-06,"price_change_percentage_24h"' - // ':7.27524,"market_cap_change_24h":28.26753,"market_cap_change_per' - // 'centage_24h":7.30726,"circulating_supply":14808052.0,"total_suppl' - // 'y":21000000.0,"max_supply":null,"ath":0.00013848,"ath_change_perce' - // 'ntage":-79.75864,"ath_date":"2021-12-11T08:39:41.129Z","atl":5.74' - // '028e-07,"atl_change_percentage":4783.08078,"atl_date":"2020-03-13T' - // '16:55:01.177Z","roi":null,"last_updated":"2022-08-22T16:38:32.826Z"}]', - // 200)); - // - // final priceAPI = PriceAPI(client); - // priceAPI.resetLastCalledToForceNextCallToUpdateCache(); - // - // final price = await priceAPI.getPricesAnd24hChange(baseCurrency: "btc"); - // - // expect( - // price.toString(), - // '{Coin.bitcoin: [0, 0.0], Coin.bitcoincash: [0, 0.0], Coin.dogecoin: ' - // '[0, 0.0], Coin.eCash: [0, 0.0], Coin.epicCash: [0, 0.0], Coin.ethereum: [0, 0.0],' - // ' Coin.firo: [0, 0.0], Coin.litecoin: [0, 0.0], Coin.monero: [0, 0.0],' - // ' Coin.namecoin: [0, 0.0], Coin.particl: [0, 0.0], Coin.wownero: [0, 0.0],' - // ' Coin.bitcoinTestNet: [0, 0.0], Coin.litecoinTestNet: [0, 0.0], ' - // 'Coin.bitcoincashTestnet: [0, 0.0], Coin.dogecoinTestNet: [0, 0.0],' - // ' Coin.firoTestNet: [0, 0.0]}'); - // }); + final priceAPI = PriceAPI(client); + priceAPI.resetLastCalledToForceNextCallToUpdateCache(); - // test("no internet available", () async { - // final client = MockClient(); - // - // when(client.get( - // Uri.parse( - // "https://api.coingecko.com/api/v3/coins/markets?vs_currency=btc" - // "&ids=monero,bitcoin,litecoin,ecash,epic-cash,zcoin,dogecoin," - // "bitcoin-cash,namecoin,wownero,ethereum,particl" - // "&order=market_cap_desc&per_page=50&page=1&sparkline=false"), - // headers: { - // 'Content-Type': 'application/json' - // })).thenThrow(const SocketException( - // "Failed host lookup: 'api.com' (OS Error: Temporary failure in name resolution, errno = -3)")); - // - // final priceAPI = PriceAPI(client); - // priceAPI.resetLastCalledToForceNextCallToUpdateCache(); - // - // final price = await priceAPI.getPricesAnd24hChange(baseCurrency: "btc"); - // - // expect( - // price.toString(), - // '{Coin.bitcoin: [0, 0.0], Coin.bitcoincash: [0, 0.0], ' - // 'Coin.dogecoin: [0, 0.0], Coin.eCash: [0, 0.0], Coin.epicCash: [0, 0.0], Coin.ethereum: [0, 0.0],' - // ' Coin.firo: [0, 0.0], Coin.litecoin: [0, 0.0], Coin.monero: [0, 0.0],' - // ' Coin.namecoin: [0, 0.0], Coin.particl: [0, 0.0], Coin.wownero: [0, 0.0],' - // ' Coin.bitcoinTestNet: [0, 0.0], Coin.litecoinTestNet: [0, 0.0], ' - // 'Coin.bitcoincashTestnet: [0, 0.0], Coin.dogecoinTestNet: [0, 0.0], ' - // 'Coin.firoTestNet: [0, 0.0]}'); - // }); + final price = await priceAPI.getPricesAnd24hChange(baseCurrency: "btc"); + + expect( + price.toString(), + '{' + 'Coin.banano: [0, 0.0], ' + 'Coin.bitcoin: [1, 0.0], ' + 'Coin.bitcoincash: [0, 0.0], ' + 'Coin.dogecoin: [0.00000315, -2.68533], ' + 'Coin.eCash: [0, 0.0], ' + 'Coin.epicCash: [0.00002803, 7.27524], ' + 'Coin.ethereum: [0, 0.0], ' + 'Coin.firo: [0.0001096, -0.89304], ' + 'Coin.litecoin: [0, 0.0], ' + 'Coin.monero: [0.00717236, -0.77656], ' + 'Coin.namecoin: [0, 0.0], ' + 'Coin.nano: [0, 0.0], ' + 'Coin.particl: [0, 0.0], ' + 'Coin.wownero: [0, 0.0], ' + 'Coin.bitcoinTestNet: [0, 0.0], ' + 'Coin.bitcoincashTestnet: [0, 0.0], ' + 'Coin.dogecoinTestNet: [0, 0.0], ' + 'Coin.firoTestNet: [0, 0.0], ' + 'Coin.litecoinTestNet: [0, 0.0]' + '}', + ); + verify(client.get( + Uri.parse( + "https://api.coingecko.com/api/v3/coins/markets?vs_currency=btc" + "&ids=monero,bitcoin,litecoin,ecash,epic-cash,zcoin,dogecoin," + "bitcoin-cash,namecoin,wownero,ethereum,particl,nano,ban" + "&order=market_cap_desc&per_page=50&page=1&sparkline=false", + ), + headers: {'Content-Type': 'application/json'})).called(1); + + verifyNoMoreInteractions(client); + }); + + test("cached price fetch", () async { + final client = MockClient(); + + when(client.get( + Uri.parse( + "https://api.coingecko.com/api/v3/coins/markets?vs_currency=btc&" + "ids=monero,bitcoin,litecoin,ecash,epic-cash,zcoin,dogecoin," + "bitcoin-cash,namecoin,wownero,ethereum,particl,nano,ban" + "&order=market_cap_desc&per_page=50&page=1&sparkline=false"), + headers: { + 'Content-Type': 'application/json' + })).thenAnswer((_) async => Response( + '[{"id":"bitcoin","symbol":"btc","name":"Bitcoin","image":"https://a' + 'ssets.coingecko.com/coins/images/1/large/bitcoin.png?1547033579","c' + 'urrent_price":1.0,"market_cap":19128800,"market_cap_rank":1,"fully_' + 'diluted_valuation":21000000,"total_volume":1272132,"high_24h":1.0,"' + 'low_24h":1.0,"price_change_24h":0.0,"price_change_percentage_24h":0' + '.0,"market_cap_change_24h":950.0,"market_cap_change_percentage_24h"' + ':0.00497,"circulating_supply":19128800.0,"total_supply":21000000.0,"' + 'max_supply":21000000.0,"ath":1.003301,"ath_change_percentage":-0.32' + '896,"ath_date":"2019-10-15T16:00:56.136Z","atl":0.99895134,"atl_cha' + 'nge_percentage":0.10498,"atl_date":"2019-10-21T00:00:00.000Z","roi"' + ':null,"last_updated":"2022-08-22T16:37:59.237Z"},{"id":"dogecoin","' + 'symbol":"doge","name":"Dogecoin","image":"https://assets.coingecko.' + 'com/coins/images/5/large/dogecoin.png?1547792256","current_price":3' + '.15e-06,"market_cap":417916,"market_cap_rank":10,"fully_diluted_val' + 'uation":null,"total_volume":27498,"high_24h":3.26e-06,"low_24h":3.1' + '3e-06,"price_change_24h":-8.6889947714e-08,"price_change_percentage' + '_24h":-2.68533,"market_cap_change_24h":-11370.894861206936,"market_' + 'cap_change_percentage_24h":-2.64879,"circulating_supply":1326707642' + '99.894,"total_supply":null,"max_supply":null,"ath":1.264e-05,"ath_c' + 'hange_percentage":-75.05046,"ath_date":"2021-05-07T23:04:53.026Z","' + 'atl":1.50936e-07,"atl_change_percentage":1989.69346,"atl_date":"202' + '0-12-17T09:18:05.654Z","roi":null,"last_updated":"2022-08-22T16:38:' + '15.113Z"},{"id":"monero","symbol":"xmr","name":"Monero","image":"ht' + 'tps://assets.coingecko.com/coins/images/69/large/monero_logo.png?15' + '47033729","current_price":0.00717236,"market_cap":130002,"market_cap' + '_rank":29,"fully_diluted_valuation":null,"total_volume":4901,"high' + '_24h":0.00731999,"low_24h":0.00707511,"price_change_24h":-5.613354' + '3212467e-05,"price_change_percentage_24h":-0.77656,"market_cap_chan' + 'ge_24h":-1007.8447677436197,"market_cap_change_percentage_24h":-0.7' + '6929,"circulating_supply":18147820.3764146,"total_supply":null,"ma' + 'x_supply":null,"ath":0.03475393,"ath_change_percentage":-79.32037,"' + 'ath_date":"2018-01-09T00:00:00.000Z","atl":0.00101492,"atl_change_' + 'percentage":608.13327,"atl_date":"2014-12-18T00:00:00.000Z","roi":n' + 'ull,"last_updated":"2022-08-22T16:38:26.347Z"},{"id":"zcoin","symbo' + 'l":"firo","name":"Firo","image":"https://assets.coingecko.com/coins' + '/images/479/large/firocoingecko.png?1636537544","current_price":0.0' + '001096,"market_cap":1252,"market_cap_rank":604,"fully_diluted_valu' + 'ation":2349,"total_volume":90.573,"high_24h":0.00011148,"low_24h":0' + '.00010834,"price_change_24h":-9.87561775002e-07,"price_change_perce' + 'ntage_24h":-0.89304,"market_cap_change_24h":-10.046635178462793,"ma' + 'rket_cap_change_percentage_24h":-0.79578,"circulating_supply":11411' + '043.8354697,"total_supply":21400000.0,"max_supply":21400000.0,"ath"' + ':0.01616272,"ath_change_percentage":-99.3208,"ath_date":"2018-04-04' + 'T16:04:48.408Z","atl":4.268e-05,"atl_change_percentage":157.22799,' + '"atl_date":"2022-05-12T07:28:47.088Z","roi":null,"last_updated":"2' + '022-08-22T16:38:47.229Z"},{"id":"epic-cash","symbol":"epic","name":"' + 'Epic Cash","image":"https://assets.coingecko.com/coins/images/9520/' + 'large/Epic_Coin_NO_drop_shadow.png?1620122642","current_price":2.80' + '3e-05,"market_cap":415.109,"market_cap_rank":953,"fully_diluted_val' + 'uation":null,"total_volume":0.2371557,"high_24h":3.053e-05,"low_24h' + '":2.581e-05,"price_change_24h":1.9e-06,"price_change_percentage_24' + 'h":7.27524,"market_cap_change_24h":28.26753,"market_cap_change_perc' + 'entage_24h":7.30726,"circulating_supply":14808052.0,"total_supply":' + '21000000.0,"max_supply":null,"ath":0.00013848,"ath_change_percentag' + 'e":-79.75864,"ath_date":"2021-12-11T08:39:41.129Z","atl":5.74028e-0' + '7,"atl_change_percentage":4783.08078,"atl_date":"2020-03-13T16:55:01' + '.177Z","roi":null,"last_updated":"2022-08-22T16:38:32.826Z"}]', + 200)); + + final priceAPI = PriceAPI(client); + priceAPI.resetLastCalledToForceNextCallToUpdateCache(); + + // initial fetch to fill cache + await priceAPI.getPricesAnd24hChange(baseCurrency: "btc"); + + // now this time it should grab from cache instead of http.get + final cachedPrice = + await priceAPI.getPricesAnd24hChange(baseCurrency: "btc"); + + expect( + cachedPrice.toString(), + '{' + 'Coin.banano: [0, 0.0], ' + 'Coin.bitcoin: [1, 0.0], ' + 'Coin.bitcoincash: [0, 0.0], ' + 'Coin.dogecoin: [0.00000315, -2.68533], ' + 'Coin.eCash: [0, 0.0], ' + 'Coin.epicCash: [0.00002803, 7.27524], ' + 'Coin.ethereum: [0, 0.0], ' + 'Coin.firo: [0.0001096, -0.89304], ' + 'Coin.litecoin: [0, 0.0], ' + 'Coin.monero: [0.00717236, -0.77656], ' + 'Coin.namecoin: [0, 0.0], ' + 'Coin.nano: [0, 0.0], ' + 'Coin.particl: [0, 0.0], ' + 'Coin.wownero: [0, 0.0], ' + 'Coin.bitcoinTestNet: [0, 0.0], ' + 'Coin.bitcoincashTestnet: [0, 0.0], ' + 'Coin.dogecoinTestNet: [0, 0.0], ' + 'Coin.firoTestNet: [0, 0.0], ' + 'Coin.litecoinTestNet: [0, 0.0]' + '}', + ); + + // verify only called once during filling of cache + verify(client.get( + Uri.parse( + "https://api.coingecko.com/api/v3/coins/markets?vs_currency=btc&ids" + "=monero,bitcoin,litecoin,ecash,epic-cash,zcoin,dogecoin," + "bitcoin-cash,namecoin,wownero,ethereum,particl,nano,ban" + "&order=market_cap_desc&per_page=50&page=1&sparkline=false"), + headers: {'Content-Type': 'application/json'})).called(1); + + verifyNoMoreInteractions(client); + }); + + test("response parse failure", () async { + final client = MockClient(); + + when(client.get( + Uri.parse( + "https://api.coingecko.com/api/v3/coins/markets?vs_currency=btc" + "&ids=monero,bitcoin,litecoin,ecash,epic-cash,zcoin,dogecoin," + "bitcoin-cash,namecoin,wownero,ethereum,particl,nano,ban" + "&order=market_cap_desc&per_page=50&page=1&sparkline=false"), + headers: { + 'Content-Type': 'application/json' + })).thenAnswer((_) async => Response( + '[{"id":"bitcoin","symbol":"btc","name":com/coins/images/1/large/' + 'bitcoin.png?1547033579","current_price":1.0,"market_cap":19128800' + ',"market_cap_rank":1,"fully_diluted_valuation":21000000,"total_volum' + 'e":1272132,"high_24h":1.0,"low_24h":1.0,"price_change_24h":0.0,"pri' + 'ce_change_percentage_24h":0.0,"market_cap_change_24h":950.0,"market_' + 'cap_change_percentage_24h":0.00497,"circulating_supply":19128800.0,"t' + 'otal_supply":21000000.0,"max_supply":21000000.0,"ath":1.003301,"ath' + '_change_percentage":-0.32896,"ath_date":"2019-10-15T16:00:56.136Z",' + '"atl":0.99895134,"atl_change_percentage":0.10498,"atl_date":' + '"2019-10-21T00:00:00.000Z","roi":null,' + '"last_updated":"2022-08-22T16:37:59.237Z"},{"id":"dogecoin"' + ',"symbol":"doge","name":"Dogecoin","image":' + '"https://assets.coingecko.com/coins/images/5/large/dogecoin.png?1547792256",' + '"current_price":3.15e-06,"market_cap":417916,"market_cap_rank":10' + ',"fully_diluted_valuation":null,"total_volume":27498,"high_24h":3' + '.26e-06,"low_24h":3.13e-06,"price_change_24h":-8.6889947714e-08,"' + 'price_change_percentage_24h":-2.68533,"market_cap_change_24h":-11' + '370.894861206936,"market_cap_change_percentage_24h":-2.64879,"cir' + 'culating_supply":132670764299.894,"total_supply":null,"max_supply' + '":null,"ath":1.264e-05,"ath_change_percentage":-75.05046,"ath_date' + '":"2021-05-07T23:04:53.026Z","atl":1.50936e-07,"atl_change_percen' + 'tage":1989.69346,"atl_date":"2020-12-17T09:18:05.654Z","roi":null,' + '"last_updated":"2022-08-22T16:38:15.113Z"},{"id":"monero","symbol"' + ':"xmr","name":"Monero","image":"https://assets.coingecko.com/coins' + '/images/69/large/monero_logo.png?1547033729","current_price":0.007' + '17236,"market_cap":130002,"market_cap_rank":29,"fully_diluted_valu' + 'ation":null,"total_volume":4901,"high_24h":0.00731999,"low_24h":0.' + '00707511,"price_change_24h":-5.6133543212467e-05,"price_change_per' + 'centage_24h":-0.77656,"market_cap_change_24h":-1007.8447677436197' + ',"market_cap_change_percentage_24h":-0.76929,"circulating_supply":' + '18147820.3764146,"total_supply":null,"max_supply":null,"ath":0.034' + '75393,"ath_change_percentage":-79.32037,"ath_date":"2018-01-09T00:' + '00:00.000Z","atl":0.00101492,"atl_change_percentage":608.13327,"at' + 'l_date":"2014-12-18T00:00:00.000Z","roi":null,"last_updated":"2022' + '-08-22T16:38:26.347Z"},{"id":"zcoin","symbol":"firo","name":"Firo"' + ',"image":"https://assets.coingecko.com/coins/images/479/large/firo' + 'coingecko.png?1636537544","current_price":0.0001096,"market_cap":1' + '252,"market_cap_rank":604,"fully_diluted_valuation":2349,"total_vo' + 'lume":90.573,"high_24h":0.00011148,"low_24h":0.00010834,"price_chang' + 'e_24h":-9.87561775002e-07,"price_change_percentage_24h":-0.89304,' + '"market_cap_change_24h":-10.046635178462793,"market_cap_change_per' + 'centage_24h":-0.79578,"circulating_supply":11411043.8354697,"tota' + 'l_supply":21400000.0,"max_supply":21400000.0,"ath":0.01616272,"ath' + '_change_percentage":-99.3208,"ath_date":"2018-04-04T16:04:48.408Z"' + ',"atl":4.268e-05,"atl_change_percentage":157.22799,"atl_date":"202' + '2-05-12T07:28:47.088Z","roi":null,"last_updated":"2022-08-22T16:3' + '8:47.229Z"},{"id":"epic-cash","symbol":"epic","name":"Epic Cash",' + '"image":"https://assets.coingecko.com/coins/images/9520/large/' + 'Epic_Coin_NO_drop_shadow.png?1620122642","current_price":2.803e-0' + '5,"market_cap":415.109,"market_cap_rank":953,"fully_diluted_valuat' + 'ion":null,"total_volume":0.2371557,"high_24h":3.053e-05,"low_24h":' + '2.581e-05,"price_change_24h":1.9e-06,"price_change_percentage_24h"' + ':7.27524,"market_cap_change_24h":28.26753,"market_cap_change_per' + 'centage_24h":7.30726,"circulating_supply":14808052.0,"total_suppl' + 'y":21000000.0,"max_supply":null,"ath":0.00013848,"ath_change_perce' + 'ntage":-79.75864,"ath_date":"2021-12-11T08:39:41.129Z","atl":5.74' + '028e-07,"atl_change_percentage":4783.08078,"atl_date":"2020-03-13T' + '16:55:01.177Z","roi":null,"last_updated":"2022-08-22T16:38:32.826Z"}]', + 200)); + + final priceAPI = PriceAPI(client); + priceAPI.resetLastCalledToForceNextCallToUpdateCache(); + + final price = await priceAPI.getPricesAnd24hChange(baseCurrency: "btc"); + + expect( + price.toString(), + '{' + 'Coin.banano: [0, 0.0], ' + 'Coin.bitcoin: [0, 0.0], ' + 'Coin.bitcoincash: [0, 0.0], ' + 'Coin.dogecoin: [0, 0.0], ' + 'Coin.eCash: [0, 0.0], ' + 'Coin.epicCash: [0, 0.0], ' + 'Coin.ethereum: [0, 0.0], ' + 'Coin.firo: [0, 0.0], ' + 'Coin.litecoin: [0, 0.0], ' + 'Coin.monero: [0, 0.0], ' + 'Coin.namecoin: [0, 0.0], ' + 'Coin.nano: [0, 0.0], ' + 'Coin.particl: [0, 0.0], ' + 'Coin.wownero: [0, 0.0], ' + 'Coin.bitcoinTestNet: [0, 0.0], ' + 'Coin.bitcoincashTestnet: [0, 0.0], ' + 'Coin.dogecoinTestNet: [0, 0.0], ' + 'Coin.firoTestNet: [0, 0.0], ' + 'Coin.litecoinTestNet: [0, 0.0]' + '}', + ); + }); + + test("no internet available", () async { + final client = MockClient(); + + when(client.get( + Uri.parse( + "https://api.coingecko.com/api/v3/coins/markets?vs_currency=btc" + "&ids=monero,bitcoin,litecoin,ecash,epic-cash,zcoin,dogecoin," + "bitcoin-cash,namecoin,wownero,ethereum,particl,nano,ban" + "&order=market_cap_desc&per_page=50&page=1&sparkline=false"), + headers: { + 'Content-Type': 'application/json' + })).thenThrow(const SocketException( + "Failed host lookup: 'api.com' (OS Error: Temporary failure in name resolution, errno = -3)")); + + final priceAPI = PriceAPI(client); + priceAPI.resetLastCalledToForceNextCallToUpdateCache(); + + final price = await priceAPI.getPricesAnd24hChange(baseCurrency: "btc"); + + expect( + price.toString(), + '{' + 'Coin.banano: [0, 0.0], ' + 'Coin.bitcoin: [0, 0.0], ' + 'Coin.bitcoincash: [0, 0.0], ' + 'Coin.dogecoin: [0, 0.0], ' + 'Coin.eCash: [0, 0.0], ' + 'Coin.epicCash: [0, 0.0], ' + 'Coin.ethereum: [0, 0.0], ' + 'Coin.firo: [0, 0.0], ' + 'Coin.litecoin: [0, 0.0], ' + 'Coin.monero: [0, 0.0], ' + 'Coin.namecoin: [0, 0.0], ' + 'Coin.nano: [0, 0.0], ' + 'Coin.particl: [0, 0.0], ' + 'Coin.wownero: [0, 0.0], ' + 'Coin.bitcoinTestNet: [0, 0.0], ' + 'Coin.bitcoincashTestnet: [0, 0.0], ' + 'Coin.dogecoinTestNet: [0, 0.0], ' + 'Coin.firoTestNet: [0, 0.0], ' + 'Coin.litecoinTestNet: [0, 0.0]' + '}', + ); + }); tearDown(() async { await tearDownTestHive(); diff --git a/test/screen_tests/address_book_view/subviews/add_address_book_view_screen_test.mocks.dart b/test/screen_tests/address_book_view/subviews/add_address_book_view_screen_test.mocks.dart index a5f53d82b..343c90563 100644 --- a/test/screen_tests/address_book_view/subviews/add_address_book_view_screen_test.mocks.dart +++ b/test/screen_tests/address_book_view/subviews/add_address_book_view_screen_test.mocks.dart @@ -269,7 +269,7 @@ class MockManager extends _i1.Mock implements _i12.Manager { @override _i13.Coin get coin => (super.noSuchMethod( Invocation.getter(#coin), - returnValue: _i13.Coin.bitcoin, + returnValue: _i13.Coin.banano, ) as _i13.Coin); @override bool get isRefreshing => (super.noSuchMethod( diff --git a/test/screen_tests/address_book_view/subviews/address_book_entry_details_view_screen_test.mocks.dart b/test/screen_tests/address_book_view/subviews/address_book_entry_details_view_screen_test.mocks.dart index 630726884..c32b1051a 100644 --- a/test/screen_tests/address_book_view/subviews/address_book_entry_details_view_screen_test.mocks.dart +++ b/test/screen_tests/address_book_view/subviews/address_book_entry_details_view_screen_test.mocks.dart @@ -230,7 +230,7 @@ class MockManager extends _i1.Mock implements _i10.Manager { @override _i11.Coin get coin => (super.noSuchMethod( Invocation.getter(#coin), - returnValue: _i11.Coin.bitcoin, + returnValue: _i11.Coin.banano, ) as _i11.Coin); @override bool get isRefreshing => (super.noSuchMethod( diff --git a/test/screen_tests/address_book_view/subviews/edit_address_book_entry_view_screen_test.mocks.dart b/test/screen_tests/address_book_view/subviews/edit_address_book_entry_view_screen_test.mocks.dart index c64135241..8b2e70ac8 100644 --- a/test/screen_tests/address_book_view/subviews/edit_address_book_entry_view_screen_test.mocks.dart +++ b/test/screen_tests/address_book_view/subviews/edit_address_book_entry_view_screen_test.mocks.dart @@ -228,7 +228,7 @@ class MockManager extends _i1.Mock implements _i10.Manager { @override _i11.Coin get coin => (super.noSuchMethod( Invocation.getter(#coin), - returnValue: _i11.Coin.bitcoin, + returnValue: _i11.Coin.banano, ) as _i11.Coin); @override bool get isRefreshing => (super.noSuchMethod( diff --git a/test/screen_tests/lockscreen_view_screen_test.mocks.dart b/test/screen_tests/lockscreen_view_screen_test.mocks.dart index 3f7609c1f..af9c67151 100644 --- a/test/screen_tests/lockscreen_view_screen_test.mocks.dart +++ b/test/screen_tests/lockscreen_view_screen_test.mocks.dart @@ -548,7 +548,7 @@ class MockManager extends _i1.Mock implements _i13.Manager { @override _i9.Coin get coin => (super.noSuchMethod( Invocation.getter(#coin), - returnValue: _i9.Coin.bitcoin, + returnValue: _i9.Coin.banano, ) as _i9.Coin); @override bool get isRefreshing => (super.noSuchMethod( diff --git a/test/screen_tests/main_view_tests/main_view_screen_testA_test.mocks.dart b/test/screen_tests/main_view_tests/main_view_screen_testA_test.mocks.dart index 909d04a86..150f48ffa 100644 --- a/test/screen_tests/main_view_tests/main_view_screen_testA_test.mocks.dart +++ b/test/screen_tests/main_view_tests/main_view_screen_testA_test.mocks.dart @@ -335,7 +335,7 @@ class MockManager extends _i1.Mock implements _i10.Manager { @override _i8.Coin get coin => (super.noSuchMethod( Invocation.getter(#coin), - returnValue: _i8.Coin.bitcoin, + returnValue: _i8.Coin.banano, ) as _i8.Coin); @override bool get isRefreshing => (super.noSuchMethod( diff --git a/test/screen_tests/main_view_tests/main_view_screen_testB_test.mocks.dart b/test/screen_tests/main_view_tests/main_view_screen_testB_test.mocks.dart index 76ca1a64a..0fcebe54f 100644 --- a/test/screen_tests/main_view_tests/main_view_screen_testB_test.mocks.dart +++ b/test/screen_tests/main_view_tests/main_view_screen_testB_test.mocks.dart @@ -335,7 +335,7 @@ class MockManager extends _i1.Mock implements _i10.Manager { @override _i8.Coin get coin => (super.noSuchMethod( Invocation.getter(#coin), - returnValue: _i8.Coin.bitcoin, + returnValue: _i8.Coin.banano, ) as _i8.Coin); @override bool get isRefreshing => (super.noSuchMethod( diff --git a/test/screen_tests/main_view_tests/main_view_screen_testC_test.mocks.dart b/test/screen_tests/main_view_tests/main_view_screen_testC_test.mocks.dart index 416090add..b6796580c 100644 --- a/test/screen_tests/main_view_tests/main_view_screen_testC_test.mocks.dart +++ b/test/screen_tests/main_view_tests/main_view_screen_testC_test.mocks.dart @@ -335,7 +335,7 @@ class MockManager extends _i1.Mock implements _i10.Manager { @override _i8.Coin get coin => (super.noSuchMethod( Invocation.getter(#coin), - returnValue: _i8.Coin.bitcoin, + returnValue: _i8.Coin.banano, ) as _i8.Coin); @override bool get isRefreshing => (super.noSuchMethod( diff --git a/test/screen_tests/onboarding/backup_key_view_screen_test.mocks.dart b/test/screen_tests/onboarding/backup_key_view_screen_test.mocks.dart index 7022de852..c89b92af5 100644 --- a/test/screen_tests/onboarding/backup_key_view_screen_test.mocks.dart +++ b/test/screen_tests/onboarding/backup_key_view_screen_test.mocks.dart @@ -102,7 +102,7 @@ class MockManager extends _i1.Mock implements _i6.Manager { @override _i7.Coin get coin => (super.noSuchMethod( Invocation.getter(#coin), - returnValue: _i7.Coin.bitcoin, + returnValue: _i7.Coin.banano, ) as _i7.Coin); @override bool get isRefreshing => (super.noSuchMethod( diff --git a/test/screen_tests/onboarding/backup_key_warning_view_screen_test.mocks.dart b/test/screen_tests/onboarding/backup_key_warning_view_screen_test.mocks.dart index 4fad26d9f..96feb3c23 100644 --- a/test/screen_tests/onboarding/backup_key_warning_view_screen_test.mocks.dart +++ b/test/screen_tests/onboarding/backup_key_warning_view_screen_test.mocks.dart @@ -333,7 +333,7 @@ class MockManager extends _i1.Mock implements _i10.Manager { @override _i8.Coin get coin => (super.noSuchMethod( Invocation.getter(#coin), - returnValue: _i8.Coin.bitcoin, + returnValue: _i8.Coin.banano, ) as _i8.Coin); @override bool get isRefreshing => (super.noSuchMethod( diff --git a/test/screen_tests/onboarding/create_pin_view_screen_test.mocks.dart b/test/screen_tests/onboarding/create_pin_view_screen_test.mocks.dart index c04081c52..6be5c8995 100644 --- a/test/screen_tests/onboarding/create_pin_view_screen_test.mocks.dart +++ b/test/screen_tests/onboarding/create_pin_view_screen_test.mocks.dart @@ -548,7 +548,7 @@ class MockManager extends _i1.Mock implements _i13.Manager { @override _i9.Coin get coin => (super.noSuchMethod( Invocation.getter(#coin), - returnValue: _i9.Coin.bitcoin, + returnValue: _i9.Coin.banano, ) as _i9.Coin); @override bool get isRefreshing => (super.noSuchMethod( diff --git a/test/screen_tests/onboarding/restore_wallet_view_screen_test.mocks.dart b/test/screen_tests/onboarding/restore_wallet_view_screen_test.mocks.dart index 9a351b683..d45ffc46d 100644 --- a/test/screen_tests/onboarding/restore_wallet_view_screen_test.mocks.dart +++ b/test/screen_tests/onboarding/restore_wallet_view_screen_test.mocks.dart @@ -389,7 +389,7 @@ class MockManager extends _i1.Mock implements _i13.Manager { @override _i11.Coin get coin => (super.noSuchMethod( Invocation.getter(#coin), - returnValue: _i11.Coin.bitcoin, + returnValue: _i11.Coin.banano, ) as _i11.Coin); @override bool get isRefreshing => (super.noSuchMethod( diff --git a/test/screen_tests/onboarding/verify_backup_key_view_screen_test.mocks.dart b/test/screen_tests/onboarding/verify_backup_key_view_screen_test.mocks.dart index 496739e8e..3a50f9e38 100644 --- a/test/screen_tests/onboarding/verify_backup_key_view_screen_test.mocks.dart +++ b/test/screen_tests/onboarding/verify_backup_key_view_screen_test.mocks.dart @@ -102,7 +102,7 @@ class MockManager extends _i1.Mock implements _i6.Manager { @override _i7.Coin get coin => (super.noSuchMethod( Invocation.getter(#coin), - returnValue: _i7.Coin.bitcoin, + returnValue: _i7.Coin.banano, ) as _i7.Coin); @override bool get isRefreshing => (super.noSuchMethod( diff --git a/test/screen_tests/settings_view/settings_subviews/currency_view_screen_test.mocks.dart b/test/screen_tests/settings_view/settings_subviews/currency_view_screen_test.mocks.dart index 5b81467df..6def2231b 100644 --- a/test/screen_tests/settings_view/settings_subviews/currency_view_screen_test.mocks.dart +++ b/test/screen_tests/settings_view/settings_subviews/currency_view_screen_test.mocks.dart @@ -102,7 +102,7 @@ class MockManager extends _i1.Mock implements _i6.Manager { @override _i7.Coin get coin => (super.noSuchMethod( Invocation.getter(#coin), - returnValue: _i7.Coin.bitcoin, + returnValue: _i7.Coin.banano, ) as _i7.Coin); @override bool get isRefreshing => (super.noSuchMethod( diff --git a/test/screen_tests/settings_view/settings_subviews/network_settings_subviews/add_custom_node_view_screen_test.mocks.dart b/test/screen_tests/settings_view/settings_subviews/network_settings_subviews/add_custom_node_view_screen_test.mocks.dart index 1c5de9829..5acdfe1e5 100644 --- a/test/screen_tests/settings_view/settings_subviews/network_settings_subviews/add_custom_node_view_screen_test.mocks.dart +++ b/test/screen_tests/settings_view/settings_subviews/network_settings_subviews/add_custom_node_view_screen_test.mocks.dart @@ -317,7 +317,7 @@ class MockManager extends _i1.Mock implements _i12.Manager { @override _i10.Coin get coin => (super.noSuchMethod( Invocation.getter(#coin), - returnValue: _i10.Coin.bitcoin, + returnValue: _i10.Coin.banano, ) as _i10.Coin); @override bool get isRefreshing => (super.noSuchMethod( diff --git a/test/screen_tests/settings_view/settings_subviews/network_settings_subviews/node_details_view_screen_test.mocks.dart b/test/screen_tests/settings_view/settings_subviews/network_settings_subviews/node_details_view_screen_test.mocks.dart index 760b143bd..5f1e62ae0 100644 --- a/test/screen_tests/settings_view/settings_subviews/network_settings_subviews/node_details_view_screen_test.mocks.dart +++ b/test/screen_tests/settings_view/settings_subviews/network_settings_subviews/node_details_view_screen_test.mocks.dart @@ -317,7 +317,7 @@ class MockManager extends _i1.Mock implements _i12.Manager { @override _i10.Coin get coin => (super.noSuchMethod( Invocation.getter(#coin), - returnValue: _i10.Coin.bitcoin, + returnValue: _i10.Coin.banano, ) as _i10.Coin); @override bool get isRefreshing => (super.noSuchMethod( diff --git a/test/screen_tests/settings_view/settings_subviews/wallet_backup_view_screen_test.mocks.dart b/test/screen_tests/settings_view/settings_subviews/wallet_backup_view_screen_test.mocks.dart index 191e1eca7..bce263d8a 100644 --- a/test/screen_tests/settings_view/settings_subviews/wallet_backup_view_screen_test.mocks.dart +++ b/test/screen_tests/settings_view/settings_subviews/wallet_backup_view_screen_test.mocks.dart @@ -102,7 +102,7 @@ class MockManager extends _i1.Mock implements _i6.Manager { @override _i7.Coin get coin => (super.noSuchMethod( Invocation.getter(#coin), - returnValue: _i7.Coin.bitcoin, + returnValue: _i7.Coin.banano, ) as _i7.Coin); @override bool get isRefreshing => (super.noSuchMethod( diff --git a/test/screen_tests/settings_view/settings_subviews/wallet_settings_subviews/rescan_warning_view_screen_test.mocks.dart b/test/screen_tests/settings_view/settings_subviews/wallet_settings_subviews/rescan_warning_view_screen_test.mocks.dart index df6bac383..0e843bd14 100644 --- a/test/screen_tests/settings_view/settings_subviews/wallet_settings_subviews/rescan_warning_view_screen_test.mocks.dart +++ b/test/screen_tests/settings_view/settings_subviews/wallet_settings_subviews/rescan_warning_view_screen_test.mocks.dart @@ -102,7 +102,7 @@ class MockManager extends _i1.Mock implements _i6.Manager { @override _i7.Coin get coin => (super.noSuchMethod( Invocation.getter(#coin), - returnValue: _i7.Coin.bitcoin, + returnValue: _i7.Coin.banano, ) as _i7.Coin); @override bool get isRefreshing => (super.noSuchMethod( diff --git a/test/screen_tests/settings_view/settings_subviews/wallet_settings_subviews/wallet_delete_mnemonic_view_screen_test.mocks.dart b/test/screen_tests/settings_view/settings_subviews/wallet_settings_subviews/wallet_delete_mnemonic_view_screen_test.mocks.dart index 2ae50c123..dc8e09b91 100644 --- a/test/screen_tests/settings_view/settings_subviews/wallet_settings_subviews/wallet_delete_mnemonic_view_screen_test.mocks.dart +++ b/test/screen_tests/settings_view/settings_subviews/wallet_settings_subviews/wallet_delete_mnemonic_view_screen_test.mocks.dart @@ -333,7 +333,7 @@ class MockManager extends _i1.Mock implements _i10.Manager { @override _i8.Coin get coin => (super.noSuchMethod( Invocation.getter(#coin), - returnValue: _i8.Coin.bitcoin, + returnValue: _i8.Coin.banano, ) as _i8.Coin); @override bool get isRefreshing => (super.noSuchMethod( diff --git a/test/screen_tests/settings_view/settings_subviews/wallet_settings_view_screen_test.mocks.dart b/test/screen_tests/settings_view/settings_subviews/wallet_settings_view_screen_test.mocks.dart index 3548ce5a4..3771527e0 100644 --- a/test/screen_tests/settings_view/settings_subviews/wallet_settings_view_screen_test.mocks.dart +++ b/test/screen_tests/settings_view/settings_subviews/wallet_settings_view_screen_test.mocks.dart @@ -569,7 +569,7 @@ class MockManager extends _i1.Mock implements _i15.Manager { @override _i9.Coin get coin => (super.noSuchMethod( Invocation.getter(#coin), - returnValue: _i9.Coin.bitcoin, + returnValue: _i9.Coin.banano, ) as _i9.Coin); @override bool get isRefreshing => (super.noSuchMethod( diff --git a/test/screen_tests/settings_view/settings_view_screen_test.mocks.dart b/test/screen_tests/settings_view/settings_view_screen_test.mocks.dart index daee1f95e..2b4b9e638 100644 --- a/test/screen_tests/settings_view/settings_view_screen_test.mocks.dart +++ b/test/screen_tests/settings_view/settings_view_screen_test.mocks.dart @@ -333,7 +333,7 @@ class MockManager extends _i1.Mock implements _i10.Manager { @override _i8.Coin get coin => (super.noSuchMethod( Invocation.getter(#coin), - returnValue: _i8.Coin.bitcoin, + returnValue: _i8.Coin.banano, ) as _i8.Coin); @override bool get isRefreshing => (super.noSuchMethod( diff --git a/test/screen_tests/transaction_subviews/transaction_search_results_view_screen_test.mocks.dart b/test/screen_tests/transaction_subviews/transaction_search_results_view_screen_test.mocks.dart index 7914d71f4..7a61b1f58 100644 --- a/test/screen_tests/transaction_subviews/transaction_search_results_view_screen_test.mocks.dart +++ b/test/screen_tests/transaction_subviews/transaction_search_results_view_screen_test.mocks.dart @@ -104,7 +104,7 @@ class MockManager extends _i1.Mock implements _i6.Manager { @override _i7.Coin get coin => (super.noSuchMethod( Invocation.getter(#coin), - returnValue: _i7.Coin.bitcoin, + returnValue: _i7.Coin.banano, ) as _i7.Coin); @override bool get isRefreshing => (super.noSuchMethod( diff --git a/test/screen_tests/wallet_view/confirm_send_view_screen_test.mocks.dart b/test/screen_tests/wallet_view/confirm_send_view_screen_test.mocks.dart index f493222d9..8c3a5a39a 100644 --- a/test/screen_tests/wallet_view/confirm_send_view_screen_test.mocks.dart +++ b/test/screen_tests/wallet_view/confirm_send_view_screen_test.mocks.dart @@ -103,7 +103,7 @@ class MockManager extends _i1.Mock implements _i6.Manager { @override _i7.Coin get coin => (super.noSuchMethod( Invocation.getter(#coin), - returnValue: _i7.Coin.bitcoin, + returnValue: _i7.Coin.banano, ) as _i7.Coin); @override bool get isRefreshing => (super.noSuchMethod( diff --git a/test/screen_tests/wallet_view/receive_view_screen_test.mocks.dart b/test/screen_tests/wallet_view/receive_view_screen_test.mocks.dart index 6e0382474..148289626 100644 --- a/test/screen_tests/wallet_view/receive_view_screen_test.mocks.dart +++ b/test/screen_tests/wallet_view/receive_view_screen_test.mocks.dart @@ -102,7 +102,7 @@ class MockManager extends _i1.Mock implements _i6.Manager { @override _i7.Coin get coin => (super.noSuchMethod( Invocation.getter(#coin), - returnValue: _i7.Coin.bitcoin, + returnValue: _i7.Coin.banano, ) as _i7.Coin); @override bool get isRefreshing => (super.noSuchMethod( diff --git a/test/screen_tests/wallet_view/send_view_screen_test.mocks.dart b/test/screen_tests/wallet_view/send_view_screen_test.mocks.dart index 97f744995..71e0ca110 100644 --- a/test/screen_tests/wallet_view/send_view_screen_test.mocks.dart +++ b/test/screen_tests/wallet_view/send_view_screen_test.mocks.dart @@ -144,7 +144,7 @@ class MockManager extends _i1.Mock implements _i9.Manager { @override _i10.Coin get coin => (super.noSuchMethod( Invocation.getter(#coin), - returnValue: _i10.Coin.bitcoin, + returnValue: _i10.Coin.banano, ) as _i10.Coin); @override bool get isRefreshing => (super.noSuchMethod( diff --git a/test/screen_tests/wallet_view/wallet_view_screen_test.mocks.dart b/test/screen_tests/wallet_view/wallet_view_screen_test.mocks.dart index 4a0a14f47..60bf5ef5f 100644 --- a/test/screen_tests/wallet_view/wallet_view_screen_test.mocks.dart +++ b/test/screen_tests/wallet_view/wallet_view_screen_test.mocks.dart @@ -104,7 +104,7 @@ class MockManager extends _i1.Mock implements _i6.Manager { @override _i7.Coin get coin => (super.noSuchMethod( Invocation.getter(#coin), - returnValue: _i7.Coin.bitcoin, + returnValue: _i7.Coin.banano, ) as _i7.Coin); @override bool get isRefreshing => (super.noSuchMethod( diff --git a/test/services/coins/manager_test.mocks.dart b/test/services/coins/manager_test.mocks.dart index a9447506e..97992e3ed 100644 --- a/test/services/coins/manager_test.mocks.dart +++ b/test/services/coins/manager_test.mocks.dart @@ -217,7 +217,7 @@ class MockFiroWallet extends _i1.Mock implements _i10.FiroWallet { @override _i12.Coin get coin => (super.noSuchMethod( Invocation.getter(#coin), - returnValue: _i12.Coin.bitcoin, + returnValue: _i12.Coin.banano, ) as _i12.Coin); @override _i11.Future> get mnemonic => (super.noSuchMethod( diff --git a/test/widget_tests/managed_favorite_test.dart b/test/widget_tests/managed_favorite_test.dart index f930caf5c..e0cb0dfc7 100644 --- a/test/widget_tests/managed_favorite_test.dart +++ b/test/widget_tests/managed_favorite_test.dart @@ -17,8 +17,10 @@ import 'package:stackwallet/services/wallets_service.dart'; import 'package:stackwallet/themes/stack_colors.dart'; import 'package:stackwallet/themes/theme_service.dart'; import 'package:stackwallet/utilities/amount/amount.dart'; +import 'package:stackwallet/utilities/amount/amount_unit.dart'; import 'package:stackwallet/utilities/enums/coin_enum.dart'; import 'package:stackwallet/utilities/listenable_list.dart'; +import 'package:stackwallet/utilities/prefs.dart'; import 'package:stackwallet/widgets/managed_favorite.dart'; import '../sample_data/theme_json.dart'; @@ -36,6 +38,7 @@ Amount _a(int i) => Amount.fromDecimal( WalletsService, BitcoinWallet, ThemeService, + Prefs, LocaleService ], customMocks: [ MockSpec(returnNullOnMissingStub: true), @@ -47,6 +50,7 @@ void main() { final wallets = MockWallets(); final CoinServiceAPI wallet = MockBitcoinWallet(); final mockThemeService = MockThemeService(); + final mockPrefs = MockPrefs(); when(mockThemeService.getTheme(themeId: "light")).thenAnswer( (_) => StackTheme.fromJson( @@ -58,6 +62,13 @@ void main() { when(wallet.walletName).thenAnswer((_) => "some wallet"); when(wallet.walletId).thenAnswer((_) => "some wallet id"); + when(mockPrefs.amountUnit(Coin.bitcoin)).thenAnswer( + (_) => AmountUnit.normal, + ); + when(mockPrefs.maxDecimals(Coin.bitcoin)).thenAnswer( + (_) => 8, + ); + final manager = Manager(wallet); when(wallets.getManager("some wallet id")) .thenAnswer((realInvocation) => manager); @@ -78,6 +89,7 @@ void main() { overrides: [ walletsChangeNotifierProvider.overrideWithValue(wallets), pThemeService.overrideWithValue(mockThemeService), + prefsChangeNotifierProvider.overrideWithValue(mockPrefs), ], child: MaterialApp( theme: ThemeData( @@ -103,161 +115,179 @@ void main() { expect(find.byType(ManagedFavorite), findsOneWidget); }); - // testWidgets("Button Pressed - wallet unfavorite", (widgetTester) async { - // final wallets = MockWallets(); - // final CoinServiceAPI wallet = MockBitcoinWallet(); - // final mockLocaleService = MockLocaleService(); - // final mockWalletsService = MockWalletsService(); - // final mockThemeService = MockThemeService(); - // - // when(mockThemeService.getTheme(themeId: "light")).thenAnswer( - // (_) => StackTheme.fromJson( - // json: lightThemeJsonMap, - // applicationThemesDirectoryPath: "test", - // ), - // ); - // when(wallet.coin).thenAnswer((_) => Coin.bitcoin); - // when(wallet.walletName).thenAnswer((_) => "some wallet"); - // when(wallet.walletId).thenAnswer((_) => "some wallet id"); - // - // final manager = Manager(wallet); - // - // when(wallets.getManager("some wallet id")) - // .thenAnswer((realInvocation) => manager); - // when(manager.balance).thenAnswer( - // (realInvocation) => Balance( - // total: _a(10), - // spendable: _a(10), - // blockedTotal: _a(0), - // pendingSpendable: _a(0), - // ), - // ); - // - // when(manager.isFavorite).thenAnswer((realInvocation) => false); - // - // when(mockLocaleService.locale).thenAnswer((_) => "en_US"); - // - // when(wallets.getManagerProvider("some wallet id")).thenAnswer( - // (realInvocation) => ChangeNotifierProvider((ref) => manager)); - // - // const managedFavorite = ManagedFavorite(walletId: "some wallet id"); - // - // final ListenableList> favorites = - // ListenableList(); - // - // final ListenableList> nonfavorites = - // ListenableList(); - // await widgetTester.pumpWidget( - // ProviderScope( - // overrides: [ - // walletsChangeNotifierProvider.overrideWithValue(wallets), - // localeServiceChangeNotifierProvider - // .overrideWithValue(mockLocaleService), - // favoritesProvider.overrideWithValue(favorites), - // nonFavoritesProvider.overrideWithValue(nonfavorites), - // pThemeService.overrideWithValue(mockThemeService), - // walletsServiceChangeNotifierProvider - // .overrideWithValue(mockWalletsService) - // ], - // child: MaterialApp( - // theme: ThemeData( - // extensions: [ - // StackColors.fromStackColorTheme( - // StackTheme.fromJson( - // json: lightThemeJsonMap, - // applicationThemesDirectoryPath: "test", - // ), - // ), - // ], - // ), - // home: const Material( - // child: managedFavorite, - // ), - // ), - // ), - // ); - // - // expect(find.byType(RawMaterialButton), findsOneWidget); - // await widgetTester.tap(find.byType(RawMaterialButton)); - // await widgetTester.pump(); - // }); + testWidgets("Button Pressed - wallet unfavorite", (widgetTester) async { + final wallets = MockWallets(); + final CoinServiceAPI wallet = MockBitcoinWallet(); + final mockLocaleService = MockLocaleService(); + final mockWalletsService = MockWalletsService(); + final mockThemeService = MockThemeService(); + final mockPrefs = MockPrefs(); - // testWidgets("Button Pressed - wallet is favorite", (widgetTester) async { - // final wallets = MockWallets(); - // final CoinServiceAPI wallet = MockBitcoinWallet(); - // final mockLocaleService = MockLocaleService(); - // final mockWalletsService = MockWalletsService(); - // final mockThemeService = MockThemeService(); - // - // when(mockThemeService.getTheme(themeId: "light")).thenAnswer( - // (_) => StackTheme.fromJson( - // json: lightThemeJsonMap, - // applicationThemesDirectoryPath: "test", - // ), - // ); - // when(wallet.coin).thenAnswer((_) => Coin.bitcoin); - // when(wallet.walletName).thenAnswer((_) => "some wallet"); - // when(wallet.walletId).thenAnswer((_) => "some wallet id"); - // - // final manager = Manager(wallet); - // - // when(wallets.getManager("some wallet id")) - // .thenAnswer((realInvocation) => manager); - // - // when(manager.isFavorite).thenAnswer((realInvocation) => true); - // when(manager.balance).thenAnswer( - // (realInvocation) => Balance( - // total: _a(10), - // spendable: _a(10), - // blockedTotal: _a(0), - // pendingSpendable: _a(0), - // ), - // ); - // - // when(mockLocaleService.locale).thenAnswer((_) => "en_US"); - // - // when(wallets.getManagerProvider("some wallet id")).thenAnswer( - // (realInvocation) => ChangeNotifierProvider((ref) => manager)); - // - // const managedFavorite = ManagedFavorite(walletId: "some wallet id"); - // - // final ListenableList> favorites = - // ListenableList(); - // - // final ListenableList> nonfavorites = - // ListenableList(); - // await widgetTester.pumpWidget( - // ProviderScope( - // overrides: [ - // walletsChangeNotifierProvider.overrideWithValue(wallets), - // localeServiceChangeNotifierProvider - // .overrideWithValue(mockLocaleService), - // favoritesProvider.overrideWithValue(favorites), - // nonFavoritesProvider.overrideWithValue(nonfavorites), - // pThemeService.overrideWithValue(mockThemeService), - // walletsServiceChangeNotifierProvider - // .overrideWithValue(mockWalletsService) - // ], - // child: MaterialApp( - // theme: ThemeData( - // extensions: [ - // StackColors.fromStackColorTheme( - // StackTheme.fromJson( - // json: lightThemeJsonMap, - // applicationThemesDirectoryPath: "test", - // ), - // ), - // ], - // ), - // home: const Material( - // child: managedFavorite, - // ), - // ), - // ), - // ); - // - // expect(find.byType(RawMaterialButton), findsOneWidget); - // await widgetTester.tap(find.byType(RawMaterialButton)); - // await widgetTester.pump(); - // }); + when(mockThemeService.getTheme(themeId: "light")).thenAnswer( + (_) => StackTheme.fromJson( + json: lightThemeJsonMap, + applicationThemesDirectoryPath: "test", + ), + ); + when(wallet.coin).thenAnswer((_) => Coin.bitcoin); + when(wallet.walletName).thenAnswer((_) => "some wallet"); + when(wallet.walletId).thenAnswer((_) => "some wallet id"); + when(mockPrefs.amountUnit(Coin.bitcoin)).thenAnswer( + (_) => AmountUnit.normal, + ); + + final manager = Manager(wallet); + + when(wallets.getManager("some wallet id")) + .thenAnswer((realInvocation) => manager); + when(manager.balance).thenAnswer( + (realInvocation) => Balance( + total: _a(10), + spendable: _a(10), + blockedTotal: _a(0), + pendingSpendable: _a(0), + ), + ); + + when(manager.isFavorite).thenAnswer((realInvocation) => false); + + when(mockPrefs.maxDecimals(Coin.bitcoin)).thenAnswer( + (_) => 8, + ); + + when(mockLocaleService.locale).thenAnswer((_) => "en_US"); + + when(wallets.getManagerProvider("some wallet id")).thenAnswer( + (realInvocation) => ChangeNotifierProvider((ref) => manager)); + + const managedFavorite = ManagedFavorite(walletId: "some wallet id"); + + final ListenableList> favorites = + ListenableList(); + + final ListenableList> nonfavorites = + ListenableList(); + await widgetTester.pumpWidget( + ProviderScope( + overrides: [ + walletsChangeNotifierProvider.overrideWithValue(wallets), + localeServiceChangeNotifierProvider + .overrideWithValue(mockLocaleService), + favoritesProvider.overrideWithValue(favorites), + nonFavoritesProvider.overrideWithValue(nonfavorites), + pThemeService.overrideWithValue(mockThemeService), + walletsServiceChangeNotifierProvider + .overrideWithValue(mockWalletsService), + prefsChangeNotifierProvider.overrideWithValue(mockPrefs), + ], + child: MaterialApp( + theme: ThemeData( + extensions: [ + StackColors.fromStackColorTheme( + StackTheme.fromJson( + json: lightThemeJsonMap, + applicationThemesDirectoryPath: "test", + ), + ), + ], + ), + home: const Material( + child: managedFavorite, + ), + ), + ), + ); + + expect(find.byType(RawMaterialButton), findsOneWidget); + await widgetTester.tap(find.byType(RawMaterialButton)); + await widgetTester.pump(); + }); + + testWidgets("Button Pressed - wallet is favorite", (widgetTester) async { + final wallets = MockWallets(); + final CoinServiceAPI wallet = MockBitcoinWallet(); + final mockLocaleService = MockLocaleService(); + final mockWalletsService = MockWalletsService(); + final mockThemeService = MockThemeService(); + final mockPrefs = MockPrefs(); + + when(mockThemeService.getTheme(themeId: "light")).thenAnswer( + (_) => StackTheme.fromJson( + json: lightThemeJsonMap, + applicationThemesDirectoryPath: "test", + ), + ); + when(wallet.coin).thenAnswer((_) => Coin.bitcoin); + when(wallet.walletName).thenAnswer((_) => "some wallet"); + when(wallet.walletId).thenAnswer((_) => "some wallet id"); + + when(mockPrefs.maxDecimals(Coin.bitcoin)).thenAnswer( + (_) => 8, + ); + + final manager = Manager(wallet); + + when(wallets.getManager("some wallet id")) + .thenAnswer((realInvocation) => manager); + + when(manager.isFavorite).thenAnswer((realInvocation) => true); + when(manager.balance).thenAnswer( + (realInvocation) => Balance( + total: _a(10), + spendable: _a(10), + blockedTotal: _a(0), + pendingSpendable: _a(0), + ), + ); + when(mockPrefs.amountUnit(Coin.bitcoin)).thenAnswer( + (_) => AmountUnit.normal, + ); + + when(mockLocaleService.locale).thenAnswer((_) => "en_US"); + + when(wallets.getManagerProvider("some wallet id")).thenAnswer( + (realInvocation) => ChangeNotifierProvider((ref) => manager)); + + const managedFavorite = ManagedFavorite(walletId: "some wallet id"); + + final ListenableList> favorites = + ListenableList(); + + final ListenableList> nonfavorites = + ListenableList(); + await widgetTester.pumpWidget( + ProviderScope( + overrides: [ + walletsChangeNotifierProvider.overrideWithValue(wallets), + localeServiceChangeNotifierProvider + .overrideWithValue(mockLocaleService), + favoritesProvider.overrideWithValue(favorites), + nonFavoritesProvider.overrideWithValue(nonfavorites), + pThemeService.overrideWithValue(mockThemeService), + prefsChangeNotifierProvider.overrideWithValue(mockPrefs), + walletsServiceChangeNotifierProvider + .overrideWithValue(mockWalletsService) + ], + child: MaterialApp( + theme: ThemeData( + extensions: [ + StackColors.fromStackColorTheme( + StackTheme.fromJson( + json: lightThemeJsonMap, + applicationThemesDirectoryPath: "test", + ), + ), + ], + ), + home: const Material( + child: managedFavorite, + ), + ), + ), + ); + + expect(find.byType(RawMaterialButton), findsOneWidget); + await widgetTester.tap(find.byType(RawMaterialButton)); + await widgetTester.pump(); + }); } diff --git a/test/widget_tests/managed_favorite_test.mocks.dart b/test/widget_tests/managed_favorite_test.mocks.dart index a45f332f2..1c47708fe 100644 --- a/test/widget_tests/managed_favorite_test.mocks.dart +++ b/test/widget_tests/managed_favorite_test.mocks.dart @@ -21,13 +21,13 @@ import 'package:stackwallet/electrumx_rpc/electrumx.dart' as _i9; import 'package:stackwallet/models/balance.dart' as _i11; import 'package:stackwallet/models/isar/models/isar_models.dart' as _i17; import 'package:stackwallet/models/isar/stack_theme.dart' as _i31; -import 'package:stackwallet/models/node_model.dart' as _i33; +import 'package:stackwallet/models/node_model.dart' as _i36; import 'package:stackwallet/models/paymint/fee_object_model.dart' as _i8; import 'package:stackwallet/models/signing_data.dart' as _i28; import 'package:stackwallet/services/coins/bitcoin/bitcoin_wallet.dart' as _i26; import 'package:stackwallet/services/coins/coin_service.dart' as _i20; import 'package:stackwallet/services/coins/manager.dart' as _i6; -import 'package:stackwallet/services/locale_service.dart' as _i32; +import 'package:stackwallet/services/locale_service.dart' as _i35; import 'package:stackwallet/services/node_service.dart' as _i3; import 'package:stackwallet/services/transaction_notification_tracker.dart' as _i7; @@ -35,8 +35,11 @@ import 'package:stackwallet/services/wallets.dart' as _i21; import 'package:stackwallet/services/wallets_service.dart' as _i2; import 'package:stackwallet/themes/theme_service.dart' as _i30; import 'package:stackwallet/utilities/amount/amount.dart' as _i14; +import 'package:stackwallet/utilities/amount/amount_unit.dart' as _i34; +import 'package:stackwallet/utilities/enums/backup_frequency_type.dart' as _i33; import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i22; import 'package:stackwallet/utilities/enums/derive_path_type_enum.dart' as _i27; +import 'package:stackwallet/utilities/enums/sync_type_enum.dart' as _i32; import 'package:stackwallet/utilities/flutter_secure_storage_interface.dart' as _i19; import 'package:stackwallet/utilities/prefs.dart' as _i24; @@ -779,7 +782,7 @@ class MockBitcoinWallet extends _i1.Mock implements _i26.BitcoinWallet { @override _i22.Coin get coin => (super.noSuchMethod( Invocation.getter(#coin), - returnValue: _i22.Coin.bitcoin, + returnValue: _i22.Coin.banano, ) as _i22.Coin); @override _i23.Future> get utxos => (super.noSuchMethod( @@ -2055,10 +2058,488 @@ class MockThemeService extends _i1.Mock implements _i30.ThemeService { )) as _i31.StackTheme?); } +/// A class which mocks [Prefs]. +/// +/// See the documentation for Mockito's code generation for more information. +class MockPrefs extends _i1.Mock implements _i24.Prefs { + MockPrefs() { + _i1.throwOnMissingStub(this); + } + + @override + bool get isInitialized => (super.noSuchMethod( + Invocation.getter(#isInitialized), + returnValue: false, + ) as bool); + @override + int get lastUnlockedTimeout => (super.noSuchMethod( + Invocation.getter(#lastUnlockedTimeout), + returnValue: 0, + ) as int); + @override + set lastUnlockedTimeout(int? lastUnlockedTimeout) => super.noSuchMethod( + Invocation.setter( + #lastUnlockedTimeout, + lastUnlockedTimeout, + ), + returnValueForMissingStub: null, + ); + @override + int get lastUnlocked => (super.noSuchMethod( + Invocation.getter(#lastUnlocked), + returnValue: 0, + ) as int); + @override + set lastUnlocked(int? lastUnlocked) => super.noSuchMethod( + Invocation.setter( + #lastUnlocked, + lastUnlocked, + ), + returnValueForMissingStub: null, + ); + @override + int get currentNotificationId => (super.noSuchMethod( + Invocation.getter(#currentNotificationId), + returnValue: 0, + ) as int); + @override + List get walletIdsSyncOnStartup => (super.noSuchMethod( + Invocation.getter(#walletIdsSyncOnStartup), + returnValue: [], + ) as List); + @override + set walletIdsSyncOnStartup(List? walletIdsSyncOnStartup) => + super.noSuchMethod( + Invocation.setter( + #walletIdsSyncOnStartup, + walletIdsSyncOnStartup, + ), + returnValueForMissingStub: null, + ); + @override + _i32.SyncingType get syncType => (super.noSuchMethod( + Invocation.getter(#syncType), + returnValue: _i32.SyncingType.currentWalletOnly, + ) as _i32.SyncingType); + @override + set syncType(_i32.SyncingType? syncType) => super.noSuchMethod( + Invocation.setter( + #syncType, + syncType, + ), + returnValueForMissingStub: null, + ); + @override + bool get wifiOnly => (super.noSuchMethod( + Invocation.getter(#wifiOnly), + returnValue: false, + ) as bool); + @override + set wifiOnly(bool? wifiOnly) => super.noSuchMethod( + Invocation.setter( + #wifiOnly, + wifiOnly, + ), + returnValueForMissingStub: null, + ); + @override + bool get showFavoriteWallets => (super.noSuchMethod( + Invocation.getter(#showFavoriteWallets), + returnValue: false, + ) as bool); + @override + set showFavoriteWallets(bool? showFavoriteWallets) => super.noSuchMethod( + Invocation.setter( + #showFavoriteWallets, + showFavoriteWallets, + ), + returnValueForMissingStub: null, + ); + @override + String get language => (super.noSuchMethod( + Invocation.getter(#language), + returnValue: '', + ) as String); + @override + set language(String? newLanguage) => super.noSuchMethod( + Invocation.setter( + #language, + newLanguage, + ), + returnValueForMissingStub: null, + ); + @override + String get currency => (super.noSuchMethod( + Invocation.getter(#currency), + returnValue: '', + ) as String); + @override + set currency(String? newCurrency) => super.noSuchMethod( + Invocation.setter( + #currency, + newCurrency, + ), + returnValueForMissingStub: null, + ); + @override + bool get randomizePIN => (super.noSuchMethod( + Invocation.getter(#randomizePIN), + returnValue: false, + ) as bool); + @override + set randomizePIN(bool? randomizePIN) => super.noSuchMethod( + Invocation.setter( + #randomizePIN, + randomizePIN, + ), + returnValueForMissingStub: null, + ); + @override + bool get useBiometrics => (super.noSuchMethod( + Invocation.getter(#useBiometrics), + returnValue: false, + ) as bool); + @override + set useBiometrics(bool? useBiometrics) => super.noSuchMethod( + Invocation.setter( + #useBiometrics, + useBiometrics, + ), + returnValueForMissingStub: null, + ); + @override + bool get hasPin => (super.noSuchMethod( + Invocation.getter(#hasPin), + returnValue: false, + ) as bool); + @override + set hasPin(bool? hasPin) => super.noSuchMethod( + Invocation.setter( + #hasPin, + hasPin, + ), + returnValueForMissingStub: null, + ); + @override + int get familiarity => (super.noSuchMethod( + Invocation.getter(#familiarity), + returnValue: 0, + ) as int); + @override + set familiarity(int? familiarity) => super.noSuchMethod( + Invocation.setter( + #familiarity, + familiarity, + ), + returnValueForMissingStub: null, + ); + @override + bool get showTestNetCoins => (super.noSuchMethod( + Invocation.getter(#showTestNetCoins), + returnValue: false, + ) as bool); + @override + set showTestNetCoins(bool? showTestNetCoins) => super.noSuchMethod( + Invocation.setter( + #showTestNetCoins, + showTestNetCoins, + ), + returnValueForMissingStub: null, + ); + @override + bool get isAutoBackupEnabled => (super.noSuchMethod( + Invocation.getter(#isAutoBackupEnabled), + returnValue: false, + ) as bool); + @override + set isAutoBackupEnabled(bool? isAutoBackupEnabled) => super.noSuchMethod( + Invocation.setter( + #isAutoBackupEnabled, + isAutoBackupEnabled, + ), + returnValueForMissingStub: null, + ); + @override + set autoBackupLocation(String? autoBackupLocation) => super.noSuchMethod( + Invocation.setter( + #autoBackupLocation, + autoBackupLocation, + ), + returnValueForMissingStub: null, + ); + @override + _i33.BackupFrequencyType get backupFrequencyType => (super.noSuchMethod( + Invocation.getter(#backupFrequencyType), + returnValue: _i33.BackupFrequencyType.everyTenMinutes, + ) as _i33.BackupFrequencyType); + @override + set backupFrequencyType(_i33.BackupFrequencyType? backupFrequencyType) => + super.noSuchMethod( + Invocation.setter( + #backupFrequencyType, + backupFrequencyType, + ), + returnValueForMissingStub: null, + ); + @override + set lastAutoBackup(DateTime? lastAutoBackup) => super.noSuchMethod( + Invocation.setter( + #lastAutoBackup, + lastAutoBackup, + ), + returnValueForMissingStub: null, + ); + @override + bool get hideBlockExplorerWarning => (super.noSuchMethod( + Invocation.getter(#hideBlockExplorerWarning), + returnValue: false, + ) as bool); + @override + set hideBlockExplorerWarning(bool? hideBlockExplorerWarning) => + super.noSuchMethod( + Invocation.setter( + #hideBlockExplorerWarning, + hideBlockExplorerWarning, + ), + returnValueForMissingStub: null, + ); + @override + bool get gotoWalletOnStartup => (super.noSuchMethod( + Invocation.getter(#gotoWalletOnStartup), + returnValue: false, + ) as bool); + @override + set gotoWalletOnStartup(bool? gotoWalletOnStartup) => super.noSuchMethod( + Invocation.setter( + #gotoWalletOnStartup, + gotoWalletOnStartup, + ), + returnValueForMissingStub: null, + ); + @override + set startupWalletId(String? startupWalletId) => super.noSuchMethod( + Invocation.setter( + #startupWalletId, + startupWalletId, + ), + returnValueForMissingStub: null, + ); + @override + bool get externalCalls => (super.noSuchMethod( + Invocation.getter(#externalCalls), + returnValue: false, + ) as bool); + @override + set externalCalls(bool? externalCalls) => super.noSuchMethod( + Invocation.setter( + #externalCalls, + externalCalls, + ), + returnValueForMissingStub: null, + ); + @override + bool get enableCoinControl => (super.noSuchMethod( + Invocation.getter(#enableCoinControl), + returnValue: false, + ) as bool); + @override + set enableCoinControl(bool? enableCoinControl) => super.noSuchMethod( + Invocation.setter( + #enableCoinControl, + enableCoinControl, + ), + returnValueForMissingStub: null, + ); + @override + bool get enableSystemBrightness => (super.noSuchMethod( + Invocation.getter(#enableSystemBrightness), + returnValue: false, + ) as bool); + @override + set enableSystemBrightness(bool? enableSystemBrightness) => + super.noSuchMethod( + Invocation.setter( + #enableSystemBrightness, + enableSystemBrightness, + ), + returnValueForMissingStub: null, + ); + @override + String get themeId => (super.noSuchMethod( + Invocation.getter(#themeId), + returnValue: '', + ) as String); + @override + set themeId(String? themeId) => super.noSuchMethod( + Invocation.setter( + #themeId, + themeId, + ), + returnValueForMissingStub: null, + ); + @override + String get systemBrightnessLightThemeId => (super.noSuchMethod( + Invocation.getter(#systemBrightnessLightThemeId), + returnValue: '', + ) as String); + @override + set systemBrightnessLightThemeId(String? systemBrightnessLightThemeId) => + super.noSuchMethod( + Invocation.setter( + #systemBrightnessLightThemeId, + systemBrightnessLightThemeId, + ), + returnValueForMissingStub: null, + ); + @override + String get systemBrightnessDarkThemeId => (super.noSuchMethod( + Invocation.getter(#systemBrightnessDarkThemeId), + returnValue: '', + ) as String); + @override + set systemBrightnessDarkThemeId(String? systemBrightnessDarkThemeId) => + super.noSuchMethod( + Invocation.setter( + #systemBrightnessDarkThemeId, + systemBrightnessDarkThemeId, + ), + returnValueForMissingStub: null, + ); + @override + bool get hasListeners => (super.noSuchMethod( + Invocation.getter(#hasListeners), + returnValue: false, + ) as bool); + @override + _i23.Future init() => (super.noSuchMethod( + Invocation.method( + #init, + [], + ), + returnValue: _i23.Future.value(), + returnValueForMissingStub: _i23.Future.value(), + ) as _i23.Future); + @override + _i23.Future incrementCurrentNotificationIndex() => (super.noSuchMethod( + Invocation.method( + #incrementCurrentNotificationIndex, + [], + ), + returnValue: _i23.Future.value(), + returnValueForMissingStub: _i23.Future.value(), + ) as _i23.Future); + @override + _i23.Future isExternalCallsSet() => (super.noSuchMethod( + Invocation.method( + #isExternalCallsSet, + [], + ), + returnValue: _i23.Future.value(false), + ) as _i23.Future); + @override + _i23.Future saveUserID(String? userId) => (super.noSuchMethod( + Invocation.method( + #saveUserID, + [userId], + ), + returnValue: _i23.Future.value(), + returnValueForMissingStub: _i23.Future.value(), + ) as _i23.Future); + @override + _i23.Future saveSignupEpoch(int? signupEpoch) => (super.noSuchMethod( + Invocation.method( + #saveSignupEpoch, + [signupEpoch], + ), + returnValue: _i23.Future.value(), + returnValueForMissingStub: _i23.Future.value(), + ) as _i23.Future); + @override + _i34.AmountUnit amountUnit(_i22.Coin? coin) => (super.noSuchMethod( + Invocation.method( + #amountUnit, + [coin], + ), + returnValue: _i34.AmountUnit.normal, + ) as _i34.AmountUnit); + @override + void updateAmountUnit({ + required _i22.Coin? coin, + required _i34.AmountUnit? amountUnit, + }) => + super.noSuchMethod( + Invocation.method( + #updateAmountUnit, + [], + { + #coin: coin, + #amountUnit: amountUnit, + }, + ), + returnValueForMissingStub: null, + ); + @override + int maxDecimals(_i22.Coin? coin) => (super.noSuchMethod( + Invocation.method( + #maxDecimals, + [coin], + ), + returnValue: 0, + ) as int); + @override + void updateMaxDecimals({ + required _i22.Coin? coin, + required int? maxDecimals, + }) => + super.noSuchMethod( + Invocation.method( + #updateMaxDecimals, + [], + { + #coin: coin, + #maxDecimals: maxDecimals, + }, + ), + returnValueForMissingStub: null, + ); + @override + void addListener(_i25.VoidCallback? listener) => super.noSuchMethod( + Invocation.method( + #addListener, + [listener], + ), + returnValueForMissingStub: null, + ); + @override + void removeListener(_i25.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 [LocaleService]. /// /// See the documentation for Mockito's code generation for more information. -class MockLocaleService extends _i1.Mock implements _i32.LocaleService { +class MockLocaleService extends _i1.Mock implements _i35.LocaleService { MockLocaleService() { _i1.throwOnMissingStub(this); } @@ -2130,15 +2611,15 @@ class MockNodeService extends _i1.Mock implements _i3.NodeService { ), ) as _i19.SecureStorageInterface); @override - List<_i33.NodeModel> get primaryNodes => (super.noSuchMethod( + List<_i36.NodeModel> get primaryNodes => (super.noSuchMethod( Invocation.getter(#primaryNodes), - returnValue: <_i33.NodeModel>[], - ) as List<_i33.NodeModel>); + returnValue: <_i36.NodeModel>[], + ) as List<_i36.NodeModel>); @override - List<_i33.NodeModel> get nodes => (super.noSuchMethod( + List<_i36.NodeModel> get nodes => (super.noSuchMethod( Invocation.getter(#nodes), - returnValue: <_i33.NodeModel>[], - ) as List<_i33.NodeModel>); + returnValue: <_i36.NodeModel>[], + ) as List<_i36.NodeModel>); @override bool get hasListeners => (super.noSuchMethod( Invocation.getter(#hasListeners), @@ -2156,7 +2637,7 @@ class MockNodeService extends _i1.Mock implements _i3.NodeService { @override _i23.Future setPrimaryNodeFor({ required _i22.Coin? coin, - required _i33.NodeModel? node, + required _i36.NodeModel? node, bool? shouldNotifyListeners = false, }) => (super.noSuchMethod( @@ -2173,40 +2654,40 @@ class MockNodeService extends _i1.Mock implements _i3.NodeService { returnValueForMissingStub: _i23.Future.value(), ) as _i23.Future); @override - _i33.NodeModel? getPrimaryNodeFor({required _i22.Coin? coin}) => + _i36.NodeModel? getPrimaryNodeFor({required _i22.Coin? coin}) => (super.noSuchMethod(Invocation.method( #getPrimaryNodeFor, [], {#coin: coin}, - )) as _i33.NodeModel?); + )) as _i36.NodeModel?); @override - List<_i33.NodeModel> getNodesFor(_i22.Coin? coin) => (super.noSuchMethod( + List<_i36.NodeModel> getNodesFor(_i22.Coin? coin) => (super.noSuchMethod( Invocation.method( #getNodesFor, [coin], ), - returnValue: <_i33.NodeModel>[], - ) as List<_i33.NodeModel>); + returnValue: <_i36.NodeModel>[], + ) as List<_i36.NodeModel>); @override - _i33.NodeModel? getNodeById({required String? id}) => + _i36.NodeModel? getNodeById({required String? id}) => (super.noSuchMethod(Invocation.method( #getNodeById, [], {#id: id}, - )) as _i33.NodeModel?); + )) as _i36.NodeModel?); @override - List<_i33.NodeModel> failoverNodesFor({required _i22.Coin? coin}) => + List<_i36.NodeModel> failoverNodesFor({required _i22.Coin? coin}) => (super.noSuchMethod( Invocation.method( #failoverNodesFor, [], {#coin: coin}, ), - returnValue: <_i33.NodeModel>[], - ) as List<_i33.NodeModel>); + returnValue: <_i36.NodeModel>[], + ) as List<_i36.NodeModel>); @override _i23.Future add( - _i33.NodeModel? node, + _i36.NodeModel? node, String? password, bool? shouldNotifyListeners, ) => @@ -2258,7 +2739,7 @@ class MockNodeService extends _i1.Mock implements _i3.NodeService { ) as _i23.Future); @override _i23.Future edit( - _i33.NodeModel? editedNode, + _i36.NodeModel? editedNode, String? password, bool? shouldNotifyListeners, ) => @@ -2350,7 +2831,7 @@ class MockManager extends _i1.Mock implements _i6.Manager { @override _i22.Coin get coin => (super.noSuchMethod( Invocation.getter(#coin), - returnValue: _i22.Coin.bitcoin, + returnValue: _i22.Coin.banano, ) as _i22.Coin); @override bool get isRefreshing => (super.noSuchMethod( @@ -2718,7 +3199,7 @@ class MockCoinServiceAPI extends _i1.Mock implements _i20.CoinServiceAPI { @override _i22.Coin get coin => (super.noSuchMethod( Invocation.getter(#coin), - returnValue: _i22.Coin.bitcoin, + returnValue: _i22.Coin.banano, ) as _i22.Coin); @override bool get isRefreshing => (super.noSuchMethod( diff --git a/test/widget_tests/table_view/table_view_row_test.mocks.dart b/test/widget_tests/table_view/table_view_row_test.mocks.dart index 50901aa31..56607efda 100644 --- a/test/widget_tests/table_view/table_view_row_test.mocks.dart +++ b/test/widget_tests/table_view/table_view_row_test.mocks.dart @@ -866,7 +866,7 @@ class MockBitcoinWallet extends _i1.Mock implements _i28.BitcoinWallet { @override _i21.Coin get coin => (super.noSuchMethod( Invocation.getter(#coin), - returnValue: _i21.Coin.bitcoin, + returnValue: _i21.Coin.banano, ) as _i21.Coin); @override _i22.Future> get utxos => (super.noSuchMethod( @@ -2077,7 +2077,7 @@ class MockManager extends _i1.Mock implements _i6.Manager { @override _i21.Coin get coin => (super.noSuchMethod( Invocation.getter(#coin), - returnValue: _i21.Coin.bitcoin, + returnValue: _i21.Coin.banano, ) as _i21.Coin); @override bool get isRefreshing => (super.noSuchMethod( @@ -2445,7 +2445,7 @@ class MockCoinServiceAPI extends _i1.Mock implements _i19.CoinServiceAPI { @override _i21.Coin get coin => (super.noSuchMethod( Invocation.getter(#coin), - returnValue: _i21.Coin.bitcoin, + returnValue: _i21.Coin.banano, ) as _i21.Coin); @override bool get isRefreshing => (super.noSuchMethod( diff --git a/test/widget_tests/transaction_card_test.dart b/test/widget_tests/transaction_card_test.dart index cb82decca..3a9765720 100644 --- a/test/widget_tests/transaction_card_test.dart +++ b/test/widget_tests/transaction_card_test.dart @@ -1,5 +1,20 @@ +import 'package:decimal/decimal.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_feather_icons/flutter_feather_icons.dart'; +import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_test/flutter_test.dart'; +import 'package:mockingjay/mockingjay.dart' as mockingjay; import 'package:mockito/annotations.dart'; +import 'package:mockito/mockito.dart'; +import 'package:stackwallet/db/isar/main_db.dart'; +import 'package:stackwallet/models/isar/models/isar_models.dart'; +import 'package:stackwallet/models/isar/stack_theme.dart'; +import 'package:stackwallet/pages/wallet_view/transaction_views/transaction_details_view.dart'; +import 'package:stackwallet/providers/db/main_db_provider.dart'; +import 'package:stackwallet/providers/global/locale_provider.dart'; +import 'package:stackwallet/providers/global/prefs_provider.dart'; +import 'package:stackwallet/providers/global/price_provider.dart'; +import 'package:stackwallet/providers/global/wallets_provider.dart'; import 'package:stackwallet/services/coins/coin_service.dart'; import 'package:stackwallet/services/coins/firo/firo_wallet.dart'; import 'package:stackwallet/services/coins/manager.dart'; @@ -7,8 +22,18 @@ import 'package:stackwallet/services/locale_service.dart'; import 'package:stackwallet/services/notes_service.dart'; import 'package:stackwallet/services/price_service.dart'; import 'package:stackwallet/services/wallets.dart'; +import 'package:stackwallet/themes/stack_colors.dart'; import 'package:stackwallet/themes/theme_service.dart'; +import 'package:stackwallet/utilities/amount/amount.dart'; +import 'package:stackwallet/utilities/amount/amount_unit.dart'; +import 'package:stackwallet/utilities/enums/coin_enum.dart'; import 'package:stackwallet/utilities/prefs.dart'; +import 'package:stackwallet/utilities/util.dart'; +import 'package:stackwallet/widgets/transaction_card.dart'; +import 'package:tuple/tuple.dart'; + +import '../sample_data/theme_json.dart'; +import 'transaction_card_test.mocks.dart'; @GenerateMocks([ Wallets, @@ -20,466 +45,519 @@ import 'package:stackwallet/utilities/prefs.dart'; PriceService, NotesService, ThemeService, + MainDB, ], customMocks: []) void main() { TestWidgetsFlutterBinding.ensureInitialized(); - // testWidgets("Sent confirmed tx displays correctly", (tester) async { - // final mockManager = MockManager(); - // final mockLocaleService = MockLocaleService(); - // final wallets = MockWallets(); - // final mockPrefs = MockPrefs(); - // final mockPriceService = MockPriceService(); - // final mockThemeService = MockThemeService(); - // - // final tx = Transaction( - // txid: "some txid", - // timestamp: 1648595998, - // type: TransactionType.outgoing, - // amount: 100000000, - // amountString: Amount( - // rawValue: BigInt.from(100000000), - // fractionDigits: Coin.firo.decimals, - // ).toJsonString(), - // fee: 3794, - // height: 450123, - // subType: TransactionSubType.none, - // isCancelled: false, - // walletId: '', - // isLelantus: null, - // slateId: '', - // otherData: '', - // nonce: null, - // inputs: [], - // outputs: [], - // numberOfMessages: null, - // )..address.value = Address( - // walletId: "walletId", - // value: "", - // publicKey: [], - // derivationIndex: 0, - // derivationPath: null, - // type: AddressType.p2pkh, - // subType: AddressSubType.receiving); - // - // final CoinServiceAPI wallet = MockFiroWallet(); - // - // when(mockThemeService.getTheme(themeId: "light")).thenAnswer( - // (_) => StackTheme.fromJson( - // json: lightThemeJsonMap, - // applicationThemesDirectoryPath: "test", - // ), - // ); - // when(wallet.coin.ticker).thenAnswer((_) => "FIRO"); - // when(mockLocaleService.locale).thenAnswer((_) => "en_US"); - // when(mockPrefs.currency).thenAnswer((_) => "USD"); - // when(mockPrefs.externalCalls).thenAnswer((_) => true); - // when(mockPriceService.getPrice(Coin.firo)) - // .thenAnswer((realInvocation) => Tuple2(Decimal.ten, 0.00)); - // - // when(wallet.coin).thenAnswer((_) => Coin.firo); - // - // when(wallets.getManager("wallet-id")) - // .thenAnswer((realInvocation) => Manager(wallet)); - // - // when(wallet.storedChainHeight).thenAnswer((_) => 6000000); - // // - // await tester.pumpWidget( - // ProviderScope( - // overrides: [ - // walletsChangeNotifierProvider.overrideWithValue(wallets), - // localeServiceChangeNotifierProvider - // .overrideWithValue(mockLocaleService), - // pThemeService.overrideWithValue(mockThemeService), - // prefsChangeNotifierProvider.overrideWithValue(mockPrefs), - // priceAnd24hChangeNotifierProvider.overrideWithValue(mockPriceService) - // ], - // child: MaterialApp( - // theme: ThemeData( - // extensions: [ - // StackColors.fromStackColorTheme( - // StackTheme.fromJson( - // json: lightThemeJsonMap, - // applicationThemesDirectoryPath: "test", - // ), - // ), - // ], - // ), - // home: TransactionCard(transaction: tx, walletId: "wallet-id"), - // ), - // ), - // ); - // - // // - // final title = find.text("Sent"); - // // final price1 = find.text("0.00 USD"); - // final amount = Util.isDesktop - // ? find.text("-1.00000000 FIRO") - // : find.text("1.00000000 FIRO"); - // - // final icon = find.byIcon(FeatherIcons.arrowUp); - // - // expect(title, findsOneWidget); - // // expect(price1, findsOneWidget); - // expect(amount, findsOneWidget); - // // expect(icon, findsOneWidget); - // // - // await tester.pumpAndSettle(const Duration(seconds: 2)); - // // - // // final price2 = find.text("\$10.00"); - // // expect(price2, findsOneWidget); - // // - // // verify(mockManager.addListener(any)).called(1); - // verify(mockLocaleService.addListener(any)).called(1); - // - // verify(mockPrefs.currency).called(1); - // verify(mockPriceService.getPrice(Coin.firo)).called(1); - // verify(wallet.coin.ticker).called(1); - // - // verify(mockLocaleService.locale).called(1); - // - // verifyNoMoreInteractions(mockManager); - // verifyNoMoreInteractions(mockLocaleService); - // }); + testWidgets("Sent confirmed tx displays correctly", (tester) async { + final mockManager = MockManager(); + final mockLocaleService = MockLocaleService(); + final wallets = MockWallets(); + final mockPrefs = MockPrefs(); + final mockPriceService = MockPriceService(); + final mockThemeService = MockThemeService(); + final mockDB = MockMainDB(); - // testWidgets("Anonymized confirmed tx displays correctly", (tester) async { - // final mockManager = MockManager(); - // final mockLocaleService = MockLocaleService(); - // final wallets = MockWallets(); - // final mockPrefs = MockPrefs(); - // final mockPriceService = MockPriceService(); - // final mockThemeService = MockThemeService(); - // - // final tx = Transaction( - // txid: "some txid", - // timestamp: 1648595998, - // type: TransactionType.outgoing, - // amount: 9659, - // amountString: Amount( - // rawValue: BigInt.from(9659), - // fractionDigits: Coin.firo.decimals, - // ).toJsonString(), - // fee: 3794, - // height: 450123, - // subType: TransactionSubType.mint, - // isCancelled: false, - // walletId: '', - // isLelantus: null, - // slateId: '', - // otherData: '', - // nonce: null, - // inputs: [], - // outputs: [], - // numberOfMessages: null, - // )..address.value = Address( - // walletId: "walletId", - // value: "", - // publicKey: [], - // derivationIndex: 0, - // derivationPath: null, - // type: AddressType.p2pkh, - // subType: AddressSubType.receiving); - // - // final CoinServiceAPI wallet = MockFiroWallet(); - // - // when(mockThemeService.getTheme(themeId: "light")).thenAnswer( - // (_) => StackTheme.fromJson( - // json: lightThemeJsonMap, - // applicationThemesDirectoryPath: "test", - // ), - // ); - // when(wallet.coin.ticker).thenAnswer((_) => "FIRO"); - // when(mockLocaleService.locale).thenAnswer((_) => "en_US"); - // when(mockPrefs.currency).thenAnswer((_) => "USD"); - // when(mockPrefs.externalCalls).thenAnswer((_) => true); - // when(mockPriceService.getPrice(Coin.firo)) - // .thenAnswer((realInvocation) => Tuple2(Decimal.ten, 0.00)); - // - // when(wallet.coin).thenAnswer((_) => Coin.firo); - // when(wallet.storedChainHeight).thenAnswer((_) => 6000000); - // - // when(wallets.getManager("wallet-id")) - // .thenAnswer((realInvocation) => Manager(wallet)); - // // - // await tester.pumpWidget( - // ProviderScope( - // overrides: [ - // walletsChangeNotifierProvider.overrideWithValue(wallets), - // localeServiceChangeNotifierProvider - // .overrideWithValue(mockLocaleService), - // prefsChangeNotifierProvider.overrideWithValue(mockPrefs), - // pThemeService.overrideWithValue(mockThemeService), - // priceAnd24hChangeNotifierProvider.overrideWithValue(mockPriceService) - // ], - // child: MaterialApp( - // theme: ThemeData( - // extensions: [ - // StackColors.fromStackColorTheme( - // StackTheme.fromJson( - // json: lightThemeJsonMap, - // applicationThemesDirectoryPath: "test", - // ), - // ), - // ], - // ), - // home: TransactionCard(transaction: tx, walletId: "wallet-id"), - // ), - // ), - // ); - // - // // - // final title = find.text("Anonymized"); - // // final price1 = find.text("0.00 USD"); - // final amount = find.text("-0.00009659 FIRO"); - // - // final icon = find.byIcon(FeatherIcons.arrowUp); - // - // expect(title, findsOneWidget); - // // expect(price1, findsOneWidget); - // expect(amount, findsOneWidget); - // // expect(icon, findsOneWidget); - // // - // await tester.pumpAndSettle(const Duration(seconds: 2)); - // // - // // final price2 = find.text("\$10.00"); - // // expect(price2, findsOneWidget); - // // - // // verify(mockManager.addListener(any)).called(1); - // verify(mockLocaleService.addListener(any)).called(1); - // - // verify(mockPrefs.currency).called(1); - // verify(mockPriceService.getPrice(Coin.firo)).called(1); - // verify(wallet.coin.ticker).called(1); - // - // verify(mockLocaleService.locale).called(1); - // - // verifyNoMoreInteractions(mockManager); - // verifyNoMoreInteractions(mockLocaleService); - // }); + final tx = Transaction( + txid: "some txid", + timestamp: 1648595998, + type: TransactionType.outgoing, + amount: 100000000, + amountString: Amount( + rawValue: BigInt.from(100000000), + fractionDigits: Coin.firo.decimals, + ).toJsonString(), + fee: 3794, + height: 450123, + subType: TransactionSubType.none, + isCancelled: false, + walletId: '', + isLelantus: null, + slateId: '', + otherData: '', + nonce: null, + inputs: [], + outputs: [], + numberOfMessages: null, + )..address.value = Address( + walletId: "walletId", + value: "", + publicKey: [], + derivationIndex: 0, + derivationPath: null, + type: AddressType.p2pkh, + subType: AddressSubType.receiving); - // testWidgets("Received unconfirmed tx displays correctly", (tester) async { - // final mockManager = MockManager(); - // final mockLocaleService = MockLocaleService(); - // final wallets = MockWallets(); - // final mockPrefs = MockPrefs(); - // final mockPriceService = MockPriceService(); - // final mockThemeService = MockThemeService(); - // - // final tx = Transaction( - // txid: "some txid", - // timestamp: 1648595998, - // type: TransactionType.incoming, - // amount: 100000000, - // amountString: Amount( - // rawValue: BigInt.from(100000000), - // fractionDigits: Coin.firo.decimals, - // ).toJsonString(), - // fee: 3794, - // height: 450123, - // subType: TransactionSubType.none, - // isCancelled: false, - // walletId: '', - // isLelantus: null, - // slateId: '', - // otherData: '', - // nonce: null, - // inputs: [], - // outputs: [], - // numberOfMessages: null, - // )..address.value = Address( - // walletId: "walletId", - // value: "", - // publicKey: [], - // derivationIndex: 0, - // derivationPath: null, - // type: AddressType.p2pkh, - // subType: AddressSubType.receiving); - // - // final CoinServiceAPI wallet = MockFiroWallet(); - // - // when(mockThemeService.getTheme(themeId: "light")).thenAnswer( - // (_) => StackTheme.fromJson( - // json: lightThemeJsonMap, - // applicationThemesDirectoryPath: "test", - // ), - // ); - // when(wallet.coin.ticker).thenAnswer((_) => "FIRO"); - // when(mockLocaleService.locale).thenAnswer((_) => "en_US"); - // when(mockPrefs.currency).thenAnswer((_) => "USD"); - // when(mockPrefs.externalCalls).thenAnswer((_) => true); - // when(mockPriceService.getPrice(Coin.firo)) - // .thenAnswer((realInvocation) => Tuple2(Decimal.ten, 0.00)); - // - // when(wallet.coin).thenAnswer((_) => Coin.firo); - // - // when(wallets.getManager("wallet-id")) - // .thenAnswer((realInvocation) => Manager(wallet)); - // - // when(wallet.storedChainHeight).thenAnswer((_) => 6000000); - // - // await tester.pumpWidget( - // ProviderScope( - // overrides: [ - // walletsChangeNotifierProvider.overrideWithValue(wallets), - // localeServiceChangeNotifierProvider - // .overrideWithValue(mockLocaleService), - // prefsChangeNotifierProvider.overrideWithValue(mockPrefs), - // pThemeService.overrideWithValue(mockThemeService), - // priceAnd24hChangeNotifierProvider.overrideWithValue(mockPriceService) - // ], - // child: MaterialApp( - // theme: ThemeData( - // extensions: [ - // StackColors.fromStackColorTheme( - // StackTheme.fromJson( - // json: lightThemeJsonMap, - // applicationThemesDirectoryPath: "test", - // ), - // ), - // ], - // ), - // home: TransactionCard(transaction: tx, walletId: "wallet-id"), - // ), - // ), - // ); - // - // final title = find.text("Received"); - // final amount = Util.isDesktop - // ? find.text("+1.00000000 FIRO") - // : find.text("1.00000000 FIRO"); - // - // expect(title, findsOneWidget); - // expect(amount, findsOneWidget); - // - // await tester.pumpAndSettle(const Duration(seconds: 2)); - // - // verify(mockLocaleService.addListener(any)).called(1); - // - // verify(mockPrefs.currency).called(1); - // verify(mockPriceService.getPrice(Coin.firo)).called(1); - // verify(wallet.coin.ticker).called(1); - // - // verify(mockLocaleService.locale).called(1); - // - // verifyNoMoreInteractions(mockManager); - // verifyNoMoreInteractions(mockLocaleService); - // }); + final CoinServiceAPI wallet = MockFiroWallet(); - // testWidgets("Tap gesture", (tester) async { - // final mockManager = MockManager(); - // final mockLocaleService = MockLocaleService(); - // final wallets = MockWallets(); - // final mockPrefs = MockPrefs(); - // final mockPriceService = MockPriceService(); - // final mockThemeService = MockThemeService(); - // final navigator = mockingjay.MockNavigator(); - // - // final tx = Transaction( - // txid: "some txid", - // timestamp: 1648595998, - // type: TransactionType.outgoing, - // amount: 100000000, - // amountString: Amount( - // rawValue: BigInt.from(100000000), - // fractionDigits: Coin.firo.decimals, - // ).toJsonString(), - // fee: 3794, - // height: 450123, - // subType: TransactionSubType.none, - // isCancelled: false, - // walletId: '', - // isLelantus: null, - // slateId: '', - // otherData: '', - // nonce: null, - // inputs: [], - // outputs: [], - // numberOfMessages: null, - // )..address.value = Address( - // walletId: "walletId", - // value: "", - // publicKey: [], - // derivationIndex: 0, - // derivationPath: null, - // type: AddressType.p2pkh, - // subType: AddressSubType.receiving); - // - // final CoinServiceAPI wallet = MockFiroWallet(); - // - // when(mockThemeService.getTheme(themeId: "light")).thenAnswer( - // (_) => StackTheme.fromJson( - // json: lightThemeJsonMap, - // applicationThemesDirectoryPath: "test", - // ), - // ); - // when(wallet.coin.ticker).thenAnswer((_) => "FIRO"); - // when(mockLocaleService.locale).thenAnswer((_) => "en_US"); - // when(mockPrefs.currency).thenAnswer((_) => "USD"); - // when(mockPrefs.externalCalls).thenAnswer((_) => true); - // when(mockPriceService.getPrice(Coin.firo)) - // .thenAnswer((realInvocation) => Tuple2(Decimal.ten, 0.00)); - // - // when(wallet.coin).thenAnswer((_) => Coin.firo); - // - // when(wallets.getManager("wallet id")) - // .thenAnswer((realInvocation) => Manager(wallet)); - // - // when(wallet.storedChainHeight).thenAnswer((_) => 6000000); - // - // mockingjay - // .when(() => navigator.pushNamed("/transactionDetails", - // arguments: Tuple3(tx, Coin.firo, "wallet id"))) - // .thenAnswer((_) async => {}); - // - // await tester.pumpWidget( - // ProviderScope( - // overrides: [ - // walletsChangeNotifierProvider.overrideWithValue(wallets), - // localeServiceChangeNotifierProvider - // .overrideWithValue(mockLocaleService), - // prefsChangeNotifierProvider.overrideWithValue(mockPrefs), - // pThemeService.overrideWithValue(mockThemeService), - // priceAnd24hChangeNotifierProvider.overrideWithValue(mockPriceService) - // ], - // child: MaterialApp( - // theme: ThemeData( - // extensions: [ - // StackColors.fromStackColorTheme( - // StackTheme.fromJson( - // json: lightThemeJsonMap, - // applicationThemesDirectoryPath: "test", - // ), - // ), - // ], - // ), - // home: mockingjay.MockNavigatorProvider( - // navigator: navigator, - // child: TransactionCard(transaction: tx, walletId: "wallet id")), - // ), - // ), - // ); - // - // expect(find.byType(GestureDetector), findsOneWidget); - // - // await tester.tap(find.byType(GestureDetector)); - // await tester.pump(); - // - // verify(mockLocaleService.addListener(any)).called(1); - // - // verify(mockPrefs.currency).called(2); - // verify(mockLocaleService.locale).called(4); - // verify(wallet.coin.ticker).called(1); - // verify(wallet.storedChainHeight).called(2); - // - // verifyNoMoreInteractions(wallet); - // verifyNoMoreInteractions(mockLocaleService); - // - // if (Util.isDesktop) { - // expect(find.byType(TransactionDetailsView), findsOneWidget); - // } else { - // mockingjay - // .verify(() => navigator.pushNamed("/transactionDetails", - // arguments: Tuple3(tx, Coin.firo, "wallet id"))) - // .called(1); - // } - // }); + when(mockThemeService.getTheme(themeId: "light")).thenAnswer( + (_) => StackTheme.fromJson( + json: lightThemeJsonMap, + applicationThemesDirectoryPath: "test", + ), + ); + when(wallet.coin.ticker).thenAnswer((_) => "FIRO"); + when(mockLocaleService.locale).thenAnswer((_) => "en_US"); + when(mockPrefs.currency).thenAnswer((_) => "USD"); + when(mockPrefs.externalCalls).thenAnswer((_) => true); + when(mockPriceService.getPrice(Coin.firo)) + .thenAnswer((realInvocation) => Tuple2(Decimal.ten, 0.00)); + + when(wallet.coin).thenAnswer((_) => Coin.firo); + + when(wallets.getManager("wallet-id")) + .thenAnswer((realInvocation) => Manager(wallet)); + + when(wallet.storedChainHeight).thenAnswer((_) => 6000000); + + when(mockPrefs.amountUnit(Coin.firo)).thenAnswer( + (_) => AmountUnit.normal, + ); + when(mockPrefs.maxDecimals(Coin.firo)).thenAnswer( + (_) => 8, + ); + + when(mockDB.getEthContractSync("")).thenAnswer( + (_) => null, + ); + // + await tester.pumpWidget( + ProviderScope( + overrides: [ + walletsChangeNotifierProvider.overrideWithValue(wallets), + localeServiceChangeNotifierProvider + .overrideWithValue(mockLocaleService), + pThemeService.overrideWithValue(mockThemeService), + prefsChangeNotifierProvider.overrideWithValue(mockPrefs), + priceAnd24hChangeNotifierProvider.overrideWithValue(mockPriceService), + mainDBProvider.overrideWithValue(mockDB), + ], + child: MaterialApp( + theme: ThemeData( + extensions: [ + StackColors.fromStackColorTheme( + StackTheme.fromJson( + json: lightThemeJsonMap, + applicationThemesDirectoryPath: "test", + ), + ), + ], + ), + home: TransactionCard(transaction: tx, walletId: "wallet-id"), + ), + ), + ); + + // + final title = find.text("Sent"); + // final price1 = find.text("0.00 USD"); + final amount = Util.isDesktop + ? find.text("-1.00000000 FIRO") + : find.text("1.00000000 FIRO"); + + final icon = find.byIcon(FeatherIcons.arrowUp); + + expect(title, findsOneWidget); + // expect(price1, findsOneWidget); + expect(amount, findsOneWidget); + // expect(icon, findsOneWidget); + // + await tester.pumpAndSettle(const Duration(seconds: 2)); + // + // final price2 = find.text("\$10.00"); + // expect(price2, findsOneWidget); + // + // verify(mockManager.addListener(any)).called(1); + verify(mockLocaleService.addListener(any)).called(1); + + verify(mockPrefs.currency).called(1); + verify(mockPriceService.getPrice(Coin.firo)).called(1); + verify(wallet.coin.ticker).called(1); + + verify(mockLocaleService.locale).called(2); + + verifyNoMoreInteractions(mockManager); + verifyNoMoreInteractions(mockLocaleService); + }); + + testWidgets("Anonymized confirmed tx displays correctly", (tester) async { + final mockManager = MockManager(); + final mockLocaleService = MockLocaleService(); + final wallets = MockWallets(); + final mockPrefs = MockPrefs(); + final mockPriceService = MockPriceService(); + final mockThemeService = MockThemeService(); + final mockDB = MockMainDB(); + + final tx = Transaction( + txid: "some txid", + timestamp: 1648595998, + type: TransactionType.outgoing, + amount: 9659, + amountString: Amount( + rawValue: BigInt.from(9659), + fractionDigits: Coin.firo.decimals, + ).toJsonString(), + fee: 3794, + height: 450123, + subType: TransactionSubType.mint, + isCancelled: false, + walletId: '', + isLelantus: null, + slateId: '', + otherData: '', + nonce: null, + inputs: [], + outputs: [], + numberOfMessages: null, + )..address.value = Address( + walletId: "walletId", + value: "", + publicKey: [], + derivationIndex: 0, + derivationPath: null, + type: AddressType.p2pkh, + subType: AddressSubType.receiving); + + final CoinServiceAPI wallet = MockFiroWallet(); + + when(mockThemeService.getTheme(themeId: "light")).thenAnswer( + (_) => StackTheme.fromJson( + json: lightThemeJsonMap, + applicationThemesDirectoryPath: "test", + ), + ); + when(wallet.coin.ticker).thenAnswer((_) => "FIRO"); + when(mockLocaleService.locale).thenAnswer((_) => "en_US"); + when(mockPrefs.currency).thenAnswer((_) => "USD"); + when(mockPrefs.externalCalls).thenAnswer((_) => true); + when(mockPriceService.getPrice(Coin.firo)) + .thenAnswer((realInvocation) => Tuple2(Decimal.ten, 0.00)); + + when(wallet.coin).thenAnswer((_) => Coin.firo); + when(wallet.storedChainHeight).thenAnswer((_) => 6000000); + + when(mockPrefs.amountUnit(Coin.firo)).thenAnswer( + (_) => AmountUnit.normal, + ); + when(mockPrefs.maxDecimals(Coin.firo)).thenAnswer( + (_) => 8, + ); + + when(mockDB.getEthContractSync("")).thenAnswer( + (_) => null, + ); + + when(wallets.getManager("wallet-id")) + .thenAnswer((realInvocation) => Manager(wallet)); + // + await tester.pumpWidget( + ProviderScope( + overrides: [ + walletsChangeNotifierProvider.overrideWithValue(wallets), + localeServiceChangeNotifierProvider + .overrideWithValue(mockLocaleService), + prefsChangeNotifierProvider.overrideWithValue(mockPrefs), + pThemeService.overrideWithValue(mockThemeService), + mainDBProvider.overrideWithValue(mockDB), + priceAnd24hChangeNotifierProvider.overrideWithValue(mockPriceService) + ], + child: MaterialApp( + theme: ThemeData( + extensions: [ + StackColors.fromStackColorTheme( + StackTheme.fromJson( + json: lightThemeJsonMap, + applicationThemesDirectoryPath: "test", + ), + ), + ], + ), + home: TransactionCard(transaction: tx, walletId: "wallet-id"), + ), + ), + ); + + // + final title = find.text("Anonymized"); + // final price1 = find.text("0.00 USD"); + final amount = find.text("-0.00009659 FIRO"); + + final icon = find.byIcon(FeatherIcons.arrowUp); + + expect(title, findsOneWidget); + // expect(price1, findsOneWidget); + expect(amount, findsOneWidget); + // expect(icon, findsOneWidget); + // + await tester.pumpAndSettle(const Duration(seconds: 2)); + // + // final price2 = find.text("\$10.00"); + // expect(price2, findsOneWidget); + // + // verify(mockManager.addListener(any)).called(1); + verify(mockLocaleService.addListener(any)).called(1); + + verify(mockPrefs.currency).called(1); + verify(mockPriceService.getPrice(Coin.firo)).called(1); + verify(wallet.coin.ticker).called(1); + + verify(mockLocaleService.locale).called(2); + + verifyNoMoreInteractions(mockManager); + verifyNoMoreInteractions(mockLocaleService); + }); + + testWidgets("Received unconfirmed tx displays correctly", (tester) async { + final mockManager = MockManager(); + final mockLocaleService = MockLocaleService(); + final wallets = MockWallets(); + final mockPrefs = MockPrefs(); + final mockPriceService = MockPriceService(); + final mockThemeService = MockThemeService(); + final mockDB = MockMainDB(); + + final tx = Transaction( + txid: "some txid", + timestamp: 1648595998, + type: TransactionType.incoming, + amount: 100000000, + amountString: Amount( + rawValue: BigInt.from(100000000), + fractionDigits: Coin.firo.decimals, + ).toJsonString(), + fee: 3794, + height: 450123, + subType: TransactionSubType.none, + isCancelled: false, + walletId: '', + isLelantus: null, + slateId: '', + otherData: '', + nonce: null, + inputs: [], + outputs: [], + numberOfMessages: null, + )..address.value = Address( + walletId: "walletId", + value: "", + publicKey: [], + derivationIndex: 0, + derivationPath: null, + type: AddressType.p2pkh, + subType: AddressSubType.receiving); + + final CoinServiceAPI wallet = MockFiroWallet(); + + when(mockThemeService.getTheme(themeId: "light")).thenAnswer( + (_) => StackTheme.fromJson( + json: lightThemeJsonMap, + applicationThemesDirectoryPath: "test", + ), + ); + when(wallet.coin.ticker).thenAnswer((_) => "FIRO"); + when(mockLocaleService.locale).thenAnswer((_) => "en_US"); + when(mockPrefs.currency).thenAnswer((_) => "USD"); + when(mockPrefs.externalCalls).thenAnswer((_) => true); + when(mockPriceService.getPrice(Coin.firo)) + .thenAnswer((realInvocation) => Tuple2(Decimal.ten, 0.00)); + + when(wallet.coin).thenAnswer((_) => Coin.firo); + + when(wallets.getManager("wallet-id")) + .thenAnswer((realInvocation) => Manager(wallet)); + + when(wallet.storedChainHeight).thenAnswer((_) => 6000000); + + when(mockPrefs.amountUnit(Coin.firo)).thenAnswer( + (_) => AmountUnit.normal, + ); + when(mockPrefs.maxDecimals(Coin.firo)).thenAnswer( + (_) => 8, + ); + + when(mockDB.getEthContractSync("")).thenAnswer( + (_) => null, + ); + + await tester.pumpWidget( + ProviderScope( + overrides: [ + walletsChangeNotifierProvider.overrideWithValue(wallets), + localeServiceChangeNotifierProvider + .overrideWithValue(mockLocaleService), + prefsChangeNotifierProvider.overrideWithValue(mockPrefs), + pThemeService.overrideWithValue(mockThemeService), + mainDBProvider.overrideWithValue(mockDB), + priceAnd24hChangeNotifierProvider.overrideWithValue(mockPriceService) + ], + child: MaterialApp( + theme: ThemeData( + extensions: [ + StackColors.fromStackColorTheme( + StackTheme.fromJson( + json: lightThemeJsonMap, + applicationThemesDirectoryPath: "test", + ), + ), + ], + ), + home: TransactionCard(transaction: tx, walletId: "wallet-id"), + ), + ), + ); + + final title = find.text("Received"); + final amount = Util.isDesktop + ? find.text("+1.00000000 FIRO") + : find.text("1.00000000 FIRO"); + + expect(title, findsOneWidget); + expect(amount, findsOneWidget); + + await tester.pumpAndSettle(const Duration(seconds: 2)); + + verify(mockLocaleService.addListener(any)).called(1); + + verify(mockPrefs.currency).called(1); + verify(mockPriceService.getPrice(Coin.firo)).called(1); + verify(wallet.coin.ticker).called(1); + + verify(mockLocaleService.locale).called(2); + + verifyNoMoreInteractions(mockManager); + verifyNoMoreInteractions(mockLocaleService); + }); + + testWidgets("Tap gesture", (tester) async { + final mockManager = MockManager(); + final mockLocaleService = MockLocaleService(); + final wallets = MockWallets(); + final mockPrefs = MockPrefs(); + final mockPriceService = MockPriceService(); + final mockThemeService = MockThemeService(); + final mockDB = MockMainDB(); + final navigator = mockingjay.MockNavigator(); + + final tx = Transaction( + txid: "some txid", + timestamp: 1648595998, + type: TransactionType.outgoing, + amount: 100000000, + amountString: Amount( + rawValue: BigInt.from(100000000), + fractionDigits: Coin.firo.decimals, + ).toJsonString(), + fee: 3794, + height: 450123, + subType: TransactionSubType.none, + isCancelled: false, + walletId: '', + isLelantus: null, + slateId: '', + otherData: '', + nonce: null, + inputs: [], + outputs: [], + numberOfMessages: null, + )..address.value = Address( + walletId: "walletId", + value: "", + publicKey: [], + derivationIndex: 0, + derivationPath: null, + type: AddressType.p2pkh, + subType: AddressSubType.receiving); + + final CoinServiceAPI wallet = MockFiroWallet(); + + when(mockThemeService.getTheme(themeId: "light")).thenAnswer( + (_) => StackTheme.fromJson( + json: lightThemeJsonMap, + applicationThemesDirectoryPath: "test", + ), + ); + when(wallet.coin.ticker).thenAnswer((_) => "FIRO"); + when(mockLocaleService.locale).thenAnswer((_) => "en_US"); + when(mockPrefs.currency).thenAnswer((_) => "USD"); + when(mockPrefs.externalCalls).thenAnswer((_) => true); + when(mockPriceService.getPrice(Coin.firo)) + .thenAnswer((realInvocation) => Tuple2(Decimal.ten, 0.00)); + + when(wallet.coin).thenAnswer((_) => Coin.firo); + + when(wallets.getManager("wallet id")) + .thenAnswer((realInvocation) => Manager(wallet)); + + when(wallet.storedChainHeight).thenAnswer((_) => 6000000); + + mockingjay + .when(() => navigator.pushNamed("/transactionDetails", + arguments: Tuple3(tx, Coin.firo, "wallet id"))) + .thenAnswer((_) async => {}); + + when(mockPrefs.amountUnit(Coin.firo)).thenAnswer( + (_) => AmountUnit.normal, + ); + when(mockPrefs.maxDecimals(Coin.firo)).thenAnswer( + (_) => 8, + ); + + when(mockDB.getEthContractSync("")).thenAnswer( + (_) => null, + ); + + await tester.pumpWidget( + ProviderScope( + overrides: [ + walletsChangeNotifierProvider.overrideWithValue(wallets), + localeServiceChangeNotifierProvider + .overrideWithValue(mockLocaleService), + prefsChangeNotifierProvider.overrideWithValue(mockPrefs), + pThemeService.overrideWithValue(mockThemeService), + mainDBProvider.overrideWithValue(mockDB), + priceAnd24hChangeNotifierProvider.overrideWithValue(mockPriceService) + ], + child: MaterialApp( + theme: ThemeData( + extensions: [ + StackColors.fromStackColorTheme( + StackTheme.fromJson( + json: lightThemeJsonMap, + applicationThemesDirectoryPath: "test", + ), + ), + ], + ), + home: mockingjay.MockNavigatorProvider( + navigator: navigator, + child: TransactionCard(transaction: tx, walletId: "wallet id")), + ), + ), + ); + + expect(find.byType(GestureDetector), findsOneWidget); + + await tester.tap(find.byType(GestureDetector)); + await tester.pump(); + + verify(mockLocaleService.addListener(any)).called(1); + + verify(mockPrefs.currency).called(2); + verify(mockLocaleService.locale).called(3); + verify(wallet.coin.ticker).called(1); + verify(wallet.storedChainHeight).called(2); + + verifyNoMoreInteractions(wallet); + verifyNoMoreInteractions(mockLocaleService); + + if (Util.isDesktop) { + expect(find.byType(TransactionDetailsView), findsOneWidget); + } else { + mockingjay + .verify(() => navigator.pushNamed("/transactionDetails", + arguments: Tuple3(tx, Coin.firo, "wallet id"))) + .called(1); + } + }); } diff --git a/test/widget_tests/transaction_card_test.mocks.dart b/test/widget_tests/transaction_card_test.mocks.dart index 336fd5af7..9f2817de9 100644 --- a/test/widget_tests/transaction_card_test.mocks.dart +++ b/test/widget_tests/transaction_card_test.mocks.dart @@ -5,40 +5,43 @@ // @dart=2.19 // ignore_for_file: no_leading_underscores_for_library_prefixes -import 'dart:async' as _i18; -import 'dart:typed_data' as _i33; -import 'dart:ui' as _i20; +import 'dart:async' as _i19; +import 'dart:typed_data' as _i34; +import 'dart:ui' as _i21; -import 'package:decimal/decimal.dart' as _i29; +import 'package:decimal/decimal.dart' as _i30; import 'package:flutter/foundation.dart' as _i4; import 'package:flutter_riverpod/flutter_riverpod.dart' as _i5; +import 'package:isar/isar.dart' as _i16; import 'package:mockito/mockito.dart' as _i1; import 'package:stackwallet/db/isar/main_db.dart' as _i14; import 'package:stackwallet/electrumx_rpc/cached_electrumx.dart' as _i13; import 'package:stackwallet/electrumx_rpc/electrumx.dart' as _i12; import 'package:stackwallet/models/balance.dart' as _i9; -import 'package:stackwallet/models/isar/models/isar_models.dart' as _i21; -import 'package:stackwallet/models/isar/stack_theme.dart' as _i32; +import 'package:stackwallet/models/isar/models/block_explorer.dart' as _i36; +import 'package:stackwallet/models/isar/models/contact_entry.dart' as _i35; +import 'package:stackwallet/models/isar/models/isar_models.dart' as _i22; +import 'package:stackwallet/models/isar/stack_theme.dart' as _i33; import 'package:stackwallet/models/models.dart' as _i8; -import 'package:stackwallet/models/signing_data.dart' as _i23; +import 'package:stackwallet/models/signing_data.dart' as _i24; import 'package:stackwallet/services/coins/coin_service.dart' as _i7; -import 'package:stackwallet/services/coins/firo/firo_wallet.dart' as _i22; +import 'package:stackwallet/services/coins/firo/firo_wallet.dart' as _i23; import 'package:stackwallet/services/coins/manager.dart' as _i6; -import 'package:stackwallet/services/locale_service.dart' as _i24; +import 'package:stackwallet/services/locale_service.dart' as _i25; import 'package:stackwallet/services/node_service.dart' as _i3; -import 'package:stackwallet/services/notes_service.dart' as _i30; -import 'package:stackwallet/services/price_service.dart' as _i28; +import 'package:stackwallet/services/notes_service.dart' as _i31; +import 'package:stackwallet/services/price_service.dart' as _i29; import 'package:stackwallet/services/transaction_notification_tracker.dart' as _i11; -import 'package:stackwallet/services/wallets.dart' as _i16; +import 'package:stackwallet/services/wallets.dart' as _i17; import 'package:stackwallet/services/wallets_service.dart' as _i2; -import 'package:stackwallet/themes/theme_service.dart' as _i31; +import 'package:stackwallet/themes/theme_service.dart' as _i32; import 'package:stackwallet/utilities/amount/amount.dart' as _i10; -import 'package:stackwallet/utilities/amount/amount_unit.dart' as _i27; -import 'package:stackwallet/utilities/enums/backup_frequency_type.dart' as _i26; -import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i17; -import 'package:stackwallet/utilities/enums/sync_type_enum.dart' as _i25; -import 'package:stackwallet/utilities/prefs.dart' as _i19; +import 'package:stackwallet/utilities/amount/amount_unit.dart' as _i28; +import 'package:stackwallet/utilities/enums/backup_frequency_type.dart' as _i27; +import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i18; +import 'package:stackwallet/utilities/enums/sync_type_enum.dart' as _i26; +import 'package:stackwallet/utilities/prefs.dart' as _i20; import 'package:tuple/tuple.dart' as _i15; // ignore_for_file: type=lint @@ -198,10 +201,31 @@ class _FakeTuple2_13 extends _i1.SmartFake ); } +class _FakeIsar_14 extends _i1.SmartFake implements _i16.Isar { + _FakeIsar_14( + Object parent, + Invocation parentInvocation, + ) : super( + parent, + parentInvocation, + ); +} + +class _FakeQueryBuilder_15 extends _i1.SmartFake + implements _i16.QueryBuilder { + _FakeQueryBuilder_15( + Object parent, + Invocation parentInvocation, + ) : super( + parent, + parentInvocation, + ); +} + /// A class which mocks [Wallets]. /// /// See the documentation for Mockito's code generation for more information. -class MockWallets extends _i1.Mock implements _i16.Wallets { +class MockWallets extends _i1.Mock implements _i17.Wallets { MockWallets() { _i1.throwOnMissingStub(this); } @@ -268,7 +292,7 @@ class MockWallets extends _i1.Mock implements _i16.Wallets { returnValueForMissingStub: null, ); @override - List getWalletIdsFor({required _i17.Coin? coin}) => + List getWalletIdsFor({required _i18.Coin? coin}) => (super.noSuchMethod( Invocation.method( #getWalletIdsFor, @@ -278,20 +302,20 @@ class MockWallets extends _i1.Mock implements _i16.Wallets { returnValue: [], ) as List); @override - List<_i15.Tuple2<_i17.Coin, List<_i5.ChangeNotifierProvider<_i6.Manager>>>> + List<_i15.Tuple2<_i18.Coin, List<_i5.ChangeNotifierProvider<_i6.Manager>>>> getManagerProvidersByCoin() => (super.noSuchMethod( Invocation.method( #getManagerProvidersByCoin, [], ), - returnValue: <_i15.Tuple2<_i17.Coin, + returnValue: <_i15.Tuple2<_i18.Coin, List<_i5.ChangeNotifierProvider<_i6.Manager>>>>[], ) as List< - _i15.Tuple2<_i17.Coin, + _i15.Tuple2<_i18.Coin, List<_i5.ChangeNotifierProvider<_i6.Manager>>>>); @override List<_i5.ChangeNotifierProvider<_i6.Manager>> getManagerProvidersForCoin( - _i17.Coin? coin) => + _i18.Coin? coin) => (super.noSuchMethod( Invocation.method( #getManagerProvidersForCoin, @@ -355,17 +379,17 @@ class MockWallets extends _i1.Mock implements _i16.Wallets { returnValueForMissingStub: null, ); @override - _i18.Future load(_i19.Prefs? prefs) => (super.noSuchMethod( + _i19.Future load(_i20.Prefs? prefs) => (super.noSuchMethod( Invocation.method( #load, [prefs], ), - returnValue: _i18.Future.value(), - returnValueForMissingStub: _i18.Future.value(), - ) as _i18.Future); + returnValue: _i19.Future.value(), + returnValueForMissingStub: _i19.Future.value(), + ) as _i19.Future); @override - _i18.Future loadAfterStackRestore( - _i19.Prefs? prefs, + _i19.Future loadAfterStackRestore( + _i20.Prefs? prefs, List<_i6.Manager>? managers, ) => (super.noSuchMethod( @@ -376,11 +400,11 @@ class MockWallets extends _i1.Mock implements _i16.Wallets { managers, ], ), - returnValue: _i18.Future.value(), - returnValueForMissingStub: _i18.Future.value(), - ) as _i18.Future); + returnValue: _i19.Future.value(), + returnValueForMissingStub: _i19.Future.value(), + ) as _i19.Future); @override - void addListener(_i20.VoidCallback? listener) => super.noSuchMethod( + void addListener(_i21.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #addListener, [listener], @@ -388,7 +412,7 @@ class MockWallets extends _i1.Mock implements _i16.Wallets { returnValueForMissingStub: null, ); @override - void removeListener(_i20.VoidCallback? listener) => super.noSuchMethod( + void removeListener(_i21.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #removeListener, [listener], @@ -440,10 +464,10 @@ class MockManager extends _i1.Mock implements _i6.Manager { returnValue: false, ) as bool); @override - _i17.Coin get coin => (super.noSuchMethod( + _i18.Coin get coin => (super.noSuchMethod( Invocation.getter(#coin), - returnValue: _i17.Coin.bitcoin, - ) as _i17.Coin); + returnValue: _i18.Coin.banano, + ) as _i18.Coin); @override bool get isRefreshing => (super.noSuchMethod( Invocation.getter(#isRefreshing), @@ -476,23 +500,23 @@ class MockManager extends _i1.Mock implements _i6.Manager { returnValueForMissingStub: null, ); @override - _i18.Future<_i8.FeeObject> get fees => (super.noSuchMethod( + _i19.Future<_i8.FeeObject> get fees => (super.noSuchMethod( Invocation.getter(#fees), - returnValue: _i18.Future<_i8.FeeObject>.value(_FakeFeeObject_5( + returnValue: _i19.Future<_i8.FeeObject>.value(_FakeFeeObject_5( this, Invocation.getter(#fees), )), - ) as _i18.Future<_i8.FeeObject>); + ) as _i19.Future<_i8.FeeObject>); @override - _i18.Future get maxFee => (super.noSuchMethod( + _i19.Future get maxFee => (super.noSuchMethod( Invocation.getter(#maxFee), - returnValue: _i18.Future.value(0), - ) as _i18.Future); + returnValue: _i19.Future.value(0), + ) as _i19.Future); @override - _i18.Future get currentReceivingAddress => (super.noSuchMethod( + _i19.Future get currentReceivingAddress => (super.noSuchMethod( Invocation.getter(#currentReceivingAddress), - returnValue: _i18.Future.value(''), - ) as _i18.Future); + returnValue: _i19.Future.value(''), + ) as _i19.Future); @override _i9.Balance get balance => (super.noSuchMethod( Invocation.getter(#balance), @@ -502,16 +526,16 @@ class MockManager extends _i1.Mock implements _i6.Manager { ), ) as _i9.Balance); @override - _i18.Future> get transactions => (super.noSuchMethod( + _i19.Future> get transactions => (super.noSuchMethod( Invocation.getter(#transactions), returnValue: - _i18.Future>.value(<_i21.Transaction>[]), - ) as _i18.Future>); + _i19.Future>.value(<_i22.Transaction>[]), + ) as _i19.Future>); @override - _i18.Future> get utxos => (super.noSuchMethod( + _i19.Future> get utxos => (super.noSuchMethod( Invocation.getter(#utxos), - returnValue: _i18.Future>.value(<_i21.UTXO>[]), - ) as _i18.Future>); + returnValue: _i19.Future>.value(<_i22.UTXO>[]), + ) as _i19.Future>); @override set walletName(String? newName) => super.noSuchMethod( Invocation.setter( @@ -531,15 +555,15 @@ class MockManager extends _i1.Mock implements _i6.Manager { returnValue: '', ) as String); @override - _i18.Future> get mnemonic => (super.noSuchMethod( + _i19.Future> get mnemonic => (super.noSuchMethod( Invocation.getter(#mnemonic), - returnValue: _i18.Future>.value([]), - ) as _i18.Future>); + returnValue: _i19.Future>.value([]), + ) as _i19.Future>); @override - _i18.Future get mnemonicPassphrase => (super.noSuchMethod( + _i19.Future get mnemonicPassphrase => (super.noSuchMethod( Invocation.getter(#mnemonicPassphrase), - returnValue: _i18.Future.value(), - ) as _i18.Future); + returnValue: _i19.Future.value(), + ) as _i19.Future); @override bool get isConnected => (super.noSuchMethod( Invocation.getter(#isConnected), @@ -581,24 +605,24 @@ class MockManager extends _i1.Mock implements _i6.Manager { returnValue: false, ) as bool); @override - _i18.Future get xpub => (super.noSuchMethod( + _i19.Future get xpub => (super.noSuchMethod( Invocation.getter(#xpub), - returnValue: _i18.Future.value(''), - ) as _i18.Future); + returnValue: _i19.Future.value(''), + ) as _i19.Future); @override bool get hasListeners => (super.noSuchMethod( Invocation.getter(#hasListeners), returnValue: false, ) as bool); @override - _i18.Future updateNode(bool? shouldRefresh) => (super.noSuchMethod( + _i19.Future updateNode(bool? shouldRefresh) => (super.noSuchMethod( Invocation.method( #updateNode, [shouldRefresh], ), - returnValue: _i18.Future.value(), - returnValueForMissingStub: _i18.Future.value(), - ) as _i18.Future); + returnValue: _i19.Future.value(), + returnValueForMissingStub: _i19.Future.value(), + ) as _i19.Future); @override void dispose() => super.noSuchMethod( Invocation.method( @@ -608,7 +632,7 @@ class MockManager extends _i1.Mock implements _i6.Manager { returnValueForMissingStub: null, ); @override - _i18.Future> prepareSend({ + _i19.Future> prepareSend({ required String? address, required _i10.Amount? amount, Map? args, @@ -624,27 +648,27 @@ class MockManager extends _i1.Mock implements _i6.Manager { }, ), returnValue: - _i18.Future>.value({}), - ) as _i18.Future>); + _i19.Future>.value({}), + ) as _i19.Future>); @override - _i18.Future confirmSend({required Map? txData}) => + _i19.Future confirmSend({required Map? txData}) => (super.noSuchMethod( Invocation.method( #confirmSend, [], {#txData: txData}, ), - returnValue: _i18.Future.value(''), - ) as _i18.Future); + returnValue: _i19.Future.value(''), + ) as _i19.Future); @override - _i18.Future refresh() => (super.noSuchMethod( + _i19.Future refresh() => (super.noSuchMethod( Invocation.method( #refresh, [], ), - returnValue: _i18.Future.value(), - returnValueForMissingStub: _i18.Future.value(), - ) as _i18.Future); + returnValue: _i19.Future.value(), + returnValueForMissingStub: _i19.Future.value(), + ) as _i19.Future); @override bool validateAddress(String? address) => (super.noSuchMethod( Invocation.method( @@ -654,33 +678,33 @@ class MockManager extends _i1.Mock implements _i6.Manager { returnValue: false, ) as bool); @override - _i18.Future testNetworkConnection() => (super.noSuchMethod( + _i19.Future testNetworkConnection() => (super.noSuchMethod( Invocation.method( #testNetworkConnection, [], ), - returnValue: _i18.Future.value(false), - ) as _i18.Future); + returnValue: _i19.Future.value(false), + ) as _i19.Future); @override - _i18.Future initializeNew() => (super.noSuchMethod( + _i19.Future initializeNew() => (super.noSuchMethod( Invocation.method( #initializeNew, [], ), - returnValue: _i18.Future.value(), - returnValueForMissingStub: _i18.Future.value(), - ) as _i18.Future); + returnValue: _i19.Future.value(), + returnValueForMissingStub: _i19.Future.value(), + ) as _i19.Future); @override - _i18.Future initializeExisting() => (super.noSuchMethod( + _i19.Future initializeExisting() => (super.noSuchMethod( Invocation.method( #initializeExisting, [], ), - returnValue: _i18.Future.value(), - returnValueForMissingStub: _i18.Future.value(), - ) as _i18.Future); + returnValue: _i19.Future.value(), + returnValueForMissingStub: _i19.Future.value(), + ) as _i19.Future); @override - _i18.Future recoverFromMnemonic({ + _i19.Future recoverFromMnemonic({ required String? mnemonic, String? mnemonicPassphrase, required int? maxUnusedAddressGap, @@ -699,20 +723,20 @@ class MockManager extends _i1.Mock implements _i6.Manager { #height: height, }, ), - returnValue: _i18.Future.value(), - returnValueForMissingStub: _i18.Future.value(), - ) as _i18.Future); + returnValue: _i19.Future.value(), + returnValueForMissingStub: _i19.Future.value(), + ) as _i19.Future); @override - _i18.Future exitCurrentWallet() => (super.noSuchMethod( + _i19.Future exitCurrentWallet() => (super.noSuchMethod( Invocation.method( #exitCurrentWallet, [], ), - returnValue: _i18.Future.value(), - returnValueForMissingStub: _i18.Future.value(), - ) as _i18.Future); + returnValue: _i19.Future.value(), + returnValueForMissingStub: _i19.Future.value(), + ) as _i19.Future); @override - _i18.Future fullRescan( + _i19.Future fullRescan( int? maxUnusedAddressGap, int? maxNumberOfIndexesToCheck, ) => @@ -724,11 +748,11 @@ class MockManager extends _i1.Mock implements _i6.Manager { maxNumberOfIndexesToCheck, ], ), - returnValue: _i18.Future.value(), - returnValueForMissingStub: _i18.Future.value(), - ) as _i18.Future); + returnValue: _i19.Future.value(), + returnValueForMissingStub: _i19.Future.value(), + ) as _i19.Future); @override - _i18.Future<_i10.Amount> estimateFeeFor( + _i19.Future<_i10.Amount> estimateFeeFor( _i10.Amount? amount, int? feeRate, ) => @@ -740,7 +764,7 @@ class MockManager extends _i1.Mock implements _i6.Manager { feeRate, ], ), - returnValue: _i18.Future<_i10.Amount>.value(_FakeAmount_7( + returnValue: _i19.Future<_i10.Amount>.value(_FakeAmount_7( this, Invocation.method( #estimateFeeFor, @@ -750,26 +774,26 @@ class MockManager extends _i1.Mock implements _i6.Manager { ], ), )), - ) as _i18.Future<_i10.Amount>); + ) as _i19.Future<_i10.Amount>); @override - _i18.Future generateNewAddress() => (super.noSuchMethod( + _i19.Future generateNewAddress() => (super.noSuchMethod( Invocation.method( #generateNewAddress, [], ), - returnValue: _i18.Future.value(false), - ) as _i18.Future); + returnValue: _i19.Future.value(false), + ) as _i19.Future); @override - _i18.Future resetRescanOnOpen() => (super.noSuchMethod( + _i19.Future resetRescanOnOpen() => (super.noSuchMethod( Invocation.method( #resetRescanOnOpen, [], ), - returnValue: _i18.Future.value(), - returnValueForMissingStub: _i18.Future.value(), - ) as _i18.Future); + returnValue: _i19.Future.value(), + returnValueForMissingStub: _i19.Future.value(), + ) as _i19.Future); @override - void addListener(_i20.VoidCallback? listener) => super.noSuchMethod( + void addListener(_i21.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #addListener, [listener], @@ -777,7 +801,7 @@ class MockManager extends _i1.Mock implements _i6.Manager { returnValueForMissingStub: null, ); @override - void removeListener(_i20.VoidCallback? listener) => super.noSuchMethod( + void removeListener(_i21.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #removeListener, [listener], @@ -812,10 +836,10 @@ class MockCoinServiceAPI extends _i1.Mock implements _i7.CoinServiceAPI { returnValueForMissingStub: null, ); @override - _i17.Coin get coin => (super.noSuchMethod( + _i18.Coin get coin => (super.noSuchMethod( Invocation.getter(#coin), - returnValue: _i17.Coin.bitcoin, - ) as _i17.Coin); + returnValue: _i18.Coin.banano, + ) as _i18.Coin); @override bool get isRefreshing => (super.noSuchMethod( Invocation.getter(#isRefreshing), @@ -848,23 +872,23 @@ class MockCoinServiceAPI extends _i1.Mock implements _i7.CoinServiceAPI { returnValueForMissingStub: null, ); @override - _i18.Future<_i8.FeeObject> get fees => (super.noSuchMethod( + _i19.Future<_i8.FeeObject> get fees => (super.noSuchMethod( Invocation.getter(#fees), - returnValue: _i18.Future<_i8.FeeObject>.value(_FakeFeeObject_5( + returnValue: _i19.Future<_i8.FeeObject>.value(_FakeFeeObject_5( this, Invocation.getter(#fees), )), - ) as _i18.Future<_i8.FeeObject>); + ) as _i19.Future<_i8.FeeObject>); @override - _i18.Future get maxFee => (super.noSuchMethod( + _i19.Future get maxFee => (super.noSuchMethod( Invocation.getter(#maxFee), - returnValue: _i18.Future.value(0), - ) as _i18.Future); + returnValue: _i19.Future.value(0), + ) as _i19.Future); @override - _i18.Future get currentReceivingAddress => (super.noSuchMethod( + _i19.Future get currentReceivingAddress => (super.noSuchMethod( Invocation.getter(#currentReceivingAddress), - returnValue: _i18.Future.value(''), - ) as _i18.Future); + returnValue: _i19.Future.value(''), + ) as _i19.Future); @override _i9.Balance get balance => (super.noSuchMethod( Invocation.getter(#balance), @@ -874,16 +898,16 @@ class MockCoinServiceAPI extends _i1.Mock implements _i7.CoinServiceAPI { ), ) as _i9.Balance); @override - _i18.Future> get transactions => (super.noSuchMethod( + _i19.Future> get transactions => (super.noSuchMethod( Invocation.getter(#transactions), returnValue: - _i18.Future>.value(<_i21.Transaction>[]), - ) as _i18.Future>); + _i19.Future>.value(<_i22.Transaction>[]), + ) as _i19.Future>); @override - _i18.Future> get utxos => (super.noSuchMethod( + _i19.Future> get utxos => (super.noSuchMethod( Invocation.getter(#utxos), - returnValue: _i18.Future>.value(<_i21.UTXO>[]), - ) as _i18.Future>); + returnValue: _i19.Future>.value(<_i22.UTXO>[]), + ) as _i19.Future>); @override set walletName(String? newName) => super.noSuchMethod( Invocation.setter( @@ -903,20 +927,20 @@ class MockCoinServiceAPI extends _i1.Mock implements _i7.CoinServiceAPI { returnValue: '', ) as String); @override - _i18.Future> get mnemonic => (super.noSuchMethod( + _i19.Future> get mnemonic => (super.noSuchMethod( Invocation.getter(#mnemonic), - returnValue: _i18.Future>.value([]), - ) as _i18.Future>); + returnValue: _i19.Future>.value([]), + ) as _i19.Future>); @override - _i18.Future get mnemonicString => (super.noSuchMethod( + _i19.Future get mnemonicString => (super.noSuchMethod( Invocation.getter(#mnemonicString), - returnValue: _i18.Future.value(), - ) as _i18.Future); + returnValue: _i19.Future.value(), + ) as _i19.Future); @override - _i18.Future get mnemonicPassphrase => (super.noSuchMethod( + _i19.Future get mnemonicPassphrase => (super.noSuchMethod( Invocation.getter(#mnemonicPassphrase), - returnValue: _i18.Future.value(), - ) as _i18.Future); + returnValue: _i19.Future.value(), + ) as _i19.Future); @override bool get hasCalledExit => (super.noSuchMethod( Invocation.getter(#hasCalledExit), @@ -933,7 +957,7 @@ class MockCoinServiceAPI extends _i1.Mock implements _i7.CoinServiceAPI { returnValue: 0, ) as int); @override - _i18.Future> prepareSend({ + _i19.Future> prepareSend({ required String? address, required _i10.Amount? amount, Map? args, @@ -949,36 +973,36 @@ class MockCoinServiceAPI extends _i1.Mock implements _i7.CoinServiceAPI { }, ), returnValue: - _i18.Future>.value({}), - ) as _i18.Future>); + _i19.Future>.value({}), + ) as _i19.Future>); @override - _i18.Future confirmSend({required Map? txData}) => + _i19.Future confirmSend({required Map? txData}) => (super.noSuchMethod( Invocation.method( #confirmSend, [], {#txData: txData}, ), - returnValue: _i18.Future.value(''), - ) as _i18.Future); + returnValue: _i19.Future.value(''), + ) as _i19.Future); @override - _i18.Future refresh() => (super.noSuchMethod( + _i19.Future refresh() => (super.noSuchMethod( Invocation.method( #refresh, [], ), - returnValue: _i18.Future.value(), - returnValueForMissingStub: _i18.Future.value(), - ) as _i18.Future); + returnValue: _i19.Future.value(), + returnValueForMissingStub: _i19.Future.value(), + ) as _i19.Future); @override - _i18.Future updateNode(bool? shouldRefresh) => (super.noSuchMethod( + _i19.Future updateNode(bool? shouldRefresh) => (super.noSuchMethod( Invocation.method( #updateNode, [shouldRefresh], ), - returnValue: _i18.Future.value(), - returnValueForMissingStub: _i18.Future.value(), - ) as _i18.Future); + returnValue: _i19.Future.value(), + returnValueForMissingStub: _i19.Future.value(), + ) as _i19.Future); @override bool validateAddress(String? address) => (super.noSuchMethod( Invocation.method( @@ -988,15 +1012,15 @@ class MockCoinServiceAPI extends _i1.Mock implements _i7.CoinServiceAPI { returnValue: false, ) as bool); @override - _i18.Future testNetworkConnection() => (super.noSuchMethod( + _i19.Future testNetworkConnection() => (super.noSuchMethod( Invocation.method( #testNetworkConnection, [], ), - returnValue: _i18.Future.value(false), - ) as _i18.Future); + returnValue: _i19.Future.value(false), + ) as _i19.Future); @override - _i18.Future recoverFromMnemonic({ + _i19.Future recoverFromMnemonic({ required String? mnemonic, String? mnemonicPassphrase, required int? maxUnusedAddressGap, @@ -1015,38 +1039,38 @@ class MockCoinServiceAPI extends _i1.Mock implements _i7.CoinServiceAPI { #height: height, }, ), - returnValue: _i18.Future.value(), - returnValueForMissingStub: _i18.Future.value(), - ) as _i18.Future); + returnValue: _i19.Future.value(), + returnValueForMissingStub: _i19.Future.value(), + ) as _i19.Future); @override - _i18.Future initializeNew() => (super.noSuchMethod( + _i19.Future initializeNew() => (super.noSuchMethod( Invocation.method( #initializeNew, [], ), - returnValue: _i18.Future.value(), - returnValueForMissingStub: _i18.Future.value(), - ) as _i18.Future); + returnValue: _i19.Future.value(), + returnValueForMissingStub: _i19.Future.value(), + ) as _i19.Future); @override - _i18.Future initializeExisting() => (super.noSuchMethod( + _i19.Future initializeExisting() => (super.noSuchMethod( Invocation.method( #initializeExisting, [], ), - returnValue: _i18.Future.value(), - returnValueForMissingStub: _i18.Future.value(), - ) as _i18.Future); + returnValue: _i19.Future.value(), + returnValueForMissingStub: _i19.Future.value(), + ) as _i19.Future); @override - _i18.Future exit() => (super.noSuchMethod( + _i19.Future exit() => (super.noSuchMethod( Invocation.method( #exit, [], ), - returnValue: _i18.Future.value(), - returnValueForMissingStub: _i18.Future.value(), - ) as _i18.Future); + returnValue: _i19.Future.value(), + returnValueForMissingStub: _i19.Future.value(), + ) as _i19.Future); @override - _i18.Future fullRescan( + _i19.Future fullRescan( int? maxUnusedAddressGap, int? maxNumberOfIndexesToCheck, ) => @@ -1058,11 +1082,11 @@ class MockCoinServiceAPI extends _i1.Mock implements _i7.CoinServiceAPI { maxNumberOfIndexesToCheck, ], ), - returnValue: _i18.Future.value(), - returnValueForMissingStub: _i18.Future.value(), - ) as _i18.Future); + returnValue: _i19.Future.value(), + returnValueForMissingStub: _i19.Future.value(), + ) as _i19.Future); @override - _i18.Future<_i10.Amount> estimateFeeFor( + _i19.Future<_i10.Amount> estimateFeeFor( _i10.Amount? amount, int? feeRate, ) => @@ -1074,7 +1098,7 @@ class MockCoinServiceAPI extends _i1.Mock implements _i7.CoinServiceAPI { feeRate, ], ), - returnValue: _i18.Future<_i10.Amount>.value(_FakeAmount_7( + returnValue: _i19.Future<_i10.Amount>.value(_FakeAmount_7( this, Invocation.method( #estimateFeeFor, @@ -1084,37 +1108,37 @@ class MockCoinServiceAPI extends _i1.Mock implements _i7.CoinServiceAPI { ], ), )), - ) as _i18.Future<_i10.Amount>); + ) as _i19.Future<_i10.Amount>); @override - _i18.Future generateNewAddress() => (super.noSuchMethod( + _i19.Future generateNewAddress() => (super.noSuchMethod( Invocation.method( #generateNewAddress, [], ), - returnValue: _i18.Future.value(false), - ) as _i18.Future); + returnValue: _i19.Future.value(false), + ) as _i19.Future); @override - _i18.Future updateSentCachedTxData(Map? txData) => + _i19.Future updateSentCachedTxData(Map? txData) => (super.noSuchMethod( Invocation.method( #updateSentCachedTxData, [txData], ), - returnValue: _i18.Future.value(), - returnValueForMissingStub: _i18.Future.value(), - ) as _i18.Future); + returnValue: _i19.Future.value(), + returnValueForMissingStub: _i19.Future.value(), + ) as _i19.Future); } /// A class which mocks [FiroWallet]. /// /// See the documentation for Mockito's code generation for more information. -class MockFiroWallet extends _i1.Mock implements _i22.FiroWallet { +class MockFiroWallet extends _i1.Mock implements _i23.FiroWallet { MockFiroWallet() { _i1.throwOnMissingStub(this); } @override - set timer(_i18.Timer? _timer) => super.noSuchMethod( + set timer(_i19.Timer? _timer) => super.noSuchMethod( Invocation.setter( #timer, _timer, @@ -1204,48 +1228,48 @@ class MockFiroWallet extends _i1.Mock implements _i22.FiroWallet { returnValue: false, ) as bool); @override - _i17.Coin get coin => (super.noSuchMethod( + _i18.Coin get coin => (super.noSuchMethod( Invocation.getter(#coin), - returnValue: _i17.Coin.bitcoin, - ) as _i17.Coin); + returnValue: _i18.Coin.banano, + ) as _i18.Coin); @override - _i18.Future> get mnemonic => (super.noSuchMethod( + _i19.Future> get mnemonic => (super.noSuchMethod( Invocation.getter(#mnemonic), - returnValue: _i18.Future>.value([]), - ) as _i18.Future>); + returnValue: _i19.Future>.value([]), + ) as _i19.Future>); @override - _i18.Future get mnemonicString => (super.noSuchMethod( + _i19.Future get mnemonicString => (super.noSuchMethod( Invocation.getter(#mnemonicString), - returnValue: _i18.Future.value(), - ) as _i18.Future); + returnValue: _i19.Future.value(), + ) as _i19.Future); @override - _i18.Future get mnemonicPassphrase => (super.noSuchMethod( + _i19.Future get mnemonicPassphrase => (super.noSuchMethod( Invocation.getter(#mnemonicPassphrase), - returnValue: _i18.Future.value(), - ) as _i18.Future); + returnValue: _i19.Future.value(), + ) as _i19.Future); @override - _i18.Future get maxFee => (super.noSuchMethod( + _i19.Future get maxFee => (super.noSuchMethod( Invocation.getter(#maxFee), - returnValue: _i18.Future.value(0), - ) as _i18.Future); + returnValue: _i19.Future.value(0), + ) as _i19.Future); @override - _i18.Future<_i8.FeeObject> get fees => (super.noSuchMethod( + _i19.Future<_i8.FeeObject> get fees => (super.noSuchMethod( Invocation.getter(#fees), - returnValue: _i18.Future<_i8.FeeObject>.value(_FakeFeeObject_5( + returnValue: _i19.Future<_i8.FeeObject>.value(_FakeFeeObject_5( this, Invocation.getter(#fees), )), - ) as _i18.Future<_i8.FeeObject>); + ) as _i19.Future<_i8.FeeObject>); @override - _i18.Future get currentReceivingAddress => (super.noSuchMethod( + _i19.Future get currentReceivingAddress => (super.noSuchMethod( Invocation.getter(#currentReceivingAddress), - returnValue: _i18.Future.value(''), - ) as _i18.Future); + returnValue: _i19.Future.value(''), + ) as _i19.Future); @override - _i18.Future get currentChangeAddress => (super.noSuchMethod( + _i19.Future get currentChangeAddress => (super.noSuchMethod( Invocation.getter(#currentChangeAddress), - returnValue: _i18.Future.value(''), - ) as _i18.Future); + returnValue: _i19.Future.value(''), + ) as _i19.Future); @override String get walletName => (super.noSuchMethod( Invocation.getter(#walletName), @@ -1296,10 +1320,10 @@ class MockFiroWallet extends _i1.Mock implements _i22.FiroWallet { returnValue: false, ) as bool); @override - _i18.Future get chainHeight => (super.noSuchMethod( + _i19.Future get chainHeight => (super.noSuchMethod( Invocation.getter(#chainHeight), - returnValue: _i18.Future.value(0), - ) as _i18.Future); + returnValue: _i19.Future.value(0), + ) as _i19.Future); @override int get storedChainHeight => (super.noSuchMethod( Invocation.getter(#storedChainHeight), @@ -1322,21 +1346,21 @@ class MockFiroWallet extends _i1.Mock implements _i22.FiroWallet { ), ) as _i9.Balance); @override - _i18.Future> get utxos => (super.noSuchMethod( + _i19.Future> get utxos => (super.noSuchMethod( Invocation.getter(#utxos), - returnValue: _i18.Future>.value(<_i21.UTXO>[]), - ) as _i18.Future>); + returnValue: _i19.Future>.value(<_i22.UTXO>[]), + ) as _i19.Future>); @override - _i18.Future> get transactions => (super.noSuchMethod( + _i19.Future> get transactions => (super.noSuchMethod( Invocation.getter(#transactions), returnValue: - _i18.Future>.value(<_i21.Transaction>[]), - ) as _i18.Future>); + _i19.Future>.value(<_i22.Transaction>[]), + ) as _i19.Future>); @override - _i18.Future get xpub => (super.noSuchMethod( + _i19.Future get xpub => (super.noSuchMethod( Invocation.getter(#xpub), - returnValue: _i18.Future.value(''), - ) as _i18.Future); + returnValue: _i19.Future.value(''), + ) as _i19.Future); @override set onIsActiveWalletChanged(void Function(bool)? _onIsActiveWalletChanged) => super.noSuchMethod( @@ -1363,23 +1387,23 @@ class MockFiroWallet extends _i1.Mock implements _i22.FiroWallet { returnValue: false, ) as bool); @override - _i18.Future updateSentCachedTxData(Map? txData) => + _i19.Future updateSentCachedTxData(Map? txData) => (super.noSuchMethod( Invocation.method( #updateSentCachedTxData, [txData], ), - returnValue: _i18.Future.value(), - returnValueForMissingStub: _i18.Future.value(), - ) as _i18.Future); + returnValue: _i19.Future.value(), + returnValueForMissingStub: _i19.Future.value(), + ) as _i19.Future); @override - _i18.Future testNetworkConnection() => (super.noSuchMethod( + _i19.Future testNetworkConnection() => (super.noSuchMethod( Invocation.method( #testNetworkConnection, [], ), - returnValue: _i18.Future.value(false), - ) as _i18.Future); + returnValue: _i19.Future.value(false), + ) as _i19.Future); @override void startNetworkAlivePinging() => super.noSuchMethod( Invocation.method( @@ -1397,7 +1421,7 @@ class MockFiroWallet extends _i1.Mock implements _i22.FiroWallet { returnValueForMissingStub: null, ); @override - _i18.Future> prepareSendPublic({ + _i19.Future> prepareSendPublic({ required String? address, required _i10.Amount? amount, Map? args, @@ -1413,20 +1437,20 @@ class MockFiroWallet extends _i1.Mock implements _i22.FiroWallet { }, ), returnValue: - _i18.Future>.value({}), - ) as _i18.Future>); + _i19.Future>.value({}), + ) as _i19.Future>); @override - _i18.Future confirmSendPublic({dynamic txData}) => + _i19.Future confirmSendPublic({dynamic txData}) => (super.noSuchMethod( Invocation.method( #confirmSendPublic, [], {#txData: txData}, ), - returnValue: _i18.Future.value(''), - ) as _i18.Future); + returnValue: _i19.Future.value(''), + ) as _i19.Future); @override - _i18.Future> prepareSend({ + _i19.Future> prepareSend({ required String? address, required _i10.Amount? amount, Map? args, @@ -1442,18 +1466,18 @@ class MockFiroWallet extends _i1.Mock implements _i22.FiroWallet { }, ), returnValue: - _i18.Future>.value({}), - ) as _i18.Future>); + _i19.Future>.value({}), + ) as _i19.Future>); @override - _i18.Future confirmSend({required Map? txData}) => + _i19.Future confirmSend({required Map? txData}) => (super.noSuchMethod( Invocation.method( #confirmSend, [], {#txData: txData}, ), - returnValue: _i18.Future.value(''), - ) as _i18.Future); + returnValue: _i19.Future.value(''), + ) as _i19.Future); @override int estimateTxFee({ required int? vSize, @@ -1477,7 +1501,7 @@ class MockFiroWallet extends _i1.Mock implements _i22.FiroWallet { String? _recipientAddress, bool? isSendAll, { int? additionalOutputs = 0, - List<_i21.UTXO>? utxos, + List<_i22.UTXO>? utxos, }) => super.noSuchMethod(Invocation.method( #coinSelection, @@ -1493,19 +1517,19 @@ class MockFiroWallet extends _i1.Mock implements _i22.FiroWallet { }, )); @override - _i18.Future> fetchBuildTxData( - List<_i21.UTXO>? utxosToUse) => + _i19.Future> fetchBuildTxData( + List<_i22.UTXO>? utxosToUse) => (super.noSuchMethod( Invocation.method( #fetchBuildTxData, [utxosToUse], ), returnValue: - _i18.Future>.value(<_i23.SigningData>[]), - ) as _i18.Future>); + _i19.Future>.value(<_i24.SigningData>[]), + ) as _i19.Future>); @override - _i18.Future> buildTransaction({ - required List<_i23.SigningData>? utxoSigningData, + _i19.Future> buildTransaction({ + required List<_i24.SigningData>? utxoSigningData, required List? recipients, required List? satoshiAmounts, }) => @@ -1520,61 +1544,61 @@ class MockFiroWallet extends _i1.Mock implements _i22.FiroWallet { }, ), returnValue: - _i18.Future>.value({}), - ) as _i18.Future>); + _i19.Future>.value({}), + ) as _i19.Future>); @override - _i18.Future updateNode(bool? shouldRefresh) => (super.noSuchMethod( + _i19.Future updateNode(bool? shouldRefresh) => (super.noSuchMethod( Invocation.method( #updateNode, [shouldRefresh], ), - returnValue: _i18.Future.value(), - returnValueForMissingStub: _i18.Future.value(), - ) as _i18.Future); + returnValue: _i19.Future.value(), + returnValueForMissingStub: _i19.Future.value(), + ) as _i19.Future); @override - _i18.Future initializeNew() => (super.noSuchMethod( + _i19.Future initializeNew() => (super.noSuchMethod( Invocation.method( #initializeNew, [], ), - returnValue: _i18.Future.value(), - returnValueForMissingStub: _i18.Future.value(), - ) as _i18.Future); + returnValue: _i19.Future.value(), + returnValueForMissingStub: _i19.Future.value(), + ) as _i19.Future); @override - _i18.Future initializeExisting() => (super.noSuchMethod( + _i19.Future initializeExisting() => (super.noSuchMethod( Invocation.method( #initializeExisting, [], ), - returnValue: _i18.Future.value(), - returnValueForMissingStub: _i18.Future.value(), - ) as _i18.Future); + returnValue: _i19.Future.value(), + returnValueForMissingStub: _i19.Future.value(), + ) as _i19.Future); @override - _i18.Future refreshIfThereIsNewData() => (super.noSuchMethod( + _i19.Future refreshIfThereIsNewData() => (super.noSuchMethod( Invocation.method( #refreshIfThereIsNewData, [], ), - returnValue: _i18.Future.value(false), - ) as _i18.Future); + returnValue: _i19.Future.value(false), + ) as _i19.Future); @override - _i18.Future getAllTxsToWatch() => (super.noSuchMethod( + _i19.Future getAllTxsToWatch() => (super.noSuchMethod( Invocation.method( #getAllTxsToWatch, [], ), - returnValue: _i18.Future.value(), - returnValueForMissingStub: _i18.Future.value(), - ) as _i18.Future); + returnValue: _i19.Future.value(), + returnValueForMissingStub: _i19.Future.value(), + ) as _i19.Future); @override - _i18.Future refresh() => (super.noSuchMethod( + _i19.Future refresh() => (super.noSuchMethod( Invocation.method( #refresh, [], ), - returnValue: _i18.Future.value(), - returnValueForMissingStub: _i18.Future.value(), - ) as _i18.Future); + returnValue: _i19.Future.value(), + returnValueForMissingStub: _i19.Future.value(), + ) as _i19.Future); @override List> getLelantusCoinMap() => (super.noSuchMethod( @@ -1585,35 +1609,35 @@ class MockFiroWallet extends _i1.Mock implements _i22.FiroWallet { returnValue: >[], ) as List>); @override - _i18.Future anonymizeAllPublicFunds() => (super.noSuchMethod( + _i19.Future anonymizeAllPublicFunds() => (super.noSuchMethod( Invocation.method( #anonymizeAllPublicFunds, [], ), - returnValue: _i18.Future.value(), - returnValueForMissingStub: _i18.Future.value(), - ) as _i18.Future); + returnValue: _i19.Future.value(), + returnValueForMissingStub: _i19.Future.value(), + ) as _i19.Future); @override - _i18.Future>> createMintsFromAmount(int? total) => + _i19.Future>> createMintsFromAmount(int? total) => (super.noSuchMethod( Invocation.method( #createMintsFromAmount, [total], ), - returnValue: _i18.Future>>.value( + returnValue: _i19.Future>>.value( >[]), - ) as _i18.Future>>); + ) as _i19.Future>>); @override - _i18.Future submitHexToNetwork(String? hex) => (super.noSuchMethod( + _i19.Future submitHexToNetwork(String? hex) => (super.noSuchMethod( Invocation.method( #submitHexToNetwork, [hex], ), - returnValue: _i18.Future.value(''), - ) as _i18.Future); + returnValue: _i19.Future.value(''), + ) as _i19.Future); @override - _i18.Future> buildMintTransaction( - List<_i21.UTXO>? utxosToUse, + _i19.Future> buildMintTransaction( + List<_i22.UTXO>? utxosToUse, int? satoshisPerRecipient, List>? mintsMap, ) => @@ -1627,29 +1651,29 @@ class MockFiroWallet extends _i1.Mock implements _i22.FiroWallet { ], ), returnValue: - _i18.Future>.value({}), - ) as _i18.Future>); + _i19.Future>.value({}), + ) as _i19.Future>); @override - _i18.Future checkReceivingAddressForTransactions() => + _i19.Future checkReceivingAddressForTransactions() => (super.noSuchMethod( Invocation.method( #checkReceivingAddressForTransactions, [], ), - returnValue: _i18.Future.value(), - returnValueForMissingStub: _i18.Future.value(), - ) as _i18.Future); + returnValue: _i19.Future.value(), + returnValueForMissingStub: _i19.Future.value(), + ) as _i19.Future); @override - _i18.Future checkChangeAddressForTransactions() => (super.noSuchMethod( + _i19.Future checkChangeAddressForTransactions() => (super.noSuchMethod( Invocation.method( #checkChangeAddressForTransactions, [], ), - returnValue: _i18.Future.value(), - returnValueForMissingStub: _i18.Future.value(), - ) as _i18.Future); + returnValue: _i19.Future.value(), + returnValueForMissingStub: _i19.Future.value(), + ) as _i19.Future); @override - _i18.Future fullRescan( + _i19.Future fullRescan( int? maxUnusedAddressGap, int? maxNumberOfIndexesToCheck, ) => @@ -1661,11 +1685,11 @@ class MockFiroWallet extends _i1.Mock implements _i22.FiroWallet { maxNumberOfIndexesToCheck, ], ), - returnValue: _i18.Future.value(), - returnValueForMissingStub: _i18.Future.value(), - ) as _i18.Future); + returnValue: _i19.Future.value(), + returnValueForMissingStub: _i19.Future.value(), + ) as _i19.Future); @override - _i18.Future recoverFromMnemonic({ + _i19.Future recoverFromMnemonic({ required String? mnemonic, String? mnemonicPassphrase, required int? maxUnusedAddressGap, @@ -1684,83 +1708,83 @@ class MockFiroWallet extends _i1.Mock implements _i22.FiroWallet { #height: height, }, ), - returnValue: _i18.Future.value(), - returnValueForMissingStub: _i18.Future.value(), - ) as _i18.Future); + returnValue: _i19.Future.value(), + returnValueForMissingStub: _i19.Future.value(), + ) as _i19.Future); @override - _i18.Future> getSetDataMap(int? latestSetId) => + _i19.Future> getSetDataMap(int? latestSetId) => (super.noSuchMethod( Invocation.method( #getSetDataMap, [latestSetId], ), - returnValue: _i18.Future>.value({}), - ) as _i18.Future>); + returnValue: _i19.Future>.value({}), + ) as _i19.Future>); @override - _i18.Future getTransactionCacheEarly(List? allAddresses) => + _i19.Future getTransactionCacheEarly(List? allAddresses) => (super.noSuchMethod( Invocation.method( #getTransactionCacheEarly, [allAddresses], ), - returnValue: _i18.Future.value(), - returnValueForMissingStub: _i18.Future.value(), - ) as _i18.Future); + returnValue: _i19.Future.value(), + returnValueForMissingStub: _i19.Future.value(), + ) as _i19.Future); @override - _i18.Future>> fetchAnonymitySets() => + _i19.Future>> fetchAnonymitySets() => (super.noSuchMethod( Invocation.method( #fetchAnonymitySets, [], ), - returnValue: _i18.Future>>.value( + returnValue: _i19.Future>>.value( >[]), - ) as _i18.Future>>); + ) as _i19.Future>>); @override - _i18.Future getLatestSetId() => (super.noSuchMethod( + _i19.Future getLatestSetId() => (super.noSuchMethod( Invocation.method( #getLatestSetId, [], ), - returnValue: _i18.Future.value(0), - ) as _i18.Future); + returnValue: _i19.Future.value(0), + ) as _i19.Future); @override - _i18.Future> getUsedCoinSerials() => (super.noSuchMethod( + _i19.Future> getUsedCoinSerials() => (super.noSuchMethod( Invocation.method( #getUsedCoinSerials, [], ), - returnValue: _i18.Future>.value([]), - ) as _i18.Future>); + returnValue: _i19.Future>.value([]), + ) as _i19.Future>); @override - _i18.Future exit() => (super.noSuchMethod( + _i19.Future exit() => (super.noSuchMethod( Invocation.method( #exit, [], ), - returnValue: _i18.Future.value(), - returnValueForMissingStub: _i18.Future.value(), - ) as _i18.Future); + returnValue: _i19.Future.value(), + returnValueForMissingStub: _i19.Future.value(), + ) as _i19.Future); @override - _i18.Future getCoinsToJoinSplit(int? required) => + _i19.Future getCoinsToJoinSplit(int? required) => (super.noSuchMethod( Invocation.method( #getCoinsToJoinSplit, [required], ), - returnValue: _i18.Future.value(), - ) as _i18.Future); + returnValue: _i19.Future.value(), + ) as _i19.Future); @override - _i18.Future estimateJoinSplitFee(int? spendAmount) => + _i19.Future estimateJoinSplitFee(int? spendAmount) => (super.noSuchMethod( Invocation.method( #estimateJoinSplitFee, [spendAmount], ), - returnValue: _i18.Future.value(0), - ) as _i18.Future); + returnValue: _i19.Future.value(0), + ) as _i19.Future); @override - _i18.Future<_i10.Amount> estimateFeeFor( + _i19.Future<_i10.Amount> estimateFeeFor( _i10.Amount? amount, int? feeRate, ) => @@ -1772,7 +1796,7 @@ class MockFiroWallet extends _i1.Mock implements _i22.FiroWallet { feeRate, ], ), - returnValue: _i18.Future<_i10.Amount>.value(_FakeAmount_7( + returnValue: _i19.Future<_i10.Amount>.value(_FakeAmount_7( this, Invocation.method( #estimateFeeFor, @@ -1782,9 +1806,9 @@ class MockFiroWallet extends _i1.Mock implements _i22.FiroWallet { ], ), )), - ) as _i18.Future<_i10.Amount>); + ) as _i19.Future<_i10.Amount>); @override - _i18.Future<_i10.Amount> estimateFeeForPublic( + _i19.Future<_i10.Amount> estimateFeeForPublic( _i10.Amount? amount, int? feeRate, ) => @@ -1796,7 +1820,7 @@ class MockFiroWallet extends _i1.Mock implements _i22.FiroWallet { feeRate, ], ), - returnValue: _i18.Future<_i10.Amount>.value(_FakeAmount_7( + returnValue: _i19.Future<_i10.Amount>.value(_FakeAmount_7( this, Invocation.method( #estimateFeeForPublic, @@ -1806,7 +1830,7 @@ class MockFiroWallet extends _i1.Mock implements _i22.FiroWallet { ], ), )), - ) as _i18.Future<_i10.Amount>); + ) as _i19.Future<_i10.Amount>); @override _i10.Amount roughFeeEstimate( int? inputCount, @@ -1835,36 +1859,36 @@ class MockFiroWallet extends _i1.Mock implements _i22.FiroWallet { ), ) as _i10.Amount); @override - _i18.Future<_i10.Amount> sweepAllEstimate(int? feeRate) => + _i19.Future<_i10.Amount> sweepAllEstimate(int? feeRate) => (super.noSuchMethod( Invocation.method( #sweepAllEstimate, [feeRate], ), - returnValue: _i18.Future<_i10.Amount>.value(_FakeAmount_7( + returnValue: _i19.Future<_i10.Amount>.value(_FakeAmount_7( this, Invocation.method( #sweepAllEstimate, [feeRate], ), )), - ) as _i18.Future<_i10.Amount>); + ) as _i19.Future<_i10.Amount>); @override - _i18.Future>> fastFetch( + _i19.Future>> fastFetch( List? allTxHashes) => (super.noSuchMethod( Invocation.method( #fastFetch, [allTxHashes], ), - returnValue: _i18.Future>>.value( + returnValue: _i19.Future>>.value( >[]), - ) as _i18.Future>>); + ) as _i19.Future>>); @override - _i18.Future> getJMintTransactions( + _i19.Future> getJMintTransactions( _i13.CachedElectrumX? cachedClient, List? transactions, - _i17.Coin? coin, + _i18.Coin? coin, ) => (super.noSuchMethod( Invocation.method( @@ -1875,17 +1899,17 @@ class MockFiroWallet extends _i1.Mock implements _i22.FiroWallet { coin, ], ), - returnValue: _i18.Future>.value( - <_i21.Address, _i21.Transaction>{}), - ) as _i18.Future>); + returnValue: _i19.Future>.value( + <_i22.Address, _i22.Transaction>{}), + ) as _i19.Future>); @override - _i18.Future generateNewAddress() => (super.noSuchMethod( + _i19.Future generateNewAddress() => (super.noSuchMethod( Invocation.method( #generateNewAddress, [], ), - returnValue: _i18.Future.value(false), - ) as _i18.Future); + returnValue: _i19.Future.value(false), + ) as _i19.Future); @override _i10.Amount availablePrivateBalance() => (super.noSuchMethod( Invocation.method( @@ -1917,7 +1941,7 @@ class MockFiroWallet extends _i1.Mock implements _i22.FiroWallet { @override void initCache( String? walletId, - _i17.Coin? coin, + _i18.Coin? coin, ) => super.noSuchMethod( Invocation.method( @@ -1930,14 +1954,14 @@ class MockFiroWallet extends _i1.Mock implements _i22.FiroWallet { returnValueForMissingStub: null, ); @override - _i18.Future updateCachedId(String? id) => (super.noSuchMethod( + _i19.Future updateCachedId(String? id) => (super.noSuchMethod( Invocation.method( #updateCachedId, [id], ), - returnValue: _i18.Future.value(), - returnValueForMissingStub: _i18.Future.value(), - ) as _i18.Future); + returnValue: _i19.Future.value(), + returnValueForMissingStub: _i19.Future.value(), + ) as _i19.Future); @override int getCachedChainHeight() => (super.noSuchMethod( Invocation.method( @@ -1947,14 +1971,14 @@ class MockFiroWallet extends _i1.Mock implements _i22.FiroWallet { returnValue: 0, ) as int); @override - _i18.Future updateCachedChainHeight(int? height) => (super.noSuchMethod( + _i19.Future updateCachedChainHeight(int? height) => (super.noSuchMethod( Invocation.method( #updateCachedChainHeight, [height], ), - returnValue: _i18.Future.value(), - returnValueForMissingStub: _i18.Future.value(), - ) as _i18.Future); + returnValue: _i19.Future.value(), + returnValueForMissingStub: _i19.Future.value(), + ) as _i19.Future); @override bool getCachedIsFavorite() => (super.noSuchMethod( Invocation.method( @@ -1964,15 +1988,15 @@ class MockFiroWallet extends _i1.Mock implements _i22.FiroWallet { returnValue: false, ) as bool); @override - _i18.Future updateCachedIsFavorite(bool? isFavorite) => + _i19.Future updateCachedIsFavorite(bool? isFavorite) => (super.noSuchMethod( Invocation.method( #updateCachedIsFavorite, [isFavorite], ), - returnValue: _i18.Future.value(), - returnValueForMissingStub: _i18.Future.value(), - ) as _i18.Future); + returnValue: _i19.Future.value(), + returnValueForMissingStub: _i19.Future.value(), + ) as _i19.Future); @override _i9.Balance getCachedBalance() => (super.noSuchMethod( Invocation.method( @@ -1988,15 +2012,15 @@ class MockFiroWallet extends _i1.Mock implements _i22.FiroWallet { ), ) as _i9.Balance); @override - _i18.Future updateCachedBalance(_i9.Balance? balance) => + _i19.Future updateCachedBalance(_i9.Balance? balance) => (super.noSuchMethod( Invocation.method( #updateCachedBalance, [balance], ), - returnValue: _i18.Future.value(), - returnValueForMissingStub: _i18.Future.value(), - ) as _i18.Future); + returnValue: _i19.Future.value(), + returnValueForMissingStub: _i19.Future.value(), + ) as _i19.Future); @override _i9.Balance getCachedBalanceSecondary() => (super.noSuchMethod( Invocation.method( @@ -2012,15 +2036,15 @@ class MockFiroWallet extends _i1.Mock implements _i22.FiroWallet { ), ) as _i9.Balance); @override - _i18.Future updateCachedBalanceSecondary(_i9.Balance? balance) => + _i19.Future updateCachedBalanceSecondary(_i9.Balance? balance) => (super.noSuchMethod( Invocation.method( #updateCachedBalanceSecondary, [balance], ), - returnValue: _i18.Future.value(), - returnValueForMissingStub: _i18.Future.value(), - ) as _i18.Future); + returnValue: _i19.Future.value(), + returnValueForMissingStub: _i19.Future.value(), + ) as _i19.Future); @override List getWalletTokenContractAddresses() => (super.noSuchMethod( Invocation.method( @@ -2030,16 +2054,16 @@ class MockFiroWallet extends _i1.Mock implements _i22.FiroWallet { returnValue: [], ) as List); @override - _i18.Future updateWalletTokenContractAddresses( + _i19.Future updateWalletTokenContractAddresses( List? contractAddresses) => (super.noSuchMethod( Invocation.method( #updateWalletTokenContractAddresses, [contractAddresses], ), - returnValue: _i18.Future.value(), - returnValueForMissingStub: _i18.Future.value(), - ) as _i18.Future); + returnValue: _i19.Future.value(), + returnValueForMissingStub: _i19.Future.value(), + ) as _i19.Future); @override void initWalletDB({_i14.MainDB? mockableOverride}) => super.noSuchMethod( Invocation.method( @@ -2058,25 +2082,25 @@ class MockFiroWallet extends _i1.Mock implements _i22.FiroWallet { returnValueForMissingStub: null, ); @override - _i18.Future firoUpdateJIndex(List? jIndex) => + _i19.Future firoUpdateJIndex(List? jIndex) => (super.noSuchMethod( Invocation.method( #firoUpdateJIndex, [jIndex], ), - returnValue: _i18.Future.value(), - returnValueForMissingStub: _i18.Future.value(), - ) as _i18.Future); + returnValue: _i19.Future.value(), + returnValueForMissingStub: _i19.Future.value(), + ) as _i19.Future); @override - _i18.Future firoUpdateLelantusCoins(List? lelantusCoins) => + _i19.Future firoUpdateLelantusCoins(List? lelantusCoins) => (super.noSuchMethod( Invocation.method( #firoUpdateLelantusCoins, [lelantusCoins], ), - returnValue: _i18.Future.value(), - returnValueForMissingStub: _i18.Future.value(), - ) as _i18.Future); + returnValue: _i19.Future.value(), + returnValueForMissingStub: _i19.Future.value(), + ) as _i19.Future); @override int firoGetMintIndex() => (super.noSuchMethod( Invocation.method( @@ -2086,20 +2110,20 @@ class MockFiroWallet extends _i1.Mock implements _i22.FiroWallet { returnValue: 0, ) as int); @override - _i18.Future firoUpdateMintIndex(int? mintIndex) => (super.noSuchMethod( + _i19.Future firoUpdateMintIndex(int? mintIndex) => (super.noSuchMethod( Invocation.method( #firoUpdateMintIndex, [mintIndex], ), - returnValue: _i18.Future.value(), - returnValueForMissingStub: _i18.Future.value(), - ) as _i18.Future); + returnValue: _i19.Future.value(), + returnValueForMissingStub: _i19.Future.value(), + ) as _i19.Future); } /// A class which mocks [LocaleService]. /// /// See the documentation for Mockito's code generation for more information. -class MockLocaleService extends _i1.Mock implements _i24.LocaleService { +class MockLocaleService extends _i1.Mock implements _i25.LocaleService { MockLocaleService() { _i1.throwOnMissingStub(this); } @@ -2115,17 +2139,17 @@ class MockLocaleService extends _i1.Mock implements _i24.LocaleService { returnValue: false, ) as bool); @override - _i18.Future loadLocale({bool? notify = true}) => (super.noSuchMethod( + _i19.Future loadLocale({bool? notify = true}) => (super.noSuchMethod( Invocation.method( #loadLocale, [], {#notify: notify}, ), - returnValue: _i18.Future.value(), - returnValueForMissingStub: _i18.Future.value(), - ) as _i18.Future); + returnValue: _i19.Future.value(), + returnValueForMissingStub: _i19.Future.value(), + ) as _i19.Future); @override - void addListener(_i20.VoidCallback? listener) => super.noSuchMethod( + void addListener(_i21.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #addListener, [listener], @@ -2133,7 +2157,7 @@ class MockLocaleService extends _i1.Mock implements _i24.LocaleService { returnValueForMissingStub: null, ); @override - void removeListener(_i20.VoidCallback? listener) => super.noSuchMethod( + void removeListener(_i21.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #removeListener, [listener], @@ -2161,7 +2185,7 @@ class MockLocaleService extends _i1.Mock implements _i24.LocaleService { /// A class which mocks [Prefs]. /// /// See the documentation for Mockito's code generation for more information. -class MockPrefs extends _i1.Mock implements _i19.Prefs { +class MockPrefs extends _i1.Mock implements _i20.Prefs { MockPrefs() { _i1.throwOnMissingStub(this); } @@ -2217,12 +2241,12 @@ class MockPrefs extends _i1.Mock implements _i19.Prefs { returnValueForMissingStub: null, ); @override - _i25.SyncingType get syncType => (super.noSuchMethod( + _i26.SyncingType get syncType => (super.noSuchMethod( Invocation.getter(#syncType), - returnValue: _i25.SyncingType.currentWalletOnly, - ) as _i25.SyncingType); + returnValue: _i26.SyncingType.currentWalletOnly, + ) as _i26.SyncingType); @override - set syncType(_i25.SyncingType? syncType) => super.noSuchMethod( + set syncType(_i26.SyncingType? syncType) => super.noSuchMethod( Invocation.setter( #syncType, syncType, @@ -2368,12 +2392,12 @@ class MockPrefs extends _i1.Mock implements _i19.Prefs { returnValueForMissingStub: null, ); @override - _i26.BackupFrequencyType get backupFrequencyType => (super.noSuchMethod( + _i27.BackupFrequencyType get backupFrequencyType => (super.noSuchMethod( Invocation.getter(#backupFrequencyType), - returnValue: _i26.BackupFrequencyType.everyTenMinutes, - ) as _i26.BackupFrequencyType); + returnValue: _i27.BackupFrequencyType.everyTenMinutes, + ) as _i27.BackupFrequencyType); @override - set backupFrequencyType(_i26.BackupFrequencyType? backupFrequencyType) => + set backupFrequencyType(_i27.BackupFrequencyType? backupFrequencyType) => super.noSuchMethod( Invocation.setter( #backupFrequencyType, @@ -2511,61 +2535,61 @@ class MockPrefs extends _i1.Mock implements _i19.Prefs { returnValue: false, ) as bool); @override - _i18.Future init() => (super.noSuchMethod( + _i19.Future init() => (super.noSuchMethod( Invocation.method( #init, [], ), - returnValue: _i18.Future.value(), - returnValueForMissingStub: _i18.Future.value(), - ) as _i18.Future); + returnValue: _i19.Future.value(), + returnValueForMissingStub: _i19.Future.value(), + ) as _i19.Future); @override - _i18.Future incrementCurrentNotificationIndex() => (super.noSuchMethod( + _i19.Future incrementCurrentNotificationIndex() => (super.noSuchMethod( Invocation.method( #incrementCurrentNotificationIndex, [], ), - returnValue: _i18.Future.value(), - returnValueForMissingStub: _i18.Future.value(), - ) as _i18.Future); + returnValue: _i19.Future.value(), + returnValueForMissingStub: _i19.Future.value(), + ) as _i19.Future); @override - _i18.Future isExternalCallsSet() => (super.noSuchMethod( + _i19.Future isExternalCallsSet() => (super.noSuchMethod( Invocation.method( #isExternalCallsSet, [], ), - returnValue: _i18.Future.value(false), - ) as _i18.Future); + returnValue: _i19.Future.value(false), + ) as _i19.Future); @override - _i18.Future saveUserID(String? userId) => (super.noSuchMethod( + _i19.Future saveUserID(String? userId) => (super.noSuchMethod( Invocation.method( #saveUserID, [userId], ), - returnValue: _i18.Future.value(), - returnValueForMissingStub: _i18.Future.value(), - ) as _i18.Future); + returnValue: _i19.Future.value(), + returnValueForMissingStub: _i19.Future.value(), + ) as _i19.Future); @override - _i18.Future saveSignupEpoch(int? signupEpoch) => (super.noSuchMethod( + _i19.Future saveSignupEpoch(int? signupEpoch) => (super.noSuchMethod( Invocation.method( #saveSignupEpoch, [signupEpoch], ), - returnValue: _i18.Future.value(), - returnValueForMissingStub: _i18.Future.value(), - ) as _i18.Future); + returnValue: _i19.Future.value(), + returnValueForMissingStub: _i19.Future.value(), + ) as _i19.Future); @override - _i27.AmountUnit amountUnit(_i17.Coin? coin) => (super.noSuchMethod( + _i28.AmountUnit amountUnit(_i18.Coin? coin) => (super.noSuchMethod( Invocation.method( #amountUnit, [coin], ), - returnValue: _i27.AmountUnit.normal, - ) as _i27.AmountUnit); + returnValue: _i28.AmountUnit.normal, + ) as _i28.AmountUnit); @override void updateAmountUnit({ - required _i17.Coin? coin, - required _i27.AmountUnit? amountUnit, + required _i18.Coin? coin, + required _i28.AmountUnit? amountUnit, }) => super.noSuchMethod( Invocation.method( @@ -2579,7 +2603,7 @@ class MockPrefs extends _i1.Mock implements _i19.Prefs { returnValueForMissingStub: null, ); @override - int maxDecimals(_i17.Coin? coin) => (super.noSuchMethod( + int maxDecimals(_i18.Coin? coin) => (super.noSuchMethod( Invocation.method( #maxDecimals, [coin], @@ -2588,7 +2612,7 @@ class MockPrefs extends _i1.Mock implements _i19.Prefs { ) as int); @override void updateMaxDecimals({ - required _i17.Coin? coin, + required _i18.Coin? coin, required int? maxDecimals, }) => super.noSuchMethod( @@ -2603,7 +2627,7 @@ class MockPrefs extends _i1.Mock implements _i19.Prefs { returnValueForMissingStub: null, ); @override - void addListener(_i20.VoidCallback? listener) => super.noSuchMethod( + void addListener(_i21.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #addListener, [listener], @@ -2611,7 +2635,7 @@ class MockPrefs extends _i1.Mock implements _i19.Prefs { returnValueForMissingStub: null, ); @override - void removeListener(_i20.VoidCallback? listener) => super.noSuchMethod( + void removeListener(_i21.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #removeListener, [listener], @@ -2639,7 +2663,7 @@ class MockPrefs extends _i1.Mock implements _i19.Prefs { /// A class which mocks [PriceService]. /// /// See the documentation for Mockito's code generation for more information. -class MockPriceService extends _i1.Mock implements _i28.PriceService { +class MockPriceService extends _i1.Mock implements _i29.PriceService { MockPriceService() { _i1.throwOnMissingStub(this); } @@ -2676,44 +2700,44 @@ class MockPriceService extends _i1.Mock implements _i28.PriceService { returnValue: false, ) as bool); @override - _i15.Tuple2<_i29.Decimal, double> getPrice(_i17.Coin? coin) => + _i15.Tuple2<_i30.Decimal, double> getPrice(_i18.Coin? coin) => (super.noSuchMethod( Invocation.method( #getPrice, [coin], ), - returnValue: _FakeTuple2_13<_i29.Decimal, double>( + returnValue: _FakeTuple2_13<_i30.Decimal, double>( this, Invocation.method( #getPrice, [coin], ), ), - ) as _i15.Tuple2<_i29.Decimal, double>); + ) as _i15.Tuple2<_i30.Decimal, double>); @override - _i15.Tuple2<_i29.Decimal, double> getTokenPrice(String? contractAddress) => + _i15.Tuple2<_i30.Decimal, double> getTokenPrice(String? contractAddress) => (super.noSuchMethod( Invocation.method( #getTokenPrice, [contractAddress], ), - returnValue: _FakeTuple2_13<_i29.Decimal, double>( + returnValue: _FakeTuple2_13<_i30.Decimal, double>( this, Invocation.method( #getTokenPrice, [contractAddress], ), ), - ) as _i15.Tuple2<_i29.Decimal, double>); + ) as _i15.Tuple2<_i30.Decimal, double>); @override - _i18.Future updatePrice() => (super.noSuchMethod( + _i19.Future updatePrice() => (super.noSuchMethod( Invocation.method( #updatePrice, [], ), - returnValue: _i18.Future.value(), - returnValueForMissingStub: _i18.Future.value(), - ) as _i18.Future); + returnValue: _i19.Future.value(), + returnValueForMissingStub: _i19.Future.value(), + ) as _i19.Future); @override void cancel() => super.noSuchMethod( Invocation.method( @@ -2739,7 +2763,7 @@ class MockPriceService extends _i1.Mock implements _i28.PriceService { returnValueForMissingStub: null, ); @override - void addListener(_i20.VoidCallback? listener) => super.noSuchMethod( + void addListener(_i21.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #addListener, [listener], @@ -2747,7 +2771,7 @@ class MockPriceService extends _i1.Mock implements _i28.PriceService { returnValueForMissingStub: null, ); @override - void removeListener(_i20.VoidCallback? listener) => super.noSuchMethod( + void removeListener(_i21.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #removeListener, [listener], @@ -2767,7 +2791,7 @@ class MockPriceService extends _i1.Mock implements _i28.PriceService { /// A class which mocks [NotesService]. /// /// See the documentation for Mockito's code generation for more information. -class MockNotesService extends _i1.Mock implements _i30.NotesService { +class MockNotesService extends _i1.Mock implements _i31.NotesService { MockNotesService() { _i1.throwOnMissingStub(this); } @@ -2783,35 +2807,35 @@ class MockNotesService extends _i1.Mock implements _i30.NotesService { returnValue: {}, ) as Map); @override - _i18.Future> get notes => (super.noSuchMethod( + _i19.Future> get notes => (super.noSuchMethod( Invocation.getter(#notes), - returnValue: _i18.Future>.value({}), - ) as _i18.Future>); + returnValue: _i19.Future>.value({}), + ) as _i19.Future>); @override bool get hasListeners => (super.noSuchMethod( Invocation.getter(#hasListeners), returnValue: false, ) as bool); @override - _i18.Future> search(String? text) => (super.noSuchMethod( + _i19.Future> search(String? text) => (super.noSuchMethod( Invocation.method( #search, [text], ), - returnValue: _i18.Future>.value({}), - ) as _i18.Future>); + returnValue: _i19.Future>.value({}), + ) as _i19.Future>); @override - _i18.Future getNoteFor({required String? txid}) => + _i19.Future getNoteFor({required String? txid}) => (super.noSuchMethod( Invocation.method( #getNoteFor, [], {#txid: txid}, ), - returnValue: _i18.Future.value(''), - ) as _i18.Future); + returnValue: _i19.Future.value(''), + ) as _i19.Future); @override - _i18.Future editOrAddNote({ + _i19.Future editOrAddNote({ required String? txid, required String? note, }) => @@ -2824,21 +2848,21 @@ class MockNotesService extends _i1.Mock implements _i30.NotesService { #note: note, }, ), - returnValue: _i18.Future.value(), - returnValueForMissingStub: _i18.Future.value(), - ) as _i18.Future); + returnValue: _i19.Future.value(), + returnValueForMissingStub: _i19.Future.value(), + ) as _i19.Future); @override - _i18.Future deleteNote({required String? txid}) => (super.noSuchMethod( + _i19.Future deleteNote({required String? txid}) => (super.noSuchMethod( Invocation.method( #deleteNote, [], {#txid: txid}, ), - returnValue: _i18.Future.value(), - returnValueForMissingStub: _i18.Future.value(), - ) as _i18.Future); + returnValue: _i19.Future.value(), + returnValueForMissingStub: _i19.Future.value(), + ) as _i19.Future); @override - void addListener(_i20.VoidCallback? listener) => super.noSuchMethod( + void addListener(_i21.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #addListener, [listener], @@ -2846,7 +2870,7 @@ class MockNotesService extends _i1.Mock implements _i30.NotesService { returnValueForMissingStub: null, ); @override - void removeListener(_i20.VoidCallback? listener) => super.noSuchMethod( + void removeListener(_i21.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #removeListener, [listener], @@ -2874,7 +2898,7 @@ class MockNotesService extends _i1.Mock implements _i30.NotesService { /// A class which mocks [ThemeService]. /// /// See the documentation for Mockito's code generation for more information. -class MockThemeService extends _i1.Mock implements _i31.ThemeService { +class MockThemeService extends _i1.Mock implements _i32.ThemeService { MockThemeService() { _i1.throwOnMissingStub(this); } @@ -2888,10 +2912,10 @@ class MockThemeService extends _i1.Mock implements _i31.ThemeService { ), ) as _i14.MainDB); @override - List<_i32.StackTheme> get installedThemes => (super.noSuchMethod( + List<_i33.StackTheme> get installedThemes => (super.noSuchMethod( Invocation.getter(#installedThemes), - returnValue: <_i32.StackTheme>[], - ) as List<_i32.StackTheme>); + returnValue: <_i33.StackTheme>[], + ) as List<_i33.StackTheme>); @override void init(_i14.MainDB? db) => super.noSuchMethod( Invocation.method( @@ -2901,71 +2925,636 @@ class MockThemeService extends _i1.Mock implements _i31.ThemeService { returnValueForMissingStub: null, ); @override - _i18.Future install({required _i33.Uint8List? themeArchiveData}) => + _i19.Future install({required _i34.Uint8List? themeArchiveData}) => (super.noSuchMethod( Invocation.method( #install, [], {#themeArchiveData: themeArchiveData}, ), - returnValue: _i18.Future.value(), - returnValueForMissingStub: _i18.Future.value(), - ) as _i18.Future); + returnValue: _i19.Future.value(), + returnValueForMissingStub: _i19.Future.value(), + ) as _i19.Future); @override - _i18.Future remove({required String? themeId}) => (super.noSuchMethod( + _i19.Future remove({required String? themeId}) => (super.noSuchMethod( Invocation.method( #remove, [], {#themeId: themeId}, ), - returnValue: _i18.Future.value(), - returnValueForMissingStub: _i18.Future.value(), - ) as _i18.Future); + returnValue: _i19.Future.value(), + returnValueForMissingStub: _i19.Future.value(), + ) as _i19.Future); @override - _i18.Future checkDefaultThemesOnStartup() => (super.noSuchMethod( + _i19.Future checkDefaultThemesOnStartup() => (super.noSuchMethod( Invocation.method( #checkDefaultThemesOnStartup, [], ), - returnValue: _i18.Future.value(), - returnValueForMissingStub: _i18.Future.value(), - ) as _i18.Future); + returnValue: _i19.Future.value(), + returnValueForMissingStub: _i19.Future.value(), + ) as _i19.Future); @override - _i18.Future verifyInstalled({required String? themeId}) => + _i19.Future verifyInstalled({required String? themeId}) => (super.noSuchMethod( Invocation.method( #verifyInstalled, [], {#themeId: themeId}, ), - returnValue: _i18.Future.value(false), - ) as _i18.Future); + returnValue: _i19.Future.value(false), + ) as _i19.Future); @override - _i18.Future> fetchThemes() => + _i19.Future> fetchThemes() => (super.noSuchMethod( Invocation.method( #fetchThemes, [], ), - returnValue: _i18.Future>.value( - <_i31.StackThemeMetaData>[]), - ) as _i18.Future>); + returnValue: _i19.Future>.value( + <_i32.StackThemeMetaData>[]), + ) as _i19.Future>); @override - _i18.Future<_i33.Uint8List> fetchTheme( - {required _i31.StackThemeMetaData? themeMetaData}) => + _i19.Future<_i34.Uint8List> fetchTheme( + {required _i32.StackThemeMetaData? themeMetaData}) => (super.noSuchMethod( Invocation.method( #fetchTheme, [], {#themeMetaData: themeMetaData}, ), - returnValue: _i18.Future<_i33.Uint8List>.value(_i33.Uint8List(0)), - ) as _i18.Future<_i33.Uint8List>); + returnValue: _i19.Future<_i34.Uint8List>.value(_i34.Uint8List(0)), + ) as _i19.Future<_i34.Uint8List>); @override - _i32.StackTheme? getTheme({required String? themeId}) => + _i33.StackTheme? getTheme({required String? themeId}) => (super.noSuchMethod(Invocation.method( #getTheme, [], {#themeId: themeId}, - )) as _i32.StackTheme?); + )) as _i33.StackTheme?); +} + +/// A class which mocks [MainDB]. +/// +/// See the documentation for Mockito's code generation for more information. +class MockMainDB extends _i1.Mock implements _i14.MainDB { + MockMainDB() { + _i1.throwOnMissingStub(this); + } + + @override + _i16.Isar get isar => (super.noSuchMethod( + Invocation.getter(#isar), + returnValue: _FakeIsar_14( + this, + Invocation.getter(#isar), + ), + ) as _i16.Isar); + @override + _i19.Future initMainDB({_i16.Isar? mock}) => (super.noSuchMethod( + Invocation.method( + #initMainDB, + [], + {#mock: mock}, + ), + returnValue: _i19.Future.value(false), + ) as _i19.Future); + @override + List<_i35.ContactEntry> getContactEntries() => (super.noSuchMethod( + Invocation.method( + #getContactEntries, + [], + ), + returnValue: <_i35.ContactEntry>[], + ) as List<_i35.ContactEntry>); + @override + _i19.Future deleteContactEntry({required String? id}) => + (super.noSuchMethod( + Invocation.method( + #deleteContactEntry, + [], + {#id: id}, + ), + returnValue: _i19.Future.value(false), + ) as _i19.Future); + @override + _i19.Future isContactEntryExists({required String? id}) => + (super.noSuchMethod( + Invocation.method( + #isContactEntryExists, + [], + {#id: id}, + ), + returnValue: _i19.Future.value(false), + ) as _i19.Future); + @override + _i35.ContactEntry? getContactEntry({required String? id}) => + (super.noSuchMethod(Invocation.method( + #getContactEntry, + [], + {#id: id}, + )) as _i35.ContactEntry?); + @override + _i19.Future putContactEntry( + {required _i35.ContactEntry? contactEntry}) => + (super.noSuchMethod( + Invocation.method( + #putContactEntry, + [], + {#contactEntry: contactEntry}, + ), + returnValue: _i19.Future.value(false), + ) as _i19.Future); + @override + _i36.TransactionBlockExplorer? getTransactionBlockExplorer( + {required _i18.Coin? coin}) => + (super.noSuchMethod(Invocation.method( + #getTransactionBlockExplorer, + [], + {#coin: coin}, + )) as _i36.TransactionBlockExplorer?); + @override + _i19.Future putTransactionBlockExplorer( + _i36.TransactionBlockExplorer? explorer) => + (super.noSuchMethod( + Invocation.method( + #putTransactionBlockExplorer, + [explorer], + ), + returnValue: _i19.Future.value(0), + ) as _i19.Future); + @override + _i16.QueryBuilder<_i22.Address, _i22.Address, _i16.QAfterWhereClause> + getAddresses(String? walletId) => (super.noSuchMethod( + Invocation.method( + #getAddresses, + [walletId], + ), + returnValue: _FakeQueryBuilder_15<_i22.Address, _i22.Address, + _i16.QAfterWhereClause>( + this, + Invocation.method( + #getAddresses, + [walletId], + ), + ), + ) as _i16.QueryBuilder<_i22.Address, _i22.Address, + _i16.QAfterWhereClause>); + @override + _i19.Future putAddress(_i22.Address? address) => (super.noSuchMethod( + Invocation.method( + #putAddress, + [address], + ), + returnValue: _i19.Future.value(0), + ) as _i19.Future); + @override + _i19.Future> putAddresses(List<_i22.Address>? addresses) => + (super.noSuchMethod( + Invocation.method( + #putAddresses, + [addresses], + ), + returnValue: _i19.Future>.value([]), + ) as _i19.Future>); + @override + _i19.Future> updateOrPutAddresses(List<_i22.Address>? addresses) => + (super.noSuchMethod( + Invocation.method( + #updateOrPutAddresses, + [addresses], + ), + returnValue: _i19.Future>.value([]), + ) as _i19.Future>); + @override + _i19.Future<_i22.Address?> getAddress( + String? walletId, + String? address, + ) => + (super.noSuchMethod( + Invocation.method( + #getAddress, + [ + walletId, + address, + ], + ), + returnValue: _i19.Future<_i22.Address?>.value(), + ) as _i19.Future<_i22.Address?>); + @override + _i19.Future updateAddress( + _i22.Address? oldAddress, + _i22.Address? newAddress, + ) => + (super.noSuchMethod( + Invocation.method( + #updateAddress, + [ + oldAddress, + newAddress, + ], + ), + returnValue: _i19.Future.value(0), + ) as _i19.Future); + @override + _i16.QueryBuilder<_i22.Transaction, _i22.Transaction, _i16.QAfterWhereClause> + getTransactions(String? walletId) => (super.noSuchMethod( + Invocation.method( + #getTransactions, + [walletId], + ), + returnValue: _FakeQueryBuilder_15<_i22.Transaction, + _i22.Transaction, _i16.QAfterWhereClause>( + this, + Invocation.method( + #getTransactions, + [walletId], + ), + ), + ) as _i16.QueryBuilder<_i22.Transaction, _i22.Transaction, + _i16.QAfterWhereClause>); + @override + _i19.Future putTransaction(_i22.Transaction? transaction) => + (super.noSuchMethod( + Invocation.method( + #putTransaction, + [transaction], + ), + returnValue: _i19.Future.value(0), + ) as _i19.Future); + @override + _i19.Future> putTransactions( + List<_i22.Transaction>? transactions) => + (super.noSuchMethod( + Invocation.method( + #putTransactions, + [transactions], + ), + returnValue: _i19.Future>.value([]), + ) as _i19.Future>); + @override + _i19.Future<_i22.Transaction?> getTransaction( + String? walletId, + String? txid, + ) => + (super.noSuchMethod( + Invocation.method( + #getTransaction, + [ + walletId, + txid, + ], + ), + returnValue: _i19.Future<_i22.Transaction?>.value(), + ) as _i19.Future<_i22.Transaction?>); + @override + _i19.Stream<_i22.Transaction?> watchTransaction({ + required int? id, + bool? fireImmediately = false, + }) => + (super.noSuchMethod( + Invocation.method( + #watchTransaction, + [], + { + #id: id, + #fireImmediately: fireImmediately, + }, + ), + returnValue: _i19.Stream<_i22.Transaction?>.empty(), + ) as _i19.Stream<_i22.Transaction?>); + @override + _i16.QueryBuilder<_i22.UTXO, _i22.UTXO, _i16.QAfterWhereClause> getUTXOs( + String? walletId) => + (super.noSuchMethod( + Invocation.method( + #getUTXOs, + [walletId], + ), + returnValue: + _FakeQueryBuilder_15<_i22.UTXO, _i22.UTXO, _i16.QAfterWhereClause>( + this, + Invocation.method( + #getUTXOs, + [walletId], + ), + ), + ) as _i16.QueryBuilder<_i22.UTXO, _i22.UTXO, _i16.QAfterWhereClause>); + @override + _i19.Future putUTXO(_i22.UTXO? utxo) => (super.noSuchMethod( + Invocation.method( + #putUTXO, + [utxo], + ), + returnValue: _i19.Future.value(), + returnValueForMissingStub: _i19.Future.value(), + ) as _i19.Future); + @override + _i19.Future putUTXOs(List<_i22.UTXO>? utxos) => (super.noSuchMethod( + Invocation.method( + #putUTXOs, + [utxos], + ), + returnValue: _i19.Future.value(), + returnValueForMissingStub: _i19.Future.value(), + ) as _i19.Future); + @override + _i19.Future updateUTXOs( + String? walletId, + List<_i22.UTXO>? utxos, + ) => + (super.noSuchMethod( + Invocation.method( + #updateUTXOs, + [ + walletId, + utxos, + ], + ), + returnValue: _i19.Future.value(), + returnValueForMissingStub: _i19.Future.value(), + ) as _i19.Future); + @override + _i19.Stream<_i22.UTXO?> watchUTXO({ + required int? id, + bool? fireImmediately = false, + }) => + (super.noSuchMethod( + Invocation.method( + #watchUTXO, + [], + { + #id: id, + #fireImmediately: fireImmediately, + }, + ), + returnValue: _i19.Stream<_i22.UTXO?>.empty(), + ) as _i19.Stream<_i22.UTXO?>); + @override + _i16.QueryBuilder<_i22.TransactionNote, _i22.TransactionNote, + _i16.QAfterWhereClause> getTransactionNotes( + String? walletId) => + (super.noSuchMethod( + Invocation.method( + #getTransactionNotes, + [walletId], + ), + returnValue: _FakeQueryBuilder_15<_i22.TransactionNote, + _i22.TransactionNote, _i16.QAfterWhereClause>( + this, + Invocation.method( + #getTransactionNotes, + [walletId], + ), + ), + ) as _i16.QueryBuilder<_i22.TransactionNote, _i22.TransactionNote, + _i16.QAfterWhereClause>); + @override + _i19.Future putTransactionNote(_i22.TransactionNote? transactionNote) => + (super.noSuchMethod( + Invocation.method( + #putTransactionNote, + [transactionNote], + ), + returnValue: _i19.Future.value(), + returnValueForMissingStub: _i19.Future.value(), + ) as _i19.Future); + @override + _i19.Future putTransactionNotes( + List<_i22.TransactionNote>? transactionNotes) => + (super.noSuchMethod( + Invocation.method( + #putTransactionNotes, + [transactionNotes], + ), + returnValue: _i19.Future.value(), + returnValueForMissingStub: _i19.Future.value(), + ) as _i19.Future); + @override + _i19.Future<_i22.TransactionNote?> getTransactionNote( + String? walletId, + String? txid, + ) => + (super.noSuchMethod( + Invocation.method( + #getTransactionNote, + [ + walletId, + txid, + ], + ), + returnValue: _i19.Future<_i22.TransactionNote?>.value(), + ) as _i19.Future<_i22.TransactionNote?>); + @override + _i19.Stream<_i22.TransactionNote?> watchTransactionNote({ + required int? id, + bool? fireImmediately = false, + }) => + (super.noSuchMethod( + Invocation.method( + #watchTransactionNote, + [], + { + #id: id, + #fireImmediately: fireImmediately, + }, + ), + returnValue: _i19.Stream<_i22.TransactionNote?>.empty(), + ) as _i19.Stream<_i22.TransactionNote?>); + @override + _i16.QueryBuilder<_i22.AddressLabel, _i22.AddressLabel, + _i16.QAfterWhereClause> getAddressLabels( + String? walletId) => + (super.noSuchMethod( + Invocation.method( + #getAddressLabels, + [walletId], + ), + returnValue: _FakeQueryBuilder_15<_i22.AddressLabel, _i22.AddressLabel, + _i16.QAfterWhereClause>( + this, + Invocation.method( + #getAddressLabels, + [walletId], + ), + ), + ) as _i16.QueryBuilder<_i22.AddressLabel, _i22.AddressLabel, + _i16.QAfterWhereClause>); + @override + _i19.Future putAddressLabel(_i22.AddressLabel? addressLabel) => + (super.noSuchMethod( + Invocation.method( + #putAddressLabel, + [addressLabel], + ), + returnValue: _i19.Future.value(0), + ) as _i19.Future); + @override + int putAddressLabelSync(_i22.AddressLabel? addressLabel) => + (super.noSuchMethod( + Invocation.method( + #putAddressLabelSync, + [addressLabel], + ), + returnValue: 0, + ) as int); + @override + _i19.Future putAddressLabels(List<_i22.AddressLabel>? addressLabels) => + (super.noSuchMethod( + Invocation.method( + #putAddressLabels, + [addressLabels], + ), + returnValue: _i19.Future.value(), + returnValueForMissingStub: _i19.Future.value(), + ) as _i19.Future); + @override + _i19.Future<_i22.AddressLabel?> getAddressLabel( + String? walletId, + String? addressString, + ) => + (super.noSuchMethod( + Invocation.method( + #getAddressLabel, + [ + walletId, + addressString, + ], + ), + returnValue: _i19.Future<_i22.AddressLabel?>.value(), + ) as _i19.Future<_i22.AddressLabel?>); + @override + _i22.AddressLabel? getAddressLabelSync( + String? walletId, + String? addressString, + ) => + (super.noSuchMethod(Invocation.method( + #getAddressLabelSync, + [ + walletId, + addressString, + ], + )) as _i22.AddressLabel?); + @override + _i19.Stream<_i22.AddressLabel?> watchAddressLabel({ + required int? id, + bool? fireImmediately = false, + }) => + (super.noSuchMethod( + Invocation.method( + #watchAddressLabel, + [], + { + #id: id, + #fireImmediately: fireImmediately, + }, + ), + returnValue: _i19.Stream<_i22.AddressLabel?>.empty(), + ) as _i19.Stream<_i22.AddressLabel?>); + @override + _i19.Future updateAddressLabel(_i22.AddressLabel? addressLabel) => + (super.noSuchMethod( + Invocation.method( + #updateAddressLabel, + [addressLabel], + ), + returnValue: _i19.Future.value(0), + ) as _i19.Future); + @override + _i19.Future deleteWalletBlockchainData(String? walletId) => + (super.noSuchMethod( + Invocation.method( + #deleteWalletBlockchainData, + [walletId], + ), + returnValue: _i19.Future.value(), + returnValueForMissingStub: _i19.Future.value(), + ) as _i19.Future); + @override + _i19.Future deleteAddressLabels(String? walletId) => + (super.noSuchMethod( + Invocation.method( + #deleteAddressLabels, + [walletId], + ), + returnValue: _i19.Future.value(), + returnValueForMissingStub: _i19.Future.value(), + ) as _i19.Future); + @override + _i19.Future deleteTransactionNotes(String? walletId) => + (super.noSuchMethod( + Invocation.method( + #deleteTransactionNotes, + [walletId], + ), + returnValue: _i19.Future.value(), + returnValueForMissingStub: _i19.Future.value(), + ) as _i19.Future); + @override + _i19.Future addNewTransactionData( + List<_i15.Tuple2<_i22.Transaction, _i22.Address?>>? transactionsData, + String? walletId, + ) => + (super.noSuchMethod( + Invocation.method( + #addNewTransactionData, + [ + transactionsData, + walletId, + ], + ), + returnValue: _i19.Future.value(), + returnValueForMissingStub: _i19.Future.value(), + ) as _i19.Future); + @override + _i16.QueryBuilder<_i22.EthContract, _i22.EthContract, _i16.QWhere> + getEthContracts() => (super.noSuchMethod( + Invocation.method( + #getEthContracts, + [], + ), + returnValue: _FakeQueryBuilder_15<_i22.EthContract, + _i22.EthContract, _i16.QWhere>( + this, + Invocation.method( + #getEthContracts, + [], + ), + ), + ) as _i16 + .QueryBuilder<_i22.EthContract, _i22.EthContract, _i16.QWhere>); + @override + _i19.Future<_i22.EthContract?> getEthContract(String? contractAddress) => + (super.noSuchMethod( + Invocation.method( + #getEthContract, + [contractAddress], + ), + returnValue: _i19.Future<_i22.EthContract?>.value(), + ) as _i19.Future<_i22.EthContract?>); + @override + _i22.EthContract? getEthContractSync(String? contractAddress) => + (super.noSuchMethod(Invocation.method( + #getEthContractSync, + [contractAddress], + )) as _i22.EthContract?); + @override + _i19.Future putEthContract(_i22.EthContract? contract) => + (super.noSuchMethod( + Invocation.method( + #putEthContract, + [contract], + ), + returnValue: _i19.Future.value(0), + ) as _i19.Future); + @override + _i19.Future putEthContracts(List<_i22.EthContract>? contracts) => + (super.noSuchMethod( + Invocation.method( + #putEthContracts, + [contracts], + ), + returnValue: _i19.Future.value(), + returnValueForMissingStub: _i19.Future.value(), + ) as _i19.Future); } diff --git a/test/widget_tests/wallet_card_test.mocks.dart b/test/widget_tests/wallet_card_test.mocks.dart index 45728d6cb..10f3e12bc 100644 --- a/test/widget_tests/wallet_card_test.mocks.dart +++ b/test/widget_tests/wallet_card_test.mocks.dart @@ -521,7 +521,7 @@ class MockBitcoinWallet extends _i1.Mock implements _i24.BitcoinWallet { @override _i20.Coin get coin => (super.noSuchMethod( Invocation.getter(#coin), - returnValue: _i20.Coin.bitcoin, + returnValue: _i20.Coin.banano, ) as _i20.Coin); @override _i21.Future> get utxos => (super.noSuchMethod( diff --git a/test/widget_tests/wallet_info_row/sub_widgets/wallet_info_row_balance_future_test.mocks.dart b/test/widget_tests/wallet_info_row/sub_widgets/wallet_info_row_balance_future_test.mocks.dart index 26b795c82..e45b66f9e 100644 --- a/test/widget_tests/wallet_info_row/sub_widgets/wallet_info_row_balance_future_test.mocks.dart +++ b/test/widget_tests/wallet_info_row/sub_widgets/wallet_info_row_balance_future_test.mocks.dart @@ -776,7 +776,7 @@ class MockBitcoinWallet extends _i1.Mock implements _i26.BitcoinWallet { @override _i22.Coin get coin => (super.noSuchMethod( Invocation.getter(#coin), - returnValue: _i22.Coin.bitcoin, + returnValue: _i22.Coin.banano, ) as _i22.Coin); @override _i23.Future> get utxos => (super.noSuchMethod( @@ -2186,7 +2186,7 @@ class MockManager extends _i1.Mock implements _i6.Manager { @override _i22.Coin get coin => (super.noSuchMethod( Invocation.getter(#coin), - returnValue: _i22.Coin.bitcoin, + returnValue: _i22.Coin.banano, ) as _i22.Coin); @override bool get isRefreshing => (super.noSuchMethod( @@ -2554,7 +2554,7 @@ class MockCoinServiceAPI extends _i1.Mock implements _i20.CoinServiceAPI { @override _i22.Coin get coin => (super.noSuchMethod( Invocation.getter(#coin), - returnValue: _i22.Coin.bitcoin, + returnValue: _i22.Coin.banano, ) as _i22.Coin); @override bool get isRefreshing => (super.noSuchMethod( diff --git a/test/widget_tests/wallet_info_row/wallet_info_row_test.mocks.dart b/test/widget_tests/wallet_info_row/wallet_info_row_test.mocks.dart index 175b202a7..64aca3224 100644 --- a/test/widget_tests/wallet_info_row/wallet_info_row_test.mocks.dart +++ b/test/widget_tests/wallet_info_row/wallet_info_row_test.mocks.dart @@ -878,7 +878,7 @@ class MockBitcoinWallet extends _i1.Mock implements _i29.BitcoinWallet { @override _i22.Coin get coin => (super.noSuchMethod( Invocation.getter(#coin), - returnValue: _i22.Coin.bitcoin, + returnValue: _i22.Coin.banano, ) as _i22.Coin); @override _i23.Future> get utxos => (super.noSuchMethod( @@ -2289,7 +2289,7 @@ class MockManager extends _i1.Mock implements _i6.Manager { @override _i22.Coin get coin => (super.noSuchMethod( Invocation.getter(#coin), - returnValue: _i22.Coin.bitcoin, + returnValue: _i22.Coin.banano, ) as _i22.Coin); @override bool get isRefreshing => (super.noSuchMethod( @@ -2657,7 +2657,7 @@ class MockCoinServiceAPI extends _i1.Mock implements _i20.CoinServiceAPI { @override _i22.Coin get coin => (super.noSuchMethod( Invocation.getter(#coin), - returnValue: _i22.Coin.bitcoin, + returnValue: _i22.Coin.banano, ) as _i22.Coin); @override bool get isRefreshing => (super.noSuchMethod(