diff --git a/.gitignore b/.gitignore index ed66fa960..e58a9412f 100644 --- a/.gitignore +++ b/.gitignore @@ -55,4 +55,10 @@ libcw_monero.dll libcw_wownero.dll libepic_cash_wallet.dll libmobileliblelantus.dll +libtor_ffi.dll /libisar.so +libtor_ffi.so + +tor_logs.txt + +torrc diff --git a/.gitmodules b/.gitmodules index 66ee203f4..3aa333e4a 100644 --- a/.gitmodules +++ b/.gitmodules @@ -7,6 +7,9 @@ [submodule "crypto_plugins/flutter_liblelantus"] path = crypto_plugins/flutter_liblelantus url = https://github.com/cypherstack/flutter_liblelantus.git +[submodule "crypto_plugins/tor"] + path = crypto_plugins/tor + url = https://github.com/cypherstack/tor.git [submodule "fusiondart"] path = fusiondart - url = https://github.com/cypherstack/fusiondart + url = https://github.com/cypherstack/fusiondart.git diff --git a/assets/default_themes/dark.zip b/assets/default_themes/dark.zip index fe11a5463..eb20d7e6e 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 1453d6ba0..0048f661c 100644 Binary files a/assets/default_themes/light.zip and b/assets/default_themes/light.zip differ diff --git a/assets/svg/connected-button.svg b/assets/svg/connected-button.svg new file mode 100644 index 000000000..96a9970c0 --- /dev/null +++ b/assets/svg/connected-button.svg @@ -0,0 +1,4 @@ + + + + diff --git a/assets/svg/connecting-button.svg b/assets/svg/connecting-button.svg new file mode 100644 index 000000000..1bc6e953b --- /dev/null +++ b/assets/svg/connecting-button.svg @@ -0,0 +1,4 @@ + + + + diff --git a/assets/svg/disconnected-button.svg b/assets/svg/disconnected-button.svg new file mode 100644 index 000000000..03a8067d7 --- /dev/null +++ b/assets/svg/disconnected-button.svg @@ -0,0 +1,4 @@ + + + + diff --git a/assets/svg/tor-circle.svg b/assets/svg/tor-circle.svg new file mode 100644 index 000000000..8268a00f6 --- /dev/null +++ b/assets/svg/tor-circle.svg @@ -0,0 +1,5 @@ + + + + + diff --git a/assets/svg/tor-synced.svg b/assets/svg/tor-synced.svg new file mode 100644 index 000000000..20cff1f37 --- /dev/null +++ b/assets/svg/tor-synced.svg @@ -0,0 +1,4 @@ + + + + diff --git a/assets/svg/tor-syncing.svg b/assets/svg/tor-syncing.svg new file mode 100644 index 000000000..b51803c70 --- /dev/null +++ b/assets/svg/tor-syncing.svg @@ -0,0 +1,4 @@ + + + + diff --git a/assets/svg/tor.svg b/assets/svg/tor.svg new file mode 100644 index 000000000..a893c0907 --- /dev/null +++ b/assets/svg/tor.svg @@ -0,0 +1,4 @@ + + + + diff --git a/crypto_plugins/tor b/crypto_plugins/tor new file mode 160000 index 000000000..a819223b2 --- /dev/null +++ b/crypto_plugins/tor @@ -0,0 +1 @@ +Subproject commit a819223b23e9fa1d76bde82ed9109651e96f2ad3 diff --git a/docs/building.md b/docs/building.md index b56a87899..e7128df2e 100644 --- a/docs/building.md +++ b/docs/building.md @@ -123,7 +123,7 @@ flutter run android Note on Emulators: Only x86_64 emulators are supported, x86 emulators will not work #### Linux -Plug in your android device or use the emulator available via Android Studio and then run the following commands: +Run the following commands or launch via Android Studio: ``` flutter pub get flutter run linux diff --git a/lib/electrumx_rpc/cached_electrumx.dart b/lib/electrumx_rpc/cached_electrumx.dart index cb5237bab..8366e259f 100644 --- a/lib/electrumx_rpc/cached_electrumx.dart +++ b/lib/electrumx_rpc/cached_electrumx.dart @@ -9,7 +9,6 @@ */ import 'dart:convert'; -import 'dart:math'; import 'package:stackwallet/db/hive/db.dart'; import 'package:stackwallet/electrumx_rpc/electrumx.dart'; @@ -158,6 +157,7 @@ class CachedElectrumX { Future> getUsedCoinSerials({ required Coin coin, + int startNumber = 0, }) async { try { final box = await DB.instance.getUsedSerialsCacheBox(coin: coin); @@ -168,7 +168,7 @@ class CachedElectrumX { _list == null ? {} : List.from(_list).toSet(); final startNumber = - max(0, cachedSerials.length - 100); // 100 being some arbitrary buffer + cachedSerials.length - 10; // 10 being some arbitrary buffer final serials = await electrumXClient.getUsedCoinSerials( startNumber: startNumber, diff --git a/lib/electrumx_rpc/electrumx.dart b/lib/electrumx_rpc/electrumx.dart index c9417116d..292679342 100644 --- a/lib/electrumx_rpc/electrumx.dart +++ b/lib/electrumx_rpc/electrumx.dart @@ -8,13 +8,20 @@ * */ +import 'dart:async'; import 'dart:convert'; import 'dart:io'; import 'package:connectivity_plus/connectivity_plus.dart'; import 'package:decimal/decimal.dart'; +import 'package:event_bus/event_bus.dart'; +import 'package:mutex/mutex.dart'; import 'package:stackwallet/electrumx_rpc/rpc.dart'; import 'package:stackwallet/exceptions/electrumx/no_such_transaction.dart'; +import 'package:stackwallet/services/event_bus/events/global/tor_connection_status_changed_event.dart'; +import 'package:stackwallet/services/event_bus/events/global/tor_status_changed_event.dart'; +import 'package:stackwallet/services/event_bus/global_event_bus.dart'; +import 'package:stackwallet/services/tor_service.dart'; import 'package:stackwallet/utilities/logger.dart'; import 'package:stackwallet/utilities/prefs.dart'; import 'package:uuid/uuid.dart'; @@ -65,12 +72,27 @@ class ElectrumX { JsonRPC? _rpcClient; late Prefs _prefs; + late TorService _torService; List? failovers; int currentFailoverIndex = -1; final Duration connectionTimeoutForSpecialCaseJsonRPCClients; + // add finalizer to cancel stream subscription when all references to an + // instance of ElectrumX becomes inaccessible + static final Finalizer _finalizer = Finalizer( + (p0) { + p0._torPreferenceListener?.cancel(); + p0._torStatusListener?.cancel(); + }, + ); + StreamSubscription? _torPreferenceListener; + StreamSubscription? _torStatusListener; + + final Mutex _torConnectingLock = Mutex(); + bool _requireMutex = false; + ElectrumX({ required String host, required int port, @@ -80,26 +102,79 @@ class ElectrumX { JsonRPC? client, this.connectionTimeoutForSpecialCaseJsonRPCClients = const Duration(seconds: 60), + TorService? torService, + EventBus? globalEventBusForTesting, }) { _prefs = prefs; + _torService = torService ?? TorService.sharedInstance; _host = host; _port = port; _useSSL = useSSL; _rpcClient = client; + + final bus = globalEventBusForTesting ?? GlobalEventBus.instance; + _torStatusListener = bus.on().listen( + (event) async { + switch (event.newStatus) { + case TorConnectionStatus.connecting: + await _torConnectingLock.acquire(); + _requireMutex = true; + break; + + case TorConnectionStatus.connected: + case TorConnectionStatus.disconnected: + if (_torConnectingLock.isLocked) { + _torConnectingLock.release(); + } + _requireMutex = false; + break; + } + }, + ); + _torPreferenceListener = bus.on().listen( + (event) async { + // not sure if we need to do anything specific here + // switch (event.status) { + // case TorStatus.enabled: + // case TorStatus.disabled: + // } + + // might be ok to just reset/kill the current _jsonRpcClient + + // since disconnecting is async and we want to ensure instant change over + // we will keep temp reference to current rpc client to call disconnect + // on before awaiting the disconnection future + + final temp = _rpcClient; + + // setting to null should force the creation of a new json rpc client + // on the next request sent through this electrumx instance + _rpcClient = null; + + await temp?.disconnect( + reason: "Tor status changed to \"${event.status}\"", + ); + }, + ); } factory ElectrumX.from({ required ElectrumXNode node, required Prefs prefs, required List failovers, - }) => - ElectrumX( - host: node.address, - port: node.port, - useSSL: node.useSSL, - prefs: prefs, - failovers: failovers, - ); + TorService? torService, + EventBus? globalEventBusForTesting, + }) { + return ElectrumX( + host: node.address, + port: node.port, + useSSL: node.useSSL, + prefs: prefs, + torService: torService, + failovers: failovers, + globalEventBusForTesting: globalEventBusForTesting, + ); + } Future _allow() async { if (_prefs.wifiOnly) { @@ -109,6 +184,75 @@ class ElectrumX { return true; } + void _checkRpcClient() { + // If we're supposed to use Tor... + if (_prefs.useTor) { + // But Tor isn't enabled... + if (!_torService.enabled) { + // And the killswitch isn't set... + if (!_prefs.torKillSwitch) { + // Then we'll just proceed and connect to ElectrumX through clearnet at the bottom of this function. + Logging.instance.log( + "Tor preference set but Tor is not enabled, killswitch not set, connecting to ElectrumX through clearnet", + level: LogLevel.Warning, + ); + } else { + // ... But if the killswitch is set, then we throw an exception. + throw Exception( + "Tor preference and killswitch set but Tor is not enabled, not connecting to ElectrumX"); + } + } else { + // Get the proxy info from the TorService. + final proxyInfo = _torService.proxyInfo; + + if (currentFailoverIndex == -1) { + _rpcClient ??= JsonRPC( + host: host, + port: port, + useSSL: useSSL, + connectionTimeout: connectionTimeoutForSpecialCaseJsonRPCClients, + proxyInfo: proxyInfo, + ); + } else { + _rpcClient ??= JsonRPC( + host: failovers![currentFailoverIndex].address, + port: failovers![currentFailoverIndex].port, + useSSL: failovers![currentFailoverIndex].useSSL, + connectionTimeout: connectionTimeoutForSpecialCaseJsonRPCClients, + proxyInfo: proxyInfo, + ); + } + + if (_rpcClient!.proxyInfo != proxyInfo) { + _rpcClient!.proxyInfo = proxyInfo; + _rpcClient!.disconnect( + reason: "Tor proxyInfo does not match current info", + ); + } + + return; + } + } + + if (currentFailoverIndex == -1) { + _rpcClient ??= JsonRPC( + host: host, + port: port, + useSSL: useSSL, + connectionTimeout: connectionTimeoutForSpecialCaseJsonRPCClients, + proxyInfo: null, + ); + } else { + _rpcClient ??= JsonRPC( + host: failovers![currentFailoverIndex].address, + port: failovers![currentFailoverIndex].port, + useSSL: failovers![currentFailoverIndex].useSSL, + connectionTimeout: connectionTimeoutForSpecialCaseJsonRPCClients, + proxyInfo: null, + ); + } + } + /// Send raw rpc command Future request({ required String command, @@ -121,20 +265,10 @@ class ElectrumX { throw WifiOnlyException(); } - if (currentFailoverIndex == -1) { - _rpcClient ??= JsonRPC( - host: host, - port: port, - useSSL: useSSL, - connectionTimeout: connectionTimeoutForSpecialCaseJsonRPCClients, - ); + if (_requireMutex) { + await _torConnectingLock.protect(() async => _checkRpcClient()); } else { - _rpcClient = JsonRPC( - host: failovers![currentFailoverIndex].address, - port: failovers![currentFailoverIndex].port, - useSSL: failovers![currentFailoverIndex].useSSL, - connectionTimeout: connectionTimeoutForSpecialCaseJsonRPCClients, - ); + _checkRpcClient(); } try { @@ -221,20 +355,10 @@ class ElectrumX { throw WifiOnlyException(); } - if (currentFailoverIndex == -1) { - _rpcClient ??= JsonRPC( - host: host, - port: port, - useSSL: useSSL, - connectionTimeout: connectionTimeoutForSpecialCaseJsonRPCClients, - ); + if (_requireMutex) { + await _torConnectingLock.protect(() async => _checkRpcClient()); } else { - _rpcClient = JsonRPC( - host: failovers![currentFailoverIndex].address, - port: failovers![currentFailoverIndex].port, - useSSL: failovers![currentFailoverIndex].useSSL, - connectionTimeout: connectionTimeoutForSpecialCaseJsonRPCClients, - ); + _checkRpcClient(); } try { diff --git a/lib/electrumx_rpc/rpc.dart b/lib/electrumx_rpc/rpc.dart index 2dc0d3a71..3d2d499a6 100644 --- a/lib/electrumx_rpc/rpc.dart +++ b/lib/electrumx_rpc/rpc.dart @@ -14,7 +14,10 @@ import 'dart:io'; import 'package:flutter/foundation.dart'; import 'package:mutex/mutex.dart'; +import 'package:stackwallet/exceptions/json_rpc/json_rpc_exception.dart'; +import 'package:stackwallet/networking/socks_socket.dart'; import 'package:stackwallet/utilities/logger.dart'; +import 'package:stackwallet/utilities/prefs.dart'; // Json RPC class to handle connecting to electrumx servers class JsonRPC { @@ -23,16 +26,19 @@ class JsonRPC { required this.port, this.useSSL = false, this.connectionTimeout = const Duration(seconds: 60), + required ({InternetAddress host, int port})? proxyInfo, }); final bool useSSL; final String host; final int port; final Duration connectionTimeout; + ({InternetAddress host, int port})? proxyInfo; final _requestMutex = Mutex(); final _JsonRPCRequestQueue _requestQueue = _JsonRPCRequestQueue(); Socket? _socket; - StreamSubscription? _subscription; + SOCKSSocket? _socksSocket; + StreamSubscription>? _subscription; void _dataHandler(List data) { _requestQueue.nextIncompleteReq.then((req) { @@ -75,7 +81,12 @@ class JsonRPC { _requestQueue.nextIncompleteReq.then((req) { if (req != null) { // \r\n required by electrumx server - _socket!.write('${req.jsonRequest}\r\n'); + if (_socket != null) { + _socket!.write('${req.jsonRequest}\r\n'); + } + if (_socksSocket != null) { + _socksSocket!.write('${req.jsonRequest}\r\n'); + } // TODO different timeout length? req.initiateTimeout( @@ -92,12 +103,22 @@ class JsonRPC { Duration requestTimeout, ) async { await _requestMutex.protect(() async { - if (_socket == null) { - Logging.instance.log( - "JsonRPC request: opening socket $host:$port", - level: LogLevel.Info, - ); - await connect(); + if (!Prefs.instance.useTor) { + if (_socket == null) { + Logging.instance.log( + "JsonRPC request: opening socket $host:$port", + level: LogLevel.Info, + ); + await connect(); + } + } else { + if (_socksSocket == null) { + Logging.instance.log( + "JsonRPC request: opening SOCKS socket to $host:$port", + level: LogLevel.Info, + ); + await connect(); + } } }); @@ -113,9 +134,9 @@ class JsonRPC { reason: "return req.completer.future.onError: $error\n$stackTrace", ); return JsonRPCResponse( - exception: error is Exception + exception: error is JsonRpcException ? error - : Exception( + : JsonRpcException( "req.completer.future.onError: $error\n$stackTrace", ), ); @@ -137,6 +158,8 @@ class JsonRPC { _subscription = null; _socket?.destroy(); _socket = null; + await _socksSocket?.close(); + _socksSocket = null; // clean up remaining queue await _requestQueue.completeRemainingWithError( @@ -146,33 +169,84 @@ class JsonRPC { } Future connect() async { - if (_socket != null) { - throw Exception( - "JsonRPC attempted to connect to an already existing socket!", - ); - } + if (!Prefs.instance.useTor) { + if (useSSL) { + _socket = await SecureSocket.connect( + host, + port, + timeout: connectionTimeout, + onBadCertificate: (_) => true, + ); // TODO do not automatically trust bad certificates + } else { + _socket = await Socket.connect( + host, + port, + timeout: connectionTimeout, + ); + } - if (useSSL) { - _socket = await SecureSocket.connect( - host, - port, - timeout: connectionTimeout, - onBadCertificate: (_) => true, - ); // TODO do not automatically trust bad certificates + _subscription = _socket!.listen( + _dataHandler, + onError: _errorHandler, + onDone: _doneHandler, + cancelOnError: true, + ); } else { - _socket = await Socket.connect( - host, - port, - timeout: connectionTimeout, + if (proxyInfo == null) { + throw JsonRpcException( + "JsonRPC.connect failed with useTor=${Prefs.instance.useTor} and proxyInfo is null"); + } + + // instantiate a socks socket at localhost and on the port selected by the tor service + _socksSocket = await SOCKSSocket.create( + proxyHost: proxyInfo!.host.address, + proxyPort: proxyInfo!.port, + sslEnabled: useSSL, + ); + + try { + Logging.instance.log( + "JsonRPC.connect(): connecting to SOCKS socket at $proxyInfo (SSL $useSSL)...", + level: LogLevel.Info); + + await _socksSocket?.connect(); + + Logging.instance.log( + "JsonRPC.connect(): connected to SOCKS socket at $proxyInfo...", + level: LogLevel.Info); + } catch (e) { + Logging.instance.log( + "JsonRPC.connect(): failed to connect to SOCKS socket at $proxyInfo, $e", + level: LogLevel.Error); + throw JsonRpcException( + "JsonRPC.connect(): failed to connect to SOCKS socket at $proxyInfo, $e"); + } + + try { + Logging.instance.log( + "JsonRPC.connect(): connecting to $host:$port over SOCKS socket at $proxyInfo...", + level: LogLevel.Info); + + await _socksSocket?.connectTo(host, port); + + Logging.instance.log( + "JsonRPC.connect(): connected to $host:$port over SOCKS socket at $proxyInfo", + level: LogLevel.Info); + } catch (e) { + Logging.instance.log( + "JsonRPC.connect(): failed to connect to $host over tor proxy at $proxyInfo, $e", + level: LogLevel.Error); + throw JsonRpcException( + "JsonRPC.connect(): failed to connect to tor proxy, $e"); + } + + _subscription = _socksSocket!.listen( + _dataHandler, + onError: _errorHandler, + onDone: _doneHandler, + cancelOnError: true, ); } - - _subscription = _socket!.listen( - _dataHandler, - onError: _errorHandler, - onDone: _doneHandler, - cancelOnError: true, - ); } } @@ -277,7 +351,7 @@ class _JsonRPCRequest { Future.delayed(requestTimeout).then((_) { if (!isComplete) { try { - throw Exception("_JsonRPCRequest timed out: $jsonRequest"); + throw JsonRpcException("_JsonRPCRequest timed out: $jsonRequest"); } catch (e, s) { completer.completeError(e, s); onTimedOut?.call(); @@ -291,7 +365,18 @@ class _JsonRPCRequest { class JsonRPCResponse { final dynamic data; - final Exception? exception; + final JsonRpcException? exception; JsonRPCResponse({this.data, this.exception}); } + +bool isIpAddress(String host) { + try { + // if the string can be parsed into an InternetAddress, it's an IP. + InternetAddress(host); + return true; + } catch (e) { + // if parsing fails, it's not an IP. + return false; + } +} diff --git a/lib/electrumx_rpc/subscribable_electrumx.dart b/lib/electrumx_rpc/subscribable_electrumx.dart index 4720e345b..b7da56a52 100644 --- a/lib/electrumx_rpc/subscribable_electrumx.dart +++ b/lib/electrumx_rpc/subscribable_electrumx.dart @@ -1,324 +1,324 @@ -/* - * This file is part of Stack Wallet. - * - * Copyright (c) 2023 Cypher Stack - * All Rights Reserved. - * The code is distributed under GPLv3 license, see LICENSE file for details. - * Generated by Cypher Stack on 2023-05-26 - * - */ - -import 'dart:async'; -import 'dart:convert'; -import 'dart:io'; - -import 'package:flutter/foundation.dart'; -import 'package:stackwallet/utilities/logger.dart'; - -class ElectrumXSubscription with ChangeNotifier { - dynamic _response; - dynamic get response => _response; - set response(dynamic newData) { - _response = newData; - notifyListeners(); - } -} - -class SocketTask { - SocketTask({this.completer, this.subscription}); - - final Completer? completer; - final ElectrumXSubscription? subscription; - - bool get isSubscription => subscription != null; -} - -class SubscribableElectrumXClient { - int _currentRequestID = 0; - bool _isConnected = false; - List _responseData = []; - final Map _tasks = {}; - Timer? _aliveTimer; - Socket? _socket; - late final bool _useSSL; - late final Duration _connectionTimeout; - late final Duration _keepAlive; - - bool get isConnected => _isConnected; - bool get useSSL => _useSSL; - - void Function(bool)? onConnectionStatusChanged; - - SubscribableElectrumXClient({ - bool useSSL = true, - this.onConnectionStatusChanged, - Duration connectionTimeout = const Duration(seconds: 5), - Duration keepAlive = const Duration(seconds: 10), - }) { - _useSSL = useSSL; - _connectionTimeout = connectionTimeout; - _keepAlive = keepAlive; - } - - Future connect({required String host, required int port}) async { - try { - await _socket?.close(); - } catch (_) {} - - if (_useSSL) { - _socket = await SecureSocket.connect( - host, - port, - timeout: _connectionTimeout, - onBadCertificate: (_) => true, - ); - } else { - _socket = await Socket.connect( - host, - port, - timeout: _connectionTimeout, - ); - } - _updateConnectionStatus(true); - - _socket!.listen( - _dataHandler, - onError: _errorHandler, - onDone: _doneHandler, - cancelOnError: true, - ); - - _aliveTimer?.cancel(); - _aliveTimer = Timer.periodic( - _keepAlive, - (_) async => _updateConnectionStatus(await ping()), - ); - } - - Future disconnect() async { - _aliveTimer?.cancel(); - await _socket?.close(); - onConnectionStatusChanged = null; - } - - String _buildJsonRequestString({ - required String method, - required String id, - required List params, - }) { - final paramString = jsonEncode(params); - return '{"jsonrpc": "2.0", "id": "$id","method": "$method","params": $paramString}\r\n'; - } - - void _updateConnectionStatus(bool connectionStatus) { - if (_isConnected != connectionStatus && onConnectionStatusChanged != null) { - onConnectionStatusChanged!(connectionStatus); - } - _isConnected = connectionStatus; - } - - void _dataHandler(List data) { - _responseData.addAll(data); - - // 0x0A is newline - // https://electrumx-spesmilo.readthedocs.io/en/latest/protocol-basics.html - if (data.last == 0x0A) { - try { - final response = jsonDecode(String.fromCharCodes(_responseData)) - as Map; - _responseHandler(response); - } catch (e, s) { - Logging.instance - .log("JsonRPC jsonDecode: $e\n$s", level: LogLevel.Error); - rethrow; - } finally { - _responseData = []; - } - } - } - - void _responseHandler(Map response) { - // subscriptions will have a method in the response - if (response['method'] is String) { - _subscriptionHandler(response: response); - return; - } - - final id = response['id'] as String; - final result = response['result']; - - _complete(id, result); - } - - void _subscriptionHandler({ - required Map response, - }) { - final method = response['method']; - switch (method) { - case "blockchain.scripthash.subscribe": - final params = response["params"] as List; - final scripthash = params.first as String; - final taskId = "blockchain.scripthash.subscribe:$scripthash"; - - _tasks[taskId]?.subscription?.response = params.last; - break; - case "blockchain.headers.subscribe": - final params = response["params"]; - const taskId = "blockchain.headers.subscribe"; - - _tasks[taskId]?.subscription?.response = params.first; - break; - default: - break; - } - } - - void _errorHandler(Object error, StackTrace trace) { - _updateConnectionStatus(false); - Logging.instance.log( - "SubscribableElectrumXClient called _errorHandler with: $error\n$trace", - level: LogLevel.Info); - } - - void _doneHandler() { - _updateConnectionStatus(false); - Logging.instance.log("SubscribableElectrumXClient called _doneHandler", - level: LogLevel.Info); - } - - void _complete(String id, dynamic data) { - if (_tasks[id] == null) { - return; - } - - if (!(_tasks[id]?.completer?.isCompleted ?? false)) { - _tasks[id]?.completer?.complete(data); - } - - if (!(_tasks[id]?.isSubscription ?? false)) { - _tasks.remove(id); - } else { - _tasks[id]?.subscription?.response = data; - } - } - - void _addTask({ - required String id, - required Completer completer, - }) { - _tasks[id] = SocketTask(completer: completer, subscription: null); - } - - void _addSubscriptionTask({ - required String id, - required ElectrumXSubscription subscription, - }) { - _tasks[id] = SocketTask(completer: null, subscription: subscription); - } - - Future _call({ - required String method, - List params = const [], - }) async { - final completer = Completer(); - _currentRequestID++; - final id = _currentRequestID.toString(); - _addTask(id: id, completer: completer); - - _socket?.write( - _buildJsonRequestString( - method: method, - id: id, - params: params, - ), - ); - - return completer.future; - } - - Future _callWithTimeout({ - required String method, - List params = const [], - Duration timeout = const Duration(seconds: 2), - }) async { - final completer = Completer(); - _currentRequestID++; - final id = _currentRequestID.toString(); - _addTask(id: id, completer: completer); - - _socket?.write( - _buildJsonRequestString( - method: method, - id: id, - params: params, - ), - ); - - Timer(timeout, () { - if (!completer.isCompleted) { - completer.completeError( - Exception("Request \"id: $id, method: $method\" timed out!"), - ); - } - }); - - return completer.future; - } - - ElectrumXSubscription _subscribe({ - required String taskId, - required String method, - List params = const [], - }) { - // try { - final subscription = ElectrumXSubscription(); - _addSubscriptionTask(id: taskId, subscription: subscription); - _currentRequestID++; - _socket?.write( - _buildJsonRequestString( - method: method, - id: taskId, - params: params, - ), - ); - - return subscription; - // } catch (e, s) { - // Logging.instance.log("SubscribableElectrumXClient _subscribe: $e\n$s", level: LogLevel.Error); - // return null; - // } - } - - /// Ping the server to ensure it is responding - /// - /// Returns true if ping succeeded - Future ping() async { - try { - final response = (await _callWithTimeout(method: "server.ping")) as Map; - return response.keys.contains("result") && response["result"] == null; - } catch (_) { - return false; - } - } - - /// Subscribe to a scripthash to receive notifications on status changes - ElectrumXSubscription subscribeToScripthash({required String scripthash}) { - return _subscribe( - taskId: 'blockchain.scripthash.subscribe:$scripthash', - method: 'blockchain.scripthash.subscribe', - params: [scripthash], - ); - } - - /// Subscribe to block headers to receive notifications on new blocks found - /// - /// Returns the existing subscription if found - ElectrumXSubscription subscribeToBlockHeaders() { - return _tasks["blockchain.headers.subscribe"]?.subscription ?? - _subscribe( - taskId: "blockchain.headers.subscribe", - method: "blockchain.headers.subscribe", - params: [], - ); - } -} +// /* +// * This file is part of Stack Wallet. +// * +// * Copyright (c) 2023 Cypher Stack +// * All Rights Reserved. +// * The code is distributed under GPLv3 license, see LICENSE file for details. +// * Generated by Cypher Stack on 2023-05-26 +// * +// */ +// +// import 'dart:async'; +// import 'dart:convert'; +// import 'dart:io'; +// +// import 'package:flutter/foundation.dart'; +// import 'package:stackwallet/utilities/logger.dart'; +// +// class ElectrumXSubscription with ChangeNotifier { +// dynamic _response; +// dynamic get response => _response; +// set response(dynamic newData) { +// _response = newData; +// notifyListeners(); +// } +// } +// +// class SocketTask { +// SocketTask({this.completer, this.subscription}); +// +// final Completer? completer; +// final ElectrumXSubscription? subscription; +// +// bool get isSubscription => subscription != null; +// } +// +// class SubscribableElectrumXClient { +// int _currentRequestID = 0; +// bool _isConnected = false; +// List _responseData = []; +// final Map _tasks = {}; +// Timer? _aliveTimer; +// Socket? _socket; +// late final bool _useSSL; +// late final Duration _connectionTimeout; +// late final Duration _keepAlive; +// +// bool get isConnected => _isConnected; +// bool get useSSL => _useSSL; +// +// void Function(bool)? onConnectionStatusChanged; +// +// SubscribableElectrumXClient({ +// bool useSSL = true, +// this.onConnectionStatusChanged, +// Duration connectionTimeout = const Duration(seconds: 5), +// Duration keepAlive = const Duration(seconds: 10), +// }) { +// _useSSL = useSSL; +// _connectionTimeout = connectionTimeout; +// _keepAlive = keepAlive; +// } +// +// Future connect({required String host, required int port}) async { +// try { +// await _socket?.close(); +// } catch (_) {} +// +// if (_useSSL) { +// _socket = await SecureSocket.connect( +// host, +// port, +// timeout: _connectionTimeout, +// onBadCertificate: (_) => true, +// ); +// } else { +// _socket = await Socket.connect( +// host, +// port, +// timeout: _connectionTimeout, +// ); +// } +// _updateConnectionStatus(true); +// +// _socket!.listen( +// _dataHandler, +// onError: _errorHandler, +// onDone: _doneHandler, +// cancelOnError: true, +// ); +// +// _aliveTimer?.cancel(); +// _aliveTimer = Timer.periodic( +// _keepAlive, +// (_) async => _updateConnectionStatus(await ping()), +// ); +// } +// +// Future disconnect() async { +// _aliveTimer?.cancel(); +// await _socket?.close(); +// onConnectionStatusChanged = null; +// } +// +// String _buildJsonRequestString({ +// required String method, +// required String id, +// required List params, +// }) { +// final paramString = jsonEncode(params); +// return '{"jsonrpc": "2.0", "id": "$id","method": "$method","params": $paramString}\r\n'; +// } +// +// void _updateConnectionStatus(bool connectionStatus) { +// if (_isConnected != connectionStatus && onConnectionStatusChanged != null) { +// onConnectionStatusChanged!(connectionStatus); +// } +// _isConnected = connectionStatus; +// } +// +// void _dataHandler(List data) { +// _responseData.addAll(data); +// +// // 0x0A is newline +// // https://electrumx-spesmilo.readthedocs.io/en/latest/protocol-basics.html +// if (data.last == 0x0A) { +// try { +// final response = jsonDecode(String.fromCharCodes(_responseData)) +// as Map; +// _responseHandler(response); +// } catch (e, s) { +// Logging.instance +// .log("JsonRPC jsonDecode: $e\n$s", level: LogLevel.Error); +// rethrow; +// } finally { +// _responseData = []; +// } +// } +// } +// +// void _responseHandler(Map response) { +// // subscriptions will have a method in the response +// if (response['method'] is String) { +// _subscriptionHandler(response: response); +// return; +// } +// +// final id = response['id'] as String; +// final result = response['result']; +// +// _complete(id, result); +// } +// +// void _subscriptionHandler({ +// required Map response, +// }) { +// final method = response['method']; +// switch (method) { +// case "blockchain.scripthash.subscribe": +// final params = response["params"] as List; +// final scripthash = params.first as String; +// final taskId = "blockchain.scripthash.subscribe:$scripthash"; +// +// _tasks[taskId]?.subscription?.response = params.last; +// break; +// case "blockchain.headers.subscribe": +// final params = response["params"]; +// const taskId = "blockchain.headers.subscribe"; +// +// _tasks[taskId]?.subscription?.response = params.first; +// break; +// default: +// break; +// } +// } +// +// void _errorHandler(Object error, StackTrace trace) { +// _updateConnectionStatus(false); +// Logging.instance.log( +// "SubscribableElectrumXClient called _errorHandler with: $error\n$trace", +// level: LogLevel.Info); +// } +// +// void _doneHandler() { +// _updateConnectionStatus(false); +// Logging.instance.log("SubscribableElectrumXClient called _doneHandler", +// level: LogLevel.Info); +// } +// +// void _complete(String id, dynamic data) { +// if (_tasks[id] == null) { +// return; +// } +// +// if (!(_tasks[id]?.completer?.isCompleted ?? false)) { +// _tasks[id]?.completer?.complete(data); +// } +// +// if (!(_tasks[id]?.isSubscription ?? false)) { +// _tasks.remove(id); +// } else { +// _tasks[id]?.subscription?.response = data; +// } +// } +// +// void _addTask({ +// required String id, +// required Completer completer, +// }) { +// _tasks[id] = SocketTask(completer: completer, subscription: null); +// } +// +// void _addSubscriptionTask({ +// required String id, +// required ElectrumXSubscription subscription, +// }) { +// _tasks[id] = SocketTask(completer: null, subscription: subscription); +// } +// +// Future _call({ +// required String method, +// List params = const [], +// }) async { +// final completer = Completer(); +// _currentRequestID++; +// final id = _currentRequestID.toString(); +// _addTask(id: id, completer: completer); +// +// _socket?.write( +// _buildJsonRequestString( +// method: method, +// id: id, +// params: params, +// ), +// ); +// +// return completer.future; +// } +// +// Future _callWithTimeout({ +// required String method, +// List params = const [], +// Duration timeout = const Duration(seconds: 2), +// }) async { +// final completer = Completer(); +// _currentRequestID++; +// final id = _currentRequestID.toString(); +// _addTask(id: id, completer: completer); +// +// _socket?.write( +// _buildJsonRequestString( +// method: method, +// id: id, +// params: params, +// ), +// ); +// +// Timer(timeout, () { +// if (!completer.isCompleted) { +// completer.completeError( +// Exception("Request \"id: $id, method: $method\" timed out!"), +// ); +// } +// }); +// +// return completer.future; +// } +// +// ElectrumXSubscription _subscribe({ +// required String taskId, +// required String method, +// List params = const [], +// }) { +// // try { +// final subscription = ElectrumXSubscription(); +// _addSubscriptionTask(id: taskId, subscription: subscription); +// _currentRequestID++; +// _socket?.write( +// _buildJsonRequestString( +// method: method, +// id: taskId, +// params: params, +// ), +// ); +// +// return subscription; +// // } catch (e, s) { +// // Logging.instance.log("SubscribableElectrumXClient _subscribe: $e\n$s", level: LogLevel.Error); +// // return null; +// // } +// } +// +// /// Ping the server to ensure it is responding +// /// +// /// Returns true if ping succeeded +// Future ping() async { +// try { +// final response = (await _callWithTimeout(method: "server.ping")) as Map; +// return response.keys.contains("result") && response["result"] == null; +// } catch (_) { +// return false; +// } +// } +// +// /// Subscribe to a scripthash to receive notifications on status changes +// ElectrumXSubscription subscribeToScripthash({required String scripthash}) { +// return _subscribe( +// taskId: 'blockchain.scripthash.subscribe:$scripthash', +// method: 'blockchain.scripthash.subscribe', +// params: [scripthash], +// ); +// } +// +// /// Subscribe to block headers to receive notifications on new blocks found +// /// +// /// Returns the existing subscription if found +// ElectrumXSubscription subscribeToBlockHeaders() { +// return _tasks["blockchain.headers.subscribe"]?.subscription ?? +// _subscribe( +// taskId: "blockchain.headers.subscribe", +// method: "blockchain.headers.subscribe", +// params: [], +// ); +// } +// } diff --git a/lib/exceptions/json_rpc/json_rpc_exception.dart b/lib/exceptions/json_rpc/json_rpc_exception.dart new file mode 100644 index 000000000..e0a51ce84 --- /dev/null +++ b/lib/exceptions/json_rpc/json_rpc_exception.dart @@ -0,0 +1,21 @@ +/* + * This file is part of Stack Wallet. + * + * Copyright (c) 2023 Cypher Stack + * All Rights Reserved. + * The code is distributed under GPLv3 license, see LICENSE file for details. + * Generated by Cypher Stack on 2023-05-26 + * + */ + +import 'package:stackwallet/exceptions/sw_exception.dart'; + +class JsonRpcException implements SWException { + JsonRpcException(this.message); + + @override + final String message; + + @override + toString() => message; +} diff --git a/lib/main.dart b/lib/main.dart index 94c70c8b1..9d9b3e879 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -16,7 +16,6 @@ import 'package:cw_core/node.dart'; import 'package:cw_core/unspent_coins_info.dart'; import 'package:cw_core/wallet_info.dart'; import 'package:cw_core/wallet_type.dart'; -import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:flutter_libmonero/monero/monero.dart'; @@ -59,6 +58,7 @@ import 'package:stackwallet/services/locale_service.dart'; import 'package:stackwallet/services/node_service.dart'; import 'package:stackwallet/services/notifications_api.dart'; import 'package:stackwallet/services/notifications_service.dart'; +import 'package:stackwallet/services/tor_service.dart'; import 'package:stackwallet/services/trade_service.dart'; import 'package:stackwallet/themes/theme_providers.dart'; import 'package:stackwallet/themes/theme_service.dart'; @@ -97,7 +97,7 @@ void main() async { setWindowMaxSize(Size.infinite); final screenHeight = screen?.frame.height; - if (screenHeight != null && !kDebugMode) { + if (screenHeight != null) { // starting to height be 3/4 screen height or 900, whichever is smaller final height = min(screenHeight * 0.75, 900); setWindowFrame( @@ -167,6 +167,16 @@ void main() async { await Hive.openBox(DB.boxNamePrefs); await Prefs.instance.init(); + // TODO: + // This should be moved to happen during the loading animation instead of + // showing a blank screen for 4-10 seconds. + // Some refactoring will need to be done here to make sure we don't make any + // network calls before starting up tor + if (Prefs.instance.useTor) { + TorService.sharedInstance.init(); + await TorService.sharedInstance.start(); + } + await StackFileSystem.initThemesDir(); // Desktop migrate handled elsewhere (currently desktop_login_view.dart) diff --git a/lib/networking/http.dart b/lib/networking/http.dart new file mode 100644 index 000000000..ad15b659c --- /dev/null +++ b/lib/networking/http.dart @@ -0,0 +1,124 @@ +import 'dart:async'; +import 'dart:convert'; +import 'dart:io'; + +import 'package:flutter/foundation.dart'; +import 'package:socks5_proxy/socks_client.dart'; +import 'package:stackwallet/utilities/logger.dart'; + +// WIP wrapper layer + +// TODO expand this class +class Response { + final int code; + final List bodyBytes; + + String get body => utf8.decode(bodyBytes, allowMalformed: true); + + Response(this.bodyBytes, this.code); +} + +class HTTP { + Future get({ + required Uri url, + Map? headers, + required ({ + InternetAddress host, + int port, + })? proxyInfo, + }) async { + final httpClient = HttpClient(); + try { + if (proxyInfo != null) { + SocksTCPClient.assignToHttpClient(httpClient, [ + ProxySettings( + proxyInfo.host, + proxyInfo.port, + ), + ]); + } + final HttpClientRequest request = await httpClient.getUrl( + url, + ); + + if (headers != null) { + headers.forEach((key, value) => request.headers.add(key, value)); + } + + final response = await request.close(); + + return Response( + await _bodyBytes(response), + response.statusCode, + ); + } catch (e, s) { + Logging.instance.log( + "HTTP.get() rethrew: $e\n$s", + level: LogLevel.Info, + ); + rethrow; + } finally { + httpClient.close(force: true); + } + } + + Future post({ + required Uri url, + Map? headers, + Object? body, + Encoding? encoding, + required ({ + InternetAddress host, + int port, + })? proxyInfo, + }) async { + final httpClient = HttpClient(); + try { + if (proxyInfo != null) { + SocksTCPClient.assignToHttpClient(httpClient, [ + ProxySettings( + proxyInfo.host, + proxyInfo.port, + ), + ]); + } + final HttpClientRequest request = await httpClient.postUrl( + url, + ); + + if (headers != null) { + headers.forEach((key, value) => request.headers.add(key, value)); + } + + request.write(body); + + final response = await request.close(); + return Response( + await _bodyBytes(response), + response.statusCode, + ); + } catch (e, s) { + Logging.instance.log( + "HTTP.post() rethrew: $e\n$s", + level: LogLevel.Info, + ); + rethrow; + } finally { + httpClient.close(force: true); + } + } + + Future _bodyBytes(HttpClientResponse response) { + final completer = Completer(); + final List bytes = []; + response.listen( + (data) { + bytes.addAll(data); + }, + onDone: () => completer.complete( + Uint8List.fromList(bytes), + ), + ); + return completer.future; + } +} diff --git a/lib/networking/socks_socket.dart b/lib/networking/socks_socket.dart new file mode 100644 index 000000000..03dc60945 --- /dev/null +++ b/lib/networking/socks_socket.dart @@ -0,0 +1,343 @@ +import 'dart:async'; +import 'dart:convert'; +import 'dart:io'; + +/// A SOCKS5 socket. +/// +/// This class is a wrapper around a Socket that connects to a SOCKS5 proxy +/// server and sends all data through the proxy. +/// +/// This class is used to connect to the Tor proxy server. +/// +/// Attributes: +/// - [proxyHost]: The host of the SOCKS5 proxy server. +/// - [proxyPort]: The port of the SOCKS5 proxy server. +/// - [_socksSocket]: The underlying [Socket] that connects to the SOCKS5 proxy +/// server. +/// - [_responseController]: A [StreamController] that listens to the +/// [_socksSocket] and broadcasts the response. +/// +/// Methods: +/// - connect: Connects to the SOCKS5 proxy server. +/// - connectTo: Connects to the specified [domain] and [port] through the +/// SOCKS5 proxy server. +/// - write: Converts [object] to a String by invoking [Object.toString] and +/// sends the encoding of the result to the socket. +/// - sendServerFeaturesCommand: Sends the server.features command to the +/// proxy server. +/// - close: Closes the connection to the Tor proxy. +/// +/// Usage: +/// ```dart +/// // Instantiate a socks socket at localhost and on the port selected by the +/// // tor service. +/// var socksSocket = await SOCKSSocket.create( +/// proxyHost: InternetAddress.loopbackIPv4.address, +/// proxyPort: tor.port, +/// // sslEnabled: true, // For SSL connections. +/// ); +/// +/// // Connect to the socks instantiated above. +/// await socksSocket.connect(); +/// +/// // Connect to bitcoincash.stackwallet.com on port 50001 via socks socket. +/// await socksSocket.connectTo( +/// 'bitcoincash.stackwallet.com', 50001); +/// +/// // Send a server features command to the connected socket, see method for +/// // more specific usage example.. +/// await socksSocket.sendServerFeaturesCommand(); +/// await socksSocket.close(); +/// ``` +/// +/// See also: +/// - SOCKS5 protocol(https://www.ietf.org/rfc/rfc1928.txt) +class SOCKSSocket { + /// The host of the SOCKS5 proxy server. + final String proxyHost; + + /// The port of the SOCKS5 proxy server. + final int proxyPort; + + /// The underlying Socket that connects to the SOCKS5 proxy server. + late final Socket _socksSocket; + + /// Getter for the underlying Socket that connects to the SOCKS5 proxy server. + Socket get socket => sslEnabled ? _secureSocksSocket : _socksSocket; + + /// A wrapper around the _socksSocket that enables SSL connections. + late final Socket _secureSocksSocket; + + /// A StreamController that listens to the _socksSocket and broadcasts. + final StreamController> _responseController = + StreamController.broadcast(); + + /// A StreamController that listens to the _secureSocksSocket and broadcasts. + final StreamController> _secureResponseController = + StreamController.broadcast(); + + /// Getter for the StreamController that listens to the _socksSocket and + /// broadcasts, or the _secureSocksSocket and broadcasts if SSL is enabled. + StreamController> get responseController => + sslEnabled ? _secureResponseController : _responseController; + + /// A StreamSubscription that listens to the _socksSocket or the + /// _secureSocksSocket if SSL is enabled. + StreamSubscription>? _subscription; + + /// Getter for the StreamSubscription that listens to the _socksSocket or the + /// _secureSocksSocket if SSL is enabled. + StreamSubscription>? get subscription => _subscription; + + /// Is SSL enabled? + final bool sslEnabled; + + /// Private constructor. + SOCKSSocket._(this.proxyHost, this.proxyPort, this.sslEnabled); + + /// Creates a SOCKS5 socket to the specified [proxyHost] and [proxyPort]. + /// + /// This method is a factory constructor that returns a Future that resolves + /// to a SOCKSSocket instance. + /// + /// Parameters: + /// - [proxyHost]: The host of the SOCKS5 proxy server. + /// - [proxyPort]: The port of the SOCKS5 proxy server. + /// + /// Returns: + /// A Future that resolves to a SOCKSSocket instance. + static Future create( + {required String proxyHost, + required int proxyPort, + bool sslEnabled = false}) async { + // Create a SOCKS socket instance. + var instance = SOCKSSocket._(proxyHost, proxyPort, sslEnabled); + + // Initialize the SOCKS socket. + await instance._init(); + + // Return the SOCKS socket instance. + return instance; + } + + /// Constructor. + SOCKSSocket( + {required this.proxyHost, + required this.proxyPort, + required this.sslEnabled}) { + _init(); + } + + /// Initializes the SOCKS socket. + /// + /// This method is a private method that is called by the constructor. + /// + /// Returns: + /// A Future that resolves to void. + Future _init() async { + // Connect to the SOCKS proxy server. + _socksSocket = await Socket.connect( + proxyHost, + proxyPort, + ); + + // Listen to the socket. + _subscription = _socksSocket.listen( + (data) { + // Add the data to the response controller. + _responseController.add(data); + }, + onError: (e) { + // Handle errors. + if (e is Object) { + _responseController.addError(e); + } + + // If the error is not an object, send the error as a string. + _responseController.addError("$e"); + // TODO make sure sending error as string is acceptable. + }, + onDone: () { + // Close the response controller when the socket is closed. + _responseController.close(); + }, + ); + } + + /// Connects to the SOCKS socket. + /// + /// Returns: + /// A Future that resolves to void. + Future connect() async { + // Greeting and method selection. + _socksSocket.add([0x05, 0x01, 0x00]); + + // Wait for server response. + var response = await _responseController.stream.first; + + // Check if the connection was successful. + if (response[1] != 0x00) { + throw Exception( + 'socks_socket.connect(): Failed to connect to SOCKS5 proxy.'); + } + } + + /// Connects to the specified [domain] and [port] through the SOCKS socket. + /// + /// Parameters: + /// - [domain]: The domain to connect to. + /// - [port]: The port to connect to. + /// + /// Returns: + /// A Future that resolves to void. + Future connectTo(String domain, int port) async { + // Connect command. + var request = [ + 0x05, // SOCKS version. + 0x01, // Connect command. + 0x00, // Reserved. + 0x03, // Domain name. + domain.length, + ...domain.codeUnits, + (port >> 8) & 0xFF, + port & 0xFF + ]; + + // Send the connect command to the SOCKS proxy server. + _socksSocket.add(request); + + // Wait for server response. + var response = await _responseController.stream.first; + + // Check if the connection was successful. + if (response[1] != 0x00) { + throw Exception( + 'socks_socket.connectTo(): Failed to connect to target through SOCKS5 proxy.'); + } + + // Upgrade to SSL if needed + if (sslEnabled) { + // Upgrade to SSL. + _secureSocksSocket = await SecureSocket.secure( + _socksSocket, + host: domain, + // onBadCertificate: (_) => true, // Uncomment this to bypass certificate validation (NOT recommended for production). + ); + + // Listen to the secure socket. + _subscription = _secureSocksSocket.listen( + (data) { + // Add the data to the response controller. + _secureResponseController.add(data); + }, + onError: (e) { + // Handle errors. + if (e is Object) { + _secureResponseController.addError(e); + } + + // If the error is not an object, send the error as a string. + _secureResponseController.addError("$e"); + // TODO make sure sending error as string is acceptable. + }, + onDone: () { + // Close the response controller when the socket is closed. + _secureResponseController.close(); + }, + ); + } + + return; + } + + /// Converts [object] to a String by invoking [Object.toString] and + /// sends the encoding of the result to the socket. + /// + /// Parameters: + /// - [object]: The object to write to the socket. + /// + /// Returns: + /// A Future that resolves to void. + void write(Object? object) { + // Don't write null. + if (object == null) return; + + // Write the data to the socket. + List data = utf8.encode(object.toString()); + if (sslEnabled) { + _secureSocksSocket.add(data); + } else { + _socksSocket.add(data); + } + } + + /// Sends the server.features command to the proxy server. + /// + /// This method is used to send the server.features command to the proxy + /// server. This command is used to request the features of the proxy server. + /// It serves as a demonstration of how to send commands to the proxy server. + /// + /// Returns: + /// A Future that resolves to void. + Future sendServerFeaturesCommand() async { + // The server.features command. + const String command = + '{"jsonrpc":"2.0","id":"0","method":"server.features","params":[]}'; + + if (!sslEnabled) { + // Send the command to the proxy server. + _socksSocket.writeln(command); + + // Wait for the response from the proxy server. + var responseData = await _responseController.stream.first; + print("responseData: ${utf8.decode(responseData)}"); + } else { + // Send the command to the proxy server. + _secureSocksSocket.writeln(command); + + // Wait for the response from the proxy server. + var responseData = await _secureResponseController.stream.first; + print("secure responseData: ${utf8.decode(responseData)}"); + } + + return; + } + + /// Closes the connection to the Tor proxy. + /// + /// Returns: + /// A Future that resolves to void. + Future close() async { + // Ensure all data is sent before closing. + // + // TODO test this. + if (sslEnabled) { + await _socksSocket.flush(); + await _secureResponseController.close(); + } + await _socksSocket.flush(); + await _responseController.close(); + return await _socksSocket.close(); + } + + StreamSubscription> listen( + void Function(List data)? onData, { + Function? onError, + void Function()? onDone, + bool? cancelOnError, + }) { + return sslEnabled + ? _secureResponseController.stream.listen( + onData, + onError: onError, + onDone: onDone, + cancelOnError: cancelOnError, + ) + : _responseController.stream.listen( + onData, + onError: onError, + onDone: onDone, + cancelOnError: cancelOnError, + ); + } +} diff --git a/lib/pages/add_wallet_views/add_token_view/sub_widgets/add_token_list_element.dart b/lib/pages/add_wallet_views/add_token_view/sub_widgets/add_token_list_element.dart index be5aaa37d..e6d9149a7 100644 --- a/lib/pages/add_wallet_views/add_token_view/sub_widgets/add_token_list_element.dart +++ b/lib/pages/add_wallet_views/add_token_view/sub_widgets/add_token_list_element.dart @@ -8,7 +8,10 @@ * */ +import 'dart:io'; + import 'package:flutter/material.dart'; +import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/flutter_svg.dart'; import 'package:isar/isar.dart'; import 'package:stackwallet/models/isar/exchange_cache/currency.dart'; @@ -16,6 +19,7 @@ import 'package:stackwallet/models/isar/models/ethereum/eth_contract.dart'; import 'package:stackwallet/services/exchange/change_now/change_now_exchange.dart'; import 'package:stackwallet/services/exchange/exchange_data_loading_service.dart'; import 'package:stackwallet/themes/stack_colors.dart'; +import 'package:stackwallet/themes/theme_providers.dart'; import 'package:stackwallet/utilities/assets.dart'; import 'package:stackwallet/utilities/text_styles.dart'; import 'package:stackwallet/utilities/util.dart'; @@ -30,16 +34,17 @@ class AddTokenListElementData { bool selected = false; } -class AddTokenListElement extends StatefulWidget { +class AddTokenListElement extends ConsumerStatefulWidget { const AddTokenListElement({Key? key, required this.data}) : super(key: key); final AddTokenListElementData data; @override - State createState() => _AddTokenListElementState(); + ConsumerState createState() => + _AddTokenListElementState(); } -class _AddTokenListElementState extends State { +class _AddTokenListElementState extends ConsumerState { final bool isDesktop = Util.isDesktop; @override @@ -74,6 +79,17 @@ class _AddTokenListElementState extends State { currency.image, width: iconSize, height: iconSize, + placeholderBuilder: (_) => SvgPicture.file( + File( + ref.watch( + themeAssetsProvider.select( + (value) => value.stackIcon, + ), + ), + ), + width: iconSize, + height: iconSize, + ), ) : SvgPicture.asset( widget.data.token.symbol == "BNB" diff --git a/lib/pages/add_wallet_views/name_your_wallet_view/name_your_wallet_view.dart b/lib/pages/add_wallet_views/name_your_wallet_view/name_your_wallet_view.dart index 4e04fcb80..f07941e36 100644 --- a/lib/pages/add_wallet_views/name_your_wallet_view/name_your_wallet_view.dart +++ b/lib/pages/add_wallet_views/name_your_wallet_view/name_your_wallet_view.dart @@ -14,6 +14,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:stackwallet/notifications/show_flush_bar.dart'; import 'package:stackwallet/pages/add_wallet_views/create_or_restore_wallet_view/sub_widgets/coin_image.dart'; +import 'package:stackwallet/pages/add_wallet_views/new_wallet_options/new_wallet_options_view.dart'; import 'package:stackwallet/pages/add_wallet_views/new_wallet_recovery_phrase_warning_view/new_wallet_recovery_phrase_warning_view.dart'; import 'package:stackwallet/pages/add_wallet_views/restore_wallet_view/restore_options_view/restore_options_view.dart'; import 'package:stackwallet/pages_desktop_specific/my_stack_view/exit_to_my_stack_button.dart'; @@ -336,46 +337,60 @@ class _NameYourWalletViewState extends ConsumerState { ref.read(walletsServiceChangeNotifierProvider); final name = textEditingController.text; - if (await walletsService.checkForDuplicate(name)) { - unawaited(showFloatingFlushBar( - type: FlushBarType.warning, - message: "Wallet name already in use.", - iconAsset: Assets.svg.circleAlert, - context: context, - )); - } else { - // hide keyboard if has focus - if (FocusScope.of(context).hasFocus) { - FocusScope.of(context).unfocus(); - await Future.delayed( - const Duration(milliseconds: 50)); - } + final hasDuplicateName = + await walletsService.checkForDuplicate(name); - if (mounted) { - switch (widget.addWalletType) { - case AddWalletType.New: - unawaited(Navigator.of(context).pushNamed( - NewWalletRecoveryPhraseWarningView.routeName, - arguments: Tuple2( - name, - coin, - ), - )); - break; - case AddWalletType.Restore: - ref - .read(mnemonicWordCountStateProvider.state) - .state = Constants.possibleLengthsForCoin( - coin) - .first; - unawaited(Navigator.of(context).pushNamed( - RestoreOptionsView.routeName, - arguments: Tuple2( - name, - coin, - ), - )); - break; + if (mounted) { + if (hasDuplicateName) { + unawaited(showFloatingFlushBar( + type: FlushBarType.warning, + message: "Wallet name already in use.", + iconAsset: Assets.svg.circleAlert, + context: context, + )); + } else { + // hide keyboard if has focus + if (FocusScope.of(context).hasFocus) { + FocusScope.of(context).unfocus(); + await Future.delayed( + const Duration(milliseconds: 50)); + } + + if (mounted) { + ref + .read(mnemonicWordCountStateProvider.state) + .state = + Constants.possibleLengthsForCoin(coin).last; + ref.read(pNewWalletOptions.notifier).state = null; + + switch (widget.addWalletType) { + case AddWalletType.New: + unawaited( + Navigator.of(context).pushNamed( + coin.hasMnemonicPassphraseSupport + ? NewWalletOptionsView.routeName + : NewWalletRecoveryPhraseWarningView + .routeName, + arguments: Tuple2( + name, + coin, + ), + ), + ); + break; + + case AddWalletType.Restore: + unawaited( + Navigator.of(context).pushNamed( + RestoreOptionsView.routeName, + arguments: Tuple2( + name, + coin, + ), + ), + ); + break; + } } } } diff --git a/lib/pages/add_wallet_views/new_wallet_options/new_wallet_options_view.dart b/lib/pages/add_wallet_views/new_wallet_options/new_wallet_options_view.dart new file mode 100644 index 000000000..f6d3075b2 --- /dev/null +++ b/lib/pages/add_wallet_views/new_wallet_options/new_wallet_options_view.dart @@ -0,0 +1,410 @@ +import 'package:dropdown_button2/dropdown_button2.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_riverpod/flutter_riverpod.dart'; +import 'package:flutter_svg/flutter_svg.dart'; +import 'package:stackwallet/pages/add_wallet_views/create_or_restore_wallet_view/sub_widgets/coin_image.dart'; +import 'package:stackwallet/pages/add_wallet_views/new_wallet_recovery_phrase_warning_view/new_wallet_recovery_phrase_warning_view.dart'; +import 'package:stackwallet/pages/add_wallet_views/restore_wallet_view/restore_options_view/sub_widgets/mobile_mnemonic_length_selector.dart'; +import 'package:stackwallet/pages/add_wallet_views/restore_wallet_view/sub_widgets/mnemonic_word_count_select_sheet.dart'; +import 'package:stackwallet/pages_desktop_specific/my_stack_view/exit_to_my_stack_button.dart'; +import 'package:stackwallet/providers/ui/verify_recovery_phrase/mnemonic_word_count_state_provider.dart'; +import 'package:stackwallet/themes/stack_colors.dart'; +import 'package:stackwallet/utilities/assets.dart'; +import 'package:stackwallet/utilities/constants.dart'; +import 'package:stackwallet/utilities/enums/coin_enum.dart'; +import 'package:stackwallet/utilities/text_styles.dart'; +import 'package:stackwallet/utilities/util.dart'; +import 'package:stackwallet/widgets/background.dart'; +import 'package:stackwallet/widgets/conditional_parent.dart'; +import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart'; +import 'package:stackwallet/widgets/desktop/desktop_app_bar.dart'; +import 'package:stackwallet/widgets/desktop/desktop_scaffold.dart'; +import 'package:stackwallet/widgets/desktop/primary_button.dart'; +import 'package:stackwallet/widgets/rounded_white_container.dart'; +import 'package:stackwallet/widgets/stack_text_field.dart'; +import 'package:tuple/tuple.dart'; + +final pNewWalletOptions = + StateProvider<({String mnemonicPassphrase, int mnemonicWordsCount})?>( + (ref) => null); + +enum NewWalletOptions { + Default, + Advanced; +} + +class NewWalletOptionsView extends ConsumerStatefulWidget { + const NewWalletOptionsView({ + Key? key, + required this.walletName, + required this.coin, + }) : super(key: key); + + static const routeName = "/newWalletOptionsView"; + + final String walletName; + final Coin coin; + + @override + ConsumerState createState() => + _NewWalletOptionsViewState(); +} + +class _NewWalletOptionsViewState extends ConsumerState { + late final FocusNode passwordFocusNode; + late final TextEditingController passwordController; + + bool hidePassword = true; + NewWalletOptions _selectedOptions = NewWalletOptions.Default; + + @override + void initState() { + passwordController = TextEditingController(); + passwordFocusNode = FocusNode(); + + super.initState(); + } + + @override + void dispose() { + passwordController.dispose(); + passwordFocusNode.dispose(); + super.dispose(); + } + + @override + Widget build(BuildContext context) { + final lengths = Constants.possibleLengthsForCoin(widget.coin).toList(); + return ConditionalParent( + condition: Util.isDesktop, + builder: (child) => DesktopScaffold( + background: Theme.of(context).extension()!.background, + appBar: const DesktopAppBar( + isCompactHeight: false, + leading: AppBarBackButton(), + trailing: ExitToMyStackButton(), + ), + body: SizedBox( + width: 480, + child: child, + ), + ), + child: ConditionalParent( + condition: !Util.isDesktop, + builder: (child) => Background( + child: Scaffold( + backgroundColor: + Theme.of(context).extension()!.background, + appBar: AppBar( + leading: const AppBarBackButton(), + title: Text( + "Wallet Options", + style: STextStyles.navBarTitle(context), + ), + ), + body: SafeArea( + child: LayoutBuilder( + builder: (context, constraints) { + return SingleChildScrollView( + child: ConstrainedBox( + constraints: BoxConstraints( + minHeight: constraints.maxHeight, + ), + child: IntrinsicHeight( + child: Padding( + padding: const EdgeInsets.symmetric(horizontal: 16), + child: child, + ), + ), + ), + ); + }, + ), + ), + ), + ), + child: Column( + children: [ + if (Util.isDesktop) + const Spacer( + flex: 10, + ), + if (!Util.isDesktop) + const SizedBox( + height: 16, + ), + if (!Util.isDesktop) + CoinImage( + coin: widget.coin, + height: 100, + width: 100, + ), + if (Util.isDesktop) + Text( + "Wallet options", + textAlign: TextAlign.center, + style: Util.isDesktop + ? STextStyles.desktopH2(context) + : STextStyles.pageTitleH1(context), + ), + SizedBox( + height: Util.isDesktop ? 32 : 16, + ), + DropdownButtonHideUnderline( + child: DropdownButton2( + value: _selectedOptions, + items: [ + ...NewWalletOptions.values.map( + (e) => DropdownMenuItem( + value: e, + child: Text( + e.name, + style: STextStyles.desktopTextMedium(context), + ), + ), + ), + ], + onChanged: (value) { + if (value is NewWalletOptions) { + setState(() { + _selectedOptions = value; + }); + } + }, + isExpanded: true, + iconStyleData: IconStyleData( + icon: SvgPicture.asset( + Assets.svg.chevronDown, + width: 12, + height: 6, + color: Theme.of(context) + .extension()! + .textFieldActiveSearchIconRight, + ), + ), + dropdownStyleData: DropdownStyleData( + offset: const Offset(0, -10), + elevation: 0, + decoration: BoxDecoration( + color: Theme.of(context) + .extension()! + .textFieldDefaultBG, + borderRadius: BorderRadius.circular( + Constants.size.circularBorderRadius, + ), + ), + ), + menuItemStyleData: const MenuItemStyleData( + padding: EdgeInsets.symmetric( + horizontal: 16, + vertical: 8, + ), + ), + ), + ), + const SizedBox( + height: 24, + ), + if (_selectedOptions == NewWalletOptions.Advanced) + Column( + children: [ + if (Util.isDesktop) + DropdownButtonHideUnderline( + child: DropdownButton2( + value: ref + .watch(mnemonicWordCountStateProvider.state) + .state, + items: [ + ...lengths.map( + (e) => DropdownMenuItem( + value: e, + child: Text( + "$e word seed", + style: STextStyles.desktopTextMedium(context), + ), + ), + ), + ], + onChanged: (value) { + if (value is int) { + ref + .read(mnemonicWordCountStateProvider.state) + .state = value; + } + }, + isExpanded: true, + iconStyleData: IconStyleData( + icon: SvgPicture.asset( + Assets.svg.chevronDown, + width: 12, + height: 6, + color: Theme.of(context) + .extension()! + .textFieldActiveSearchIconRight, + ), + ), + dropdownStyleData: DropdownStyleData( + offset: const Offset(0, -10), + elevation: 0, + decoration: BoxDecoration( + color: Theme.of(context) + .extension()! + .textFieldDefaultBG, + borderRadius: BorderRadius.circular( + Constants.size.circularBorderRadius, + ), + ), + ), + menuItemStyleData: const MenuItemStyleData( + padding: EdgeInsets.symmetric( + horizontal: 16, + vertical: 8, + ), + ), + ), + ), + if (!Util.isDesktop) + MobileMnemonicLengthSelector( + chooseMnemonicLength: () { + showModalBottomSheet( + backgroundColor: Colors.transparent, + context: context, + shape: const RoundedRectangleBorder( + borderRadius: BorderRadius.vertical( + top: Radius.circular(20), + ), + ), + builder: (_) { + return MnemonicWordCountSelectSheet( + lengthOptions: lengths, + ); + }, + ); + }, + ), + const SizedBox( + height: 24, + ), + RoundedWhiteContainer( + child: Center( + child: Text( + "You may add a BIP39 passphrase. This is optional. " + "You will need BOTH your seed and your passphrase to recover the wallet.", + style: Util.isDesktop + ? STextStyles.desktopTextExtraSmall(context) + .copyWith( + color: Theme.of(context) + .extension()! + .textSubtitle1, + ) + : STextStyles.itemSubtitle(context), + ), + ), + ), + const SizedBox( + height: 8, + ), + ClipRRect( + borderRadius: BorderRadius.circular( + Constants.size.circularBorderRadius, + ), + child: TextField( + key: const Key("mnemonicPassphraseFieldKey1"), + focusNode: passwordFocusNode, + controller: passwordController, + style: Util.isDesktop + ? STextStyles.desktopTextMedium(context).copyWith( + height: 2, + ) + : STextStyles.field(context), + obscureText: hidePassword, + enableSuggestions: false, + autocorrect: false, + decoration: standardInputDecoration( + "BIP39 passphrase", + passwordFocusNode, + context, + ).copyWith( + suffixIcon: UnconstrainedBox( + child: ConditionalParent( + condition: Util.isDesktop, + builder: (child) => SizedBox( + height: 70, + child: child, + ), + child: Row( + children: [ + SizedBox( + width: Util.isDesktop ? 24 : 16, + ), + GestureDetector( + key: const Key( + "mnemonicPassphraseFieldShowPasswordButtonKey"), + onTap: () async { + setState(() { + hidePassword = !hidePassword; + }); + }, + child: SvgPicture.asset( + hidePassword + ? Assets.svg.eye + : Assets.svg.eyeSlash, + color: Theme.of(context) + .extension()! + .textDark3, + width: Util.isDesktop ? 24 : 16, + height: Util.isDesktop ? 24 : 16, + ), + ), + const SizedBox( + width: 12, + ), + ], + ), + ), + ), + ), + ), + ), + ], + ), + if (!Util.isDesktop) const Spacer(), + SizedBox( + height: Util.isDesktop ? 32 : 16, + ), + PrimaryButton( + label: "Continue", + onPressed: () { + if (_selectedOptions == NewWalletOptions.Advanced) { + ref.read(pNewWalletOptions.notifier).state = ( + mnemonicWordsCount: + ref.read(mnemonicWordCountStateProvider.state).state, + mnemonicPassphrase: passwordController.text, + ); + } else { + ref.read(pNewWalletOptions.notifier).state = null; + } + + Navigator.of(context).pushNamed( + NewWalletRecoveryPhraseWarningView.routeName, + arguments: Tuple2( + widget.walletName, + widget.coin, + ), + ); + }, + ), + if (!Util.isDesktop) + const SizedBox( + height: 16, + ), + if (Util.isDesktop) + const Spacer( + flex: 15, + ), + ], + ), + ), + ); + } +} diff --git a/lib/pages/add_wallet_views/new_wallet_recovery_phrase_warning_view/new_wallet_recovery_phrase_warning_view.dart b/lib/pages/add_wallet_views/new_wallet_recovery_phrase_warning_view/new_wallet_recovery_phrase_warning_view.dart index e373e817b..d843f6ec8 100644 --- a/lib/pages/add_wallet_views/new_wallet_recovery_phrase_warning_view/new_wallet_recovery_phrase_warning_view.dart +++ b/lib/pages/add_wallet_views/new_wallet_recovery_phrase_warning_view/new_wallet_recovery_phrase_warning_view.dart @@ -13,6 +13,7 @@ import 'dart:async'; import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/flutter_svg.dart'; +import 'package:stackwallet/pages/add_wallet_views/new_wallet_options/new_wallet_options_view.dart'; import 'package:stackwallet/pages/add_wallet_views/new_wallet_recovery_phrase_view/new_wallet_recovery_phrase_view.dart'; import 'package:stackwallet/pages/add_wallet_views/new_wallet_recovery_phrase_warning_view/recovery_phrase_explanation_dialog.dart'; import 'package:stackwallet/pages_desktop_specific/my_stack_view/exit_to_my_stack_button.dart'; @@ -38,7 +39,7 @@ import 'package:stackwallet/widgets/rounded_container.dart'; import 'package:stackwallet/widgets/rounded_white_container.dart'; import 'package:tuple/tuple.dart'; -class NewWalletRecoveryPhraseWarningView extends StatefulWidget { +class NewWalletRecoveryPhraseWarningView extends ConsumerStatefulWidget { const NewWalletRecoveryPhraseWarningView({ Key? key, required this.coin, @@ -51,12 +52,12 @@ class NewWalletRecoveryPhraseWarningView extends StatefulWidget { final String walletName; @override - State createState() => + ConsumerState createState() => _NewWalletRecoveryPhraseWarningViewState(); } class _NewWalletRecoveryPhraseWarningViewState - extends State { + extends ConsumerState { late final Coin coin; late final String walletName; late final bool isDesktop; @@ -72,6 +73,10 @@ class _NewWalletRecoveryPhraseWarningViewState @override Widget build(BuildContext context) { debugPrint("BUILD: $runtimeType"); + final options = ref.read(pNewWalletOptions.state).state; + + final seedCount = options?.mnemonicWordsCount ?? + Constants.defaultSeedPhraseLengthFor(coin: coin); return MasterScaffold( isDesktop: isDesktop, @@ -172,7 +177,7 @@ class _NewWalletRecoveryPhraseWarningViewState child: isDesktop ? Text( "On the next screen you will see " - "${Constants.defaultSeedPhraseLengthFor(coin: coin)} " + "$seedCount " "words that make up your recovery phrase.\n\nPlease " "write it down. Keep it safe and never share it with " "anyone. Your recovery phrase is the only way you can" @@ -216,9 +221,7 @@ class _NewWalletRecoveryPhraseWarningViewState ), ), TextSpan( - text: - "${Constants.defaultSeedPhraseLengthFor(coin: coin)}" - " words", + text: "$seedCount words", style: STextStyles.desktopH3(context).copyWith( color: Theme.of(context) .extension()! @@ -496,7 +499,24 @@ class _NewWalletRecoveryPhraseWarningViewState final manager = Manager(wallet); - await manager.initializeNew(); + if (coin.hasMnemonicPassphraseSupport && + ref + .read(pNewWalletOptions.state) + .state != + null) { + await manager.initializeNew(( + mnemonicPassphrase: ref + .read(pNewWalletOptions.state) + .state! + .mnemonicPassphrase, + wordCount: ref + .read(pNewWalletOptions.state) + .state! + .mnemonicWordsCount, + )); + } else { + await manager.initializeNew(null); + } // pop progress dialog if (mounted) { diff --git a/lib/pages/add_wallet_views/restore_wallet_view/restore_options_view/restore_options_view.dart b/lib/pages/add_wallet_views/restore_wallet_view/restore_options_view/restore_options_view.dart index 59d1c0a8f..44ac51aac 100644 --- a/lib/pages/add_wallet_views/restore_wallet_view/restore_options_view/restore_options_view.dart +++ b/lib/pages/add_wallet_views/restore_wallet_view/restore_options_view/restore_options_view.dart @@ -535,7 +535,7 @@ class _RestoreOptionsViewState extends ConsumerState { enableSuggestions: false, autocorrect: false, decoration: standardInputDecoration( - "Recovery phrase password", + "BIP39 passphrase", passwordFocusNode, context, ).copyWith( @@ -586,7 +586,9 @@ class _RestoreOptionsViewState extends ConsumerState { RoundedWhiteContainer( child: Center( child: Text( - "If the recovery phrase you are about to restore was created with an optional passphrase you can enter it here.", + "If the recovery phrase you are about to restore " + "was created with an optional BIP39 passphrase " + "you can enter it here.", style: isDesktop ? STextStyles.desktopTextExtraSmall(context) .copyWith( diff --git a/lib/pages/add_wallet_views/restore_wallet_view/restore_wallet_view.dart b/lib/pages/add_wallet_views/restore_wallet_view/restore_wallet_view.dart index 87219d277..1a62af746 100644 --- a/lib/pages/add_wallet_views/restore_wallet_view/restore_wallet_view.dart +++ b/lib/pages/add_wallet_views/restore_wallet_view/restore_wallet_view.dart @@ -98,7 +98,7 @@ class _RestoreWalletViewState extends ConsumerState { final List _controllers = []; final List _inputStatuses = []; - final List _focusNodes = []; + // final List _focusNodes = []; late final BarcodeScannerInterface scanner; @@ -152,7 +152,7 @@ class _RestoreWalletViewState extends ConsumerState { for (int i = 0; i < _seedWordCount; i++) { _controllers.add(TextEditingController()); _inputStatuses.add(FormInputStatus.empty); - _focusNodes.add(FocusNode()); + // _focusNodes.add(FocusNode()); } super.initState(); @@ -821,8 +821,8 @@ class _RestoreWalletViewState extends ConsumerState { i * 4 + j - 1 == 1 ? textSelectionControls : null, - focusNode: - _focusNodes[i * 4 + j - 1], + // focusNode: + // _focusNodes[i * 4 + j - 1], onChanged: (value) { final FormInputStatus formInputStatus; @@ -841,18 +841,18 @@ class _RestoreWalletViewState extends ConsumerState { FormInputStatus.invalid; } - if (formInputStatus == - FormInputStatus.valid) { - if (i * 4 + j < - _focusNodes.length) { - _focusNodes[i * 4 + j] - .requestFocus(); - } else if (i * 4 + j == - _focusNodes.length) { - _focusNodes[i * 4 + j - 1] - .unfocus(); - } - } + // if (formInputStatus == + // FormInputStatus.valid) { + // if (i * 4 + j < + // _focusNodes.length) { + // _focusNodes[i * 4 + j] + // .requestFocus(); + // } else if (i * 4 + j == + // _focusNodes.length) { + // _focusNodes[i * 4 + j - 1] + // .unfocus(); + // } + // } setState(() { _inputStatuses[i * 4 + j - @@ -929,7 +929,7 @@ class _RestoreWalletViewState extends ConsumerState { selectionControls: i == 1 ? textSelectionControls : null, - focusNode: _focusNodes[i], + // focusNode: _focusNodes[i], onChanged: (value) { final FormInputStatus formInputStatus; @@ -948,27 +948,27 @@ class _RestoreWalletViewState extends ConsumerState { FormInputStatus.invalid; } - if (formInputStatus == - FormInputStatus - .valid && - (i - 1) < - _focusNodes.length) { - Focus.of(context) - .requestFocus( - _focusNodes[i]); - } + // if (formInputStatus == + // FormInputStatus + // .valid && + // (i - 1) < + // _focusNodes.length) { + // Focus.of(context) + // .requestFocus( + // _focusNodes[i]); + // } - if (formInputStatus == - FormInputStatus.valid) { - if (i + 1 < - _focusNodes.length) { - _focusNodes[i + 1] - .requestFocus(); - } else if (i + 1 == - _focusNodes.length) { - _focusNodes[i].unfocus(); - } - } + // if (formInputStatus == + // FormInputStatus.valid) { + // if (i + 1 < + // _focusNodes.length) { + // _focusNodes[i + 1] + // .requestFocus(); + // } else if (i + 1 == + // _focusNodes.length) { + // _focusNodes[i].unfocus(); + // } + // } }, controller: _controllers[i], style: @@ -1068,7 +1068,7 @@ class _RestoreWalletViewState extends ConsumerState { AutovalidateMode.onUserInteraction, selectionControls: i == 1 ? textSelectionControls : null, - focusNode: _focusNodes[i - 1], + // focusNode: _focusNodes[i - 1], onChanged: (value) { final FormInputStatus formInputStatus; @@ -1084,14 +1084,14 @@ class _RestoreWalletViewState extends ConsumerState { FormInputStatus.invalid; } - if (formInputStatus == - FormInputStatus.valid) { - if (i < _focusNodes.length) { - _focusNodes[i].requestFocus(); - } else if (i == _focusNodes.length) { - _focusNodes[i - 1].unfocus(); - } - } + // if (formInputStatus == + // FormInputStatus.valid) { + // if (i < _focusNodes.length) { + // _focusNodes[i].requestFocus(); + // } else if (i == _focusNodes.length) { + // _focusNodes[i - 1].unfocus(); + // } + // } setState(() { _inputStatuses[i - 1] = formInputStatus; diff --git a/lib/pages/add_wallet_views/verify_recovery_phrase_view/verify_mnemonic_passphrase_dialog.dart b/lib/pages/add_wallet_views/verify_recovery_phrase_view/verify_mnemonic_passphrase_dialog.dart new file mode 100644 index 000000000..bae25a7e1 --- /dev/null +++ b/lib/pages/add_wallet_views/verify_recovery_phrase_view/verify_mnemonic_passphrase_dialog.dart @@ -0,0 +1,218 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_riverpod/flutter_riverpod.dart'; +import 'package:flutter_svg/flutter_svg.dart'; +import 'package:stackwallet/notifications/show_flush_bar.dart'; +import 'package:stackwallet/pages/add_wallet_views/new_wallet_options/new_wallet_options_view.dart'; +import 'package:stackwallet/themes/stack_colors.dart'; +import 'package:stackwallet/utilities/assets.dart'; +import 'package:stackwallet/utilities/constants.dart'; +import 'package:stackwallet/utilities/text_styles.dart'; +import 'package:stackwallet/utilities/util.dart'; +import 'package:stackwallet/widgets/conditional_parent.dart'; +import 'package:stackwallet/widgets/desktop/desktop_dialog.dart'; +import 'package:stackwallet/widgets/desktop/desktop_dialog_close_button.dart'; +import 'package:stackwallet/widgets/desktop/primary_button.dart'; +import 'package:stackwallet/widgets/desktop/secondary_button.dart'; +import 'package:stackwallet/widgets/stack_dialog.dart'; +import 'package:stackwallet/widgets/stack_text_field.dart'; + +class VerifyMnemonicPassphraseDialog extends ConsumerStatefulWidget { + const VerifyMnemonicPassphraseDialog({super.key}); + + @override + ConsumerState createState() => + _VerifyMnemonicPassphraseDialogState(); +} + +class _VerifyMnemonicPassphraseDialogState + extends ConsumerState { + late final FocusNode passwordFocusNode; + late final TextEditingController passwordController; + + bool hidePassword = true; + + bool _verifyLock = false; + + void _verify() { + if (_verifyLock) { + return; + } + _verifyLock = true; + + if (passwordController.text == + ref.read(pNewWalletOptions.state).state!.mnemonicPassphrase) { + Navigator.of(context, rootNavigator: Util.isDesktop).pop("verified"); + } else { + showFloatingFlushBar( + type: FlushBarType.warning, + message: "Passphrase does not match", + context: context, + ); + } + + _verifyLock = false; + } + + @override + void initState() { + passwordController = TextEditingController(); + passwordFocusNode = FocusNode(); + + super.initState(); + } + + @override + void dispose() { + passwordController.dispose(); + passwordFocusNode.dispose(); + super.dispose(); + } + + @override + Widget build(BuildContext context) { + return ConditionalParent( + condition: Util.isDesktop, + builder: (child) => DesktopDialog( + maxHeight: double.infinity, + child: Column( + children: [ + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Padding( + padding: const EdgeInsets.only( + left: 32, + ), + child: Text( + "Verify mnemonic passphrase", + style: STextStyles.desktopH3(context), + ), + ), + const DesktopDialogCloseButton(), + ], + ), + Padding( + padding: const EdgeInsets.only( + left: 32, + right: 32, + bottom: 32, + ), + child: child, + ), + ], + ), + ), + child: ConditionalParent( + condition: !Util.isDesktop, + builder: (child) => StackDialogBase( + keyboardPaddingAmount: MediaQuery.of(context).viewInsets.bottom, + child: child, + ), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + if (!Util.isDesktop) + Text( + "Verify BIP39 passphrase", + style: STextStyles.pageTitleH2(context), + ), + const SizedBox( + height: 24, + ), + ClipRRect( + borderRadius: BorderRadius.circular( + Constants.size.circularBorderRadius, + ), + child: TextField( + key: const Key("mnemonicPassphraseFieldKey1"), + focusNode: passwordFocusNode, + controller: passwordController, + style: Util.isDesktop + ? STextStyles.desktopTextMedium(context).copyWith( + height: 2, + ) + : STextStyles.field(context), + obscureText: hidePassword, + enableSuggestions: false, + autocorrect: false, + decoration: standardInputDecoration( + "Enter your BIP39 passphrase", + passwordFocusNode, + context, + ).copyWith( + suffixIcon: UnconstrainedBox( + child: ConditionalParent( + condition: Util.isDesktop, + builder: (child) => SizedBox( + height: 70, + child: child, + ), + child: Row( + children: [ + SizedBox( + width: Util.isDesktop ? 24 : 16, + ), + GestureDetector( + key: const Key( + "mnemonicPassphraseFieldShowPasswordButtonKey"), + onTap: () async { + setState(() { + hidePassword = !hidePassword; + }); + }, + child: SvgPicture.asset( + hidePassword + ? Assets.svg.eye + : Assets.svg.eyeSlash, + color: Theme.of(context) + .extension()! + .textDark3, + width: Util.isDesktop ? 24 : 16, + height: Util.isDesktop ? 24 : 16, + ), + ), + const SizedBox( + width: 12, + ), + ], + ), + ), + ), + ), + ), + ), + SizedBox( + height: Util.isDesktop ? 48 : 24, + ), + ConditionalParent( + condition: !Util.isDesktop, + builder: (child) => Row( + children: [ + Expanded( + child: SecondaryButton( + label: "Cancel", + onPressed: Navigator.of( + context, + rootNavigator: Util.isDesktop, + ).pop, + ), + ), + const SizedBox( + width: 16, + ), + Expanded( + child: child, + ), + ], + ), + child: PrimaryButton( + label: "Verify", + onPressed: _verify, + ), + ), + ], + ), + ), + ); + } +} diff --git a/lib/pages/add_wallet_views/verify_recovery_phrase_view/verify_recovery_phrase_view.dart b/lib/pages/add_wallet_views/verify_recovery_phrase_view/verify_recovery_phrase_view.dart index fda4419d9..0d0083cc6 100644 --- a/lib/pages/add_wallet_views/verify_recovery_phrase_view/verify_recovery_phrase_view.dart +++ b/lib/pages/add_wallet_views/verify_recovery_phrase_view/verify_recovery_phrase_view.dart @@ -16,9 +16,11 @@ import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:stackwallet/notifications/show_flush_bar.dart'; import 'package:stackwallet/pages/add_wallet_views/add_token_view/edit_wallet_tokens_view.dart'; +import 'package:stackwallet/pages/add_wallet_views/new_wallet_options/new_wallet_options_view.dart'; import 'package:stackwallet/pages/add_wallet_views/new_wallet_recovery_phrase_view/new_wallet_recovery_phrase_view.dart'; import 'package:stackwallet/pages/add_wallet_views/select_wallet_for_token_view.dart'; import 'package:stackwallet/pages/add_wallet_views/verify_recovery_phrase_view/sub_widgets/word_table.dart'; +import 'package:stackwallet/pages/add_wallet_views/verify_recovery_phrase_view/verify_mnemonic_passphrase_dialog.dart'; import 'package:stackwallet/pages/home_view/home_view.dart'; import 'package:stackwallet/pages_desktop_specific/desktop_home_view.dart'; import 'package:stackwallet/pages_desktop_specific/my_stack_view/exit_to_my_stack_button.dart'; @@ -98,8 +100,25 @@ class _VerifyRecoveryPhraseViewState // } // } + Future _verifyMnemonicPassphrase() async { + final result = await showDialog( + context: context, + builder: (_) => const VerifyMnemonicPassphraseDialog(), + ); + + return result == "verified"; + } + Future _continue(bool isMatch) async { if (isMatch) { + if (ref.read(pNewWalletOptions.state).state != null) { + final passphraseVerified = await _verifyMnemonicPassphrase(); + + if (!passphraseVerified) { + return; + } + } + await ref.read(walletsServiceChangeNotifierProvider).setMnemonicVerified( walletId: _manager.walletId, ); diff --git a/lib/pages/buy_view/buy_view.dart b/lib/pages/buy_view/buy_view.dart index 3d5fe1539..beeece754 100644 --- a/lib/pages/buy_view/buy_view.dart +++ b/lib/pages/buy_view/buy_view.dart @@ -9,38 +9,82 @@ */ import 'package:flutter/material.dart'; +import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:stackwallet/models/isar/models/ethereum/eth_contract.dart'; import 'package:stackwallet/pages/buy_view/buy_form.dart'; +import 'package:stackwallet/providers/global/prefs_provider.dart'; +import 'package:stackwallet/themes/stack_colors.dart'; import 'package:stackwallet/utilities/enums/coin_enum.dart'; +import 'package:stackwallet/widgets/stack_dialog.dart'; -class BuyView extends StatelessWidget { +class BuyView extends ConsumerStatefulWidget { const BuyView({ Key? key, this.coin, this.tokenContract, }) : super(key: key); - static const String routeName = "/stackBuyView"; - final Coin? coin; final EthContract? tokenContract; + static const String routeName = "/stackBuyView"; + + @override + ConsumerState createState() => _BuyViewState(); +} + +class _BuyViewState extends ConsumerState { + Coin? coin; + EthContract? tokenContract; + late bool torEnabled = false; + + @override + void initState() { + coin = widget.coin; + tokenContract = widget.tokenContract; + + WidgetsBinding.instance.addPostFrameCallback((_) async { + setState(() { + torEnabled = ref.read(prefsChangeNotifierProvider).useTor; + }); + }); + + super.initState(); + } + @override Widget build(BuildContext context) { debugPrint("BUILD: $runtimeType"); - return SafeArea( - child: Padding( - padding: const EdgeInsets.only( - left: 16, - right: 16, - top: 16, + return Stack( + children: [ + SafeArea( + child: Padding( + padding: const EdgeInsets.only( + left: 16, + right: 16, + top: 16, + ), + child: BuyForm( + coin: coin, + tokenContract: tokenContract, + ), + ), ), - child: BuyForm( - coin: coin, - tokenContract: tokenContract, - ), - ), + if (torEnabled) + Container( + color: Theme.of(context) + .extension()! + .overlay + .withOpacity(0.7), + height: MediaQuery.of(context).size.height, + width: MediaQuery.of(context).size.width, + child: const StackDialog( + title: "Tor is enabled", + message: "Purchasing not available while Tor is enabled", + ), + ), + ], ); } } diff --git a/lib/pages/exchange_view/exchange_coin_selection/exchange_currency_selection_view.dart b/lib/pages/exchange_view/exchange_coin_selection/exchange_currency_selection_view.dart index 87fc590e9..ada195455 100644 --- a/lib/pages/exchange_view/exchange_coin_selection/exchange_currency_selection_view.dart +++ b/lib/pages/exchange_view/exchange_coin_selection/exchange_currency_selection_view.dart @@ -24,6 +24,7 @@ import 'package:stackwallet/themes/stack_colors.dart'; import 'package:stackwallet/utilities/assets.dart'; import 'package:stackwallet/utilities/constants.dart'; import 'package:stackwallet/utilities/enums/coin_enum.dart'; +import 'package:stackwallet/utilities/prefs.dart'; import 'package:stackwallet/utilities/text_styles.dart'; import 'package:stackwallet/utilities/util.dart'; import 'package:stackwallet/widgets/background.dart'; @@ -39,6 +40,8 @@ import 'package:stackwallet/widgets/stack_dialog.dart'; import 'package:stackwallet/widgets/stack_text_field.dart'; import 'package:stackwallet/widgets/textfield_icon_button.dart'; +import '../../../services/exchange/exchange.dart'; + class ExchangeCurrencySelectionView extends StatefulWidget { const ExchangeCurrencySelectionView({ Key? key, @@ -125,7 +128,7 @@ class _ExchangeCurrencySelectionViewState await showDialog( context: context, builder: (context) => StackDialog( - title: "ChangeNOW Error", + title: "Exchange Error", message: "Failed to load currency data: ${cn.exception}", leftButton: SecondaryButton( label: "Ok", @@ -169,6 +172,15 @@ class _ExchangeCurrencySelectionViewState .thenByName() .findAll(); + // If using Tor, filter exchanges which do not support Tor. + if (Prefs.instance.useTor) { + if (Exchange.exchangeNamesWithTorSupport.isNotEmpty) { + currencies.removeWhere((element) => !Exchange + .exchangeNamesWithTorSupport + .contains(element.exchangeName)); + } + } + return _getDistinctCurrenciesFrom(currencies); } diff --git a/lib/pages/exchange_view/exchange_form.dart b/lib/pages/exchange_view/exchange_form.dart index a15e13843..a81f758a6 100644 --- a/lib/pages/exchange_view/exchange_form.dart +++ b/lib/pages/exchange_view/exchange_form.dart @@ -31,15 +31,19 @@ import 'package:stackwallet/pages/exchange_view/sub_widgets/rate_type_toggle.dar import 'package:stackwallet/pages_desktop_specific/desktop_exchange/exchange_steps/step_scaffold.dart'; import 'package:stackwallet/providers/providers.dart'; import 'package:stackwallet/services/exchange/change_now/change_now_exchange.dart'; +import 'package:stackwallet/services/exchange/exchange.dart'; import 'package:stackwallet/services/exchange/exchange_data_loading_service.dart'; +import 'package:stackwallet/services/exchange/exchange_response.dart'; import 'package:stackwallet/services/exchange/majestic_bank/majestic_bank_exchange.dart'; import 'package:stackwallet/services/exchange/trocador/trocador_exchange.dart'; +import 'package:stackwallet/services/tor_service.dart'; import 'package:stackwallet/themes/stack_colors.dart'; import 'package:stackwallet/utilities/amount/amount_unit.dart'; import 'package:stackwallet/utilities/assets.dart'; import 'package:stackwallet/utilities/constants.dart'; import 'package:stackwallet/utilities/enums/coin_enum.dart'; import 'package:stackwallet/utilities/enums/exchange_rate_type_enum.dart'; +import 'package:stackwallet/utilities/prefs.dart'; import 'package:stackwallet/utilities/text_styles.dart'; import 'package:stackwallet/utilities/util.dart'; import 'package:stackwallet/widgets/conditional_parent.dart'; @@ -55,8 +59,6 @@ import 'package:stackwallet/widgets/textfields/exchange_textfield.dart'; import 'package:tuple/tuple.dart'; import 'package:uuid/uuid.dart'; -import '../../services/exchange/exchange_response.dart'; - class ExchangeForm extends ConsumerStatefulWidget { const ExchangeForm({ Key? key, @@ -78,7 +80,7 @@ class _ExchangeFormState extends ConsumerState { late final Coin? coin; late final bool walletInitiated; - final exchanges = [ + var exchanges = [ MajesticBankExchange.instance, ChangeNowExchange.instance, TrocadorExchange.instance, @@ -773,6 +775,14 @@ class _ExchangeFormState extends ConsumerState { }); } + // Instantiate the Tor service. + torService = TorService.sharedInstance; + + // Filter exchanges based on Tor support. + if (Prefs.instance.useTor) { + exchanges = Exchange.exchangesWithTorSupport; + } + super.initState(); } @@ -1007,4 +1017,7 @@ class _ExchangeFormState extends ConsumerState { ], ); } + + // TorService instance. + late TorService torService; } diff --git a/lib/pages/exchange_view/exchange_step_views/step_4_view.dart b/lib/pages/exchange_view/exchange_step_views/step_4_view.dart index 25967801a..d491899f8 100644 --- a/lib/pages/exchange_view/exchange_step_views/step_4_view.dart +++ b/lib/pages/exchange_view/exchange_step_views/step_4_view.dart @@ -252,10 +252,17 @@ class _Step4ViewState extends ConsumerState { }, ); } else { + final memo = + manager.coin == Coin.stellar || manager.coin == Coin.stellarTestnet + ? model.trade!.payInExtraId.isNotEmpty + ? model.trade!.payInExtraId + : null + : null; txDataFuture = manager.prepareSend( address: address, amount: amount, args: { + "memo": memo, "feeRate": FeeRateType.average, // ref.read(feeRateTypeStateProvider) }, @@ -568,6 +575,74 @@ class _Step4ViewState extends ConsumerState { const SizedBox( height: 6, ), + if (model.trade!.payInExtraId.isNotEmpty) + RoundedWhiteContainer( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Row( + mainAxisAlignment: + MainAxisAlignment.spaceBetween, + children: [ + Text( + "Memo", + style: + STextStyles.itemSubtitle(context), + ), + GestureDetector( + onTap: () async { + final data = ClipboardData( + text: + model.trade!.payInExtraId); + await clipboard.setData(data); + if (mounted) { + unawaited( + showFloatingFlushBar( + type: FlushBarType.info, + message: + "Copied to clipboard", + context: context, + ), + ); + } + }, + child: Row( + children: [ + SvgPicture.asset( + Assets.svg.copy, + color: Theme.of(context) + .extension()! + .infoItemIcons, + width: 10, + ), + const SizedBox( + width: 4, + ), + Text( + "Copy", + style: + STextStyles.link2(context), + ), + ], + ), + ), + ], + ), + const SizedBox( + height: 4, + ), + Text( + model.trade!.payInExtraId, + style: + STextStyles.itemSubtitle12(context), + ), + ], + ), + ), + if (model.trade!.payInExtraId.isNotEmpty) + const SizedBox( + height: 6, + ), RoundedWhiteContainer( child: Row( children: [ diff --git a/lib/pages/exchange_view/send_from_view.dart b/lib/pages/exchange_view/send_from_view.dart index 4935a1b20..68b595900 100644 --- a/lib/pages/exchange_view/send_from_view.dart +++ b/lib/pages/exchange_view/send_from_view.dart @@ -268,10 +268,17 @@ class _SendFromCardState extends ConsumerState { // if not firo then do normal send if (shouldSendPublicFiroFunds == null) { + final memo = + manager.coin == Coin.stellar || manager.coin == Coin.stellarTestnet + ? trade.payInExtraId.isNotEmpty + ? trade.payInExtraId + : null + : null; txDataFuture = manager.prepareSend( address: address, amount: amount, args: { + "memo": memo, "feeRate": FeeRateType.average, // ref.read(feeRateTypeStateProvider) }, diff --git a/lib/pages/exchange_view/sub_widgets/exchange_provider_options.dart b/lib/pages/exchange_view/sub_widgets/exchange_provider_options.dart index 13330e2f9..6f0108f66 100644 --- a/lib/pages/exchange_view/sub_widgets/exchange_provider_options.dart +++ b/lib/pages/exchange_view/sub_widgets/exchange_provider_options.dart @@ -14,9 +14,11 @@ import 'package:stackwallet/models/exchange/aggregate_currency.dart'; import 'package:stackwallet/pages/exchange_view/sub_widgets/exchange_provider_option.dart'; import 'package:stackwallet/providers/providers.dart'; import 'package:stackwallet/services/exchange/change_now/change_now_exchange.dart'; +import 'package:stackwallet/services/exchange/exchange.dart'; import 'package:stackwallet/services/exchange/majestic_bank/majestic_bank_exchange.dart'; import 'package:stackwallet/services/exchange/trocador/trocador_exchange.dart'; import 'package:stackwallet/themes/stack_colors.dart'; +import 'package:stackwallet/utilities/prefs.dart'; import 'package:stackwallet/utilities/util.dart'; import 'package:stackwallet/widgets/rounded_white_container.dart'; @@ -44,6 +46,13 @@ class _ExchangeProviderOptionsState required AggregateCurrency? sendCurrency, required AggregateCurrency? receiveCurrency, }) { + // If using Tor, only allow exchanges that support it. + if (Prefs.instance.useTor) { + if (!Exchange.exchangeNamesWithTorSupport.contains(exchangeName)) { + return false; + } + } + final send = sendCurrency?.forExchange(exchangeName); if (send == null) return false; diff --git a/lib/pages/exchange_view/trade_details_view.dart b/lib/pages/exchange_view/trade_details_view.dart index ff9b7ae24..24208a19c 100644 --- a/lib/pages/exchange_view/trade_details_view.dart +++ b/lib/pages/exchange_view/trade_details_view.dart @@ -850,6 +850,81 @@ class _TradeDetailsViewState extends ConsumerState { : const SizedBox( height: 12, ), + if (trade.payInExtraId.isNotEmpty && !sentFromStack && !hasTx) + RoundedWhiteContainer( + padding: isDesktop + ? const EdgeInsets.all(16) + : const EdgeInsets.all(12), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text( + "Memo", + style: STextStyles.itemSubtitle(context), + ), + isDesktop + ? IconCopyButton( + data: trade.payInExtraId, + ) + : GestureDetector( + onTap: () async { + final address = trade.payInExtraId; + await Clipboard.setData( + ClipboardData( + text: address, + ), + ); + if (mounted) { + unawaited( + showFloatingFlushBar( + type: FlushBarType.info, + message: "Copied to clipboard", + context: context, + ), + ); + } + }, + child: Row( + children: [ + SvgPicture.asset( + Assets.svg.copy, + width: 12, + height: 12, + color: Theme.of(context) + .extension()! + .infoItemIcons, + ), + const SizedBox( + width: 4, + ), + Text( + "Copy", + style: STextStyles.link2(context), + ), + ], + ), + ), + ], + ), + const SizedBox( + height: 4, + ), + SelectableText( + trade.payInExtraId, + style: STextStyles.itemSubtitle12(context), + ), + ], + ), + ), + if (trade.payInExtraId.isNotEmpty && !sentFromStack && !hasTx) + isDesktop + ? const _Divider() + : const SizedBox( + height: 12, + ), RoundedWhiteContainer( padding: isDesktop ? const EdgeInsets.all(16) diff --git a/lib/pages/home_view/home_view.dart b/lib/pages/home_view/home_view.dart index c3cad7a97..2303333e1 100644 --- a/lib/pages/home_view/home_view.dart +++ b/lib/pages/home_view/home_view.dart @@ -24,6 +24,7 @@ import 'package:stackwallet/pages/wallets_view/wallets_view.dart'; import 'package:stackwallet/providers/global/notifications_provider.dart'; import 'package:stackwallet/providers/ui/home_view_index_provider.dart'; import 'package:stackwallet/providers/ui/unread_notifications_provider.dart'; +import 'package:stackwallet/services/event_bus/events/global/tor_connection_status_changed_event.dart'; import 'package:stackwallet/themes/stack_colors.dart'; import 'package:stackwallet/themes/theme_providers.dart'; import 'package:stackwallet/utilities/assets.dart'; @@ -32,6 +33,7 @@ import 'package:stackwallet/utilities/text_styles.dart'; import 'package:stackwallet/widgets/animated_widgets/rotate_icon.dart'; import 'package:stackwallet/widgets/background.dart'; import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart'; +import 'package:stackwallet/widgets/small_tor_icon.dart'; import 'package:stackwallet/widgets/stack_dialog.dart'; class HomeView extends ConsumerStatefulWidget { @@ -55,6 +57,8 @@ class _HomeViewState extends ConsumerState { bool _exitEnabled = false; + late TorConnectionStatus _currentSyncStatus; + // final _buyDataLoadingService = BuyDataLoadingService(); Future _onWillPop() async { @@ -125,6 +129,20 @@ class _HomeViewState extends ConsumerState { ref.read(notificationsProvider).startCheckingWatchedNotifications(); + /// todo change to watch tor network + // if (ref.read(managerProvider).isRefreshing) { + // _currentSyncStatus = WalletSyncStatus.syncing; + // _currentNodeStatus = NodeConnectionStatus.connected; + // } else { + // _currentSyncStatus = WalletSyncStatus.synced; + // if (ref.read(managerProvider).isConnected) { + // _currentNodeStatus = NodeConnectionStatus.connected; + // } else { + // _currentNodeStatus = NodeConnectionStatus.disconnected; + // _currentSyncStatus = WalletSyncStatus.unableToSync; + // } + // } + super.initState(); } @@ -200,6 +218,17 @@ class _HomeViewState extends ConsumerState { ], ), actions: [ + const Padding( + padding: EdgeInsets.only( + top: 10, + bottom: 10, + right: 10, + ), + child: AspectRatio( + aspectRatio: 1, + child: SmallTorIcon(), + ), + ), Padding( padding: const EdgeInsets.only( top: 10, diff --git a/lib/pages/ordinals/ordinal_details_view.dart b/lib/pages/ordinals/ordinal_details_view.dart index 041401767..17a518bf9 100644 --- a/lib/pages/ordinals/ordinal_details_view.dart +++ b/lib/pages/ordinals/ordinal_details_view.dart @@ -5,20 +5,22 @@ import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/flutter_svg.dart'; -import 'package:http/http.dart'; import 'package:path_provider/path_provider.dart'; import 'package:permission_handler/permission_handler.dart'; import 'package:stackwallet/models/isar/models/blockchain_data/utxo.dart'; import 'package:stackwallet/models/isar/ordinal.dart'; +import 'package:stackwallet/networking/http.dart'; import 'package:stackwallet/notifications/show_flush_bar.dart'; import 'package:stackwallet/providers/db/main_db_provider.dart'; import 'package:stackwallet/providers/global/wallets_provider.dart'; +import 'package:stackwallet/services/tor_service.dart'; import 'package:stackwallet/themes/stack_colors.dart'; import 'package:stackwallet/utilities/amount/amount.dart'; import 'package:stackwallet/utilities/amount/amount_formatter.dart'; import 'package:stackwallet/utilities/assets.dart'; import 'package:stackwallet/utilities/constants.dart'; import 'package:stackwallet/utilities/enums/coin_enum.dart'; +import 'package:stackwallet/utilities/prefs.dart'; import 'package:stackwallet/utilities/show_loading.dart'; import 'package:stackwallet/utilities/text_styles.dart'; import 'package:stackwallet/widgets/background.dart'; @@ -230,11 +232,16 @@ class _OrdinalImageGroup extends StatelessWidget { static const _spacing = 12.0; Future _savePngToFile() async { - final response = await get(Uri.parse(ordinal.content)); + HTTP client = HTTP(); - if (response.statusCode != 200) { - throw Exception( - "statusCode=${response.statusCode} body=${response.bodyBytes}"); + final response = await client.get( + url: Uri.parse(ordinal.content), + proxyInfo: + Prefs.instance.useTor ? TorService.sharedInstance.proxyInfo : null, + ); + + if (response.code != 200) { + throw Exception("statusCode=${response.code} body=${response.bodyBytes}"); } final bytes = response.bodyBytes; diff --git a/lib/pages/receive_view/receive_view.dart b/lib/pages/receive_view/receive_view.dart index d77e0e244..480813fc9 100644 --- a/lib/pages/receive_view/receive_view.dart +++ b/lib/pages/receive_view/receive_view.dart @@ -307,14 +307,20 @@ class _ReceiveViewState extends ConsumerState { if (coin != Coin.epicCash && coin != Coin.ethereum && coin != Coin.banano && - coin != Coin.nano) + coin != Coin.nano && + coin != Coin.stellar && + coin != Coin.stellarTestnet && + coin != Coin.tezos) const SizedBox( height: 12, ), if (coin != Coin.epicCash && coin != Coin.ethereum && coin != Coin.banano && - coin != Coin.nano) + coin != Coin.nano && + coin != Coin.stellar && + coin != Coin.stellarTestnet && + coin != Coin.tezos) TextButton( onPressed: generateNewAddress, style: Theme.of(context) diff --git a/lib/pages/send_view/send_view.dart b/lib/pages/send_view/send_view.dart index c3e66e758..01131b536 100644 --- a/lib/pages/send_view/send_view.dart +++ b/lib/pages/send_view/send_view.dart @@ -103,6 +103,7 @@ class _SendViewState extends ConsumerState { late TextEditingController noteController; late TextEditingController onChainNoteController; late TextEditingController feeController; + late TextEditingController memoController; late final SendViewAutoFillData? _data; @@ -111,6 +112,9 @@ class _SendViewState extends ConsumerState { final _onChainNoteFocusNode = FocusNode(); final _cryptoFocus = FocusNode(); final _baseFocus = FocusNode(); + final _memoFocus = FocusNode(); + + late final bool isStellar; Amount? _amountToSend; Amount? _cachedAmountToSend; @@ -522,10 +526,15 @@ class _SendViewState extends ConsumerState { }, ); } else { + final memo = + manager.coin == Coin.stellar || manager.coin == Coin.stellarTestnet + ? memoController.text + : null; txDataFuture = manager.prepareSend( address: _address!, amount: amount, args: { + "memo": memo, "feeRate": ref.read(feeRateTypeStateProvider), "satsPerVByte": isCustomFee ? customFeeRate : null, "UTXOs": (manager.hasCoinControlSupport && @@ -622,6 +631,7 @@ class _SendViewState extends ConsumerState { walletId = widget.walletId; clipboard = widget.clipboard; scanner = widget.barcodeScanner; + isStellar = coin == Coin.stellar || coin == Coin.stellarTestnet; sendToController = TextEditingController(); cryptoAmountController = TextEditingController(); @@ -629,6 +639,7 @@ class _SendViewState extends ConsumerState { noteController = TextEditingController(); onChainNoteController = TextEditingController(); feeController = TextEditingController(); + memoController = TextEditingController(); onCryptoAmountChanged = _cryptoAmountChanged; cryptoAmountController.addListener(onCryptoAmountChanged); @@ -704,12 +715,14 @@ class _SendViewState extends ConsumerState { noteController.dispose(); onChainNoteController.dispose(); feeController.dispose(); + memoController.dispose(); _noteFocusNode.dispose(); _onChainNoteFocusNode.dispose(); _addressFocusNode.dispose(); _cryptoFocus.dispose(); _baseFocus.dispose(); + _memoFocus.dispose(); super.dispose(); } @@ -1298,6 +1311,88 @@ class _SendViewState extends ConsumerState { ), ), ), + const SizedBox( + height: 10, + ), + if (isStellar) + ClipRRect( + borderRadius: BorderRadius.circular( + Constants.size.circularBorderRadius, + ), + child: TextField( + key: const Key("sendViewMemoFieldKey"), + controller: memoController, + readOnly: false, + autocorrect: false, + enableSuggestions: false, + focusNode: _memoFocus, + style: STextStyles.field(context), + onChanged: (_) { + setState(() {}); + }, + decoration: standardInputDecoration( + "Enter memo (optional)", + _memoFocus, + context, + ).copyWith( + contentPadding: const EdgeInsets.only( + left: 16, + top: 6, + bottom: 8, + right: 5, + ), + suffixIcon: Padding( + padding: memoController.text.isEmpty + ? const EdgeInsets.only(right: 8) + : const EdgeInsets.only(right: 0), + child: UnconstrainedBox( + child: Row( + mainAxisAlignment: + MainAxisAlignment.spaceAround, + children: [ + memoController.text.isNotEmpty + ? TextFieldIconButton( + semanticsLabel: + "Clear Button. Clears The Memo Field Input.", + key: const Key( + "sendViewClearMemoFieldButtonKey"), + onTap: () { + memoController.text = ""; + setState(() {}); + }, + child: const XIcon(), + ) + : TextFieldIconButton( + semanticsLabel: + "Paste Button. Pastes From Clipboard To Memo Field Input.", + key: const Key( + "sendViewPasteMemoFieldButtonKey"), + onTap: () async { + final ClipboardData? data = + await clipboard.getData( + Clipboard + .kTextPlain); + if (data?.text != null && + data! + .text!.isNotEmpty) { + String content = + data.text!.trim(); + + memoController.text = + content.trim(); + + setState(() {}); + } + }, + child: const ClipboardIcon(), + ), + ], + ), + ), + ), + ), + ), + ), Builder( builder: (_) { final error = _updateInvalidAddressText( @@ -1817,7 +1912,8 @@ class _SendViewState extends ConsumerState { ), child: TextField( autocorrect: Util.isDesktop ? false : true, - enableSuggestions: Util.isDesktop ? false : true, + enableSuggestions: + Util.isDesktop ? false : true, maxLength: 256, controller: onChainNoteController, focusNode: _onChainNoteFocusNode, @@ -1828,25 +1924,27 @@ class _SendViewState extends ConsumerState { _onChainNoteFocusNode, context, ).copyWith( - suffixIcon: onChainNoteController.text.isNotEmpty + suffixIcon: onChainNoteController + .text.isNotEmpty ? Padding( - padding: - const EdgeInsets.only(right: 0), - child: UnconstrainedBox( - child: Row( - children: [ - TextFieldIconButton( - child: const XIcon(), - onTap: () async { - setState(() { - onChainNoteController.text = ""; - }); - }, + padding: + const EdgeInsets.only(right: 0), + child: UnconstrainedBox( + child: Row( + children: [ + TextFieldIconButton( + child: const XIcon(), + onTap: () async { + setState(() { + onChainNoteController + .text = ""; + }); + }, + ), + ], + ), ), - ], - ), - ), - ) + ) : null, ), ), @@ -1856,8 +1954,9 @@ class _SendViewState extends ConsumerState { height: 12, ), Text( - (coin == Coin.epicCash) ? "Local Note (optional)" - : "Note (optional)", + (coin == Coin.epicCash) + ? "Local Note (optional)" + : "Note (optional)", style: STextStyles.smallMed12(context), textAlign: TextAlign.left, ), diff --git a/lib/pages/settings_views/global_settings_view/about_view.dart b/lib/pages/settings_views/global_settings_view/about_view.dart index 5daa1e81a..0d3e8d811 100644 --- a/lib/pages/settings_views/global_settings_view/about_view.dart +++ b/lib/pages/settings_views/global_settings_view/about_view.dart @@ -15,11 +15,13 @@ import 'package:flutter/material.dart'; import 'package:flutter_libepiccash/git_versions.dart' as EPIC_VERSIONS; import 'package:flutter_libmonero/git_versions.dart' as MONERO_VERSIONS; import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:http/http.dart'; import 'package:lelantus/git_versions.dart' as FIRO_VERSIONS; import 'package:package_info_plus/package_info_plus.dart'; +import 'package:stackwallet/networking/http.dart'; +import 'package:stackwallet/services/tor_service.dart'; import 'package:stackwallet/themes/stack_colors.dart'; import 'package:stackwallet/utilities/logger.dart'; +import 'package:stackwallet/utilities/prefs.dart'; import 'package:stackwallet/utilities/text_styles.dart'; import 'package:stackwallet/widgets/background.dart'; import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart'; @@ -39,14 +41,17 @@ Future doesCommitExist( String commit, ) async { Logging.instance.log("doesCommitExist", level: LogLevel.Info); - final Client client = Client(); + // final Client client = Client(); + HTTP client = HTTP(); try { final uri = Uri.parse( "$kGithubAPI$kGithubHead/$organization/$project/commits/$commit"); final commitQuery = await client.get( - uri, + url: uri, headers: {'Content-Type': 'application/json'}, + proxyInfo: + Prefs.instance.useTor ? TorService.sharedInstance.proxyInfo : null, ); final response = jsonDecode(commitQuery.body.toString()); @@ -76,14 +81,16 @@ Future isHeadCommit( String commit, ) async { Logging.instance.log("doesCommitExist", level: LogLevel.Info); - final Client client = Client(); + HTTP client = HTTP(); try { final uri = Uri.parse( "$kGithubAPI$kGithubHead/$organization/$project/commits/$branch"); final commitQuery = await client.get( - uri, + url: uri, headers: {'Content-Type': 'application/json'}, + proxyInfo: + Prefs.instance.useTor ? TorService.sharedInstance.proxyInfo : null, ); final response = jsonDecode(commitQuery.body.toString()); diff --git a/lib/pages/settings_views/global_settings_view/global_settings_view.dart b/lib/pages/settings_views/global_settings_view/global_settings_view.dart index 7cadc1a77..29984b928 100644 --- a/lib/pages/settings_views/global_settings_view/global_settings_view.dart +++ b/lib/pages/settings_views/global_settings_view/global_settings_view.dart @@ -25,6 +25,7 @@ import 'package:stackwallet/pages/settings_views/global_settings_view/stack_back import 'package:stackwallet/pages/settings_views/global_settings_view/startup_preferences/startup_preferences_view.dart'; import 'package:stackwallet/pages/settings_views/global_settings_view/support_view.dart'; import 'package:stackwallet/pages/settings_views/global_settings_view/syncing_preferences_views/syncing_preferences_view.dart'; +import 'package:stackwallet/pages/settings_views/global_settings_view/tor_settings/tor_settings_view.dart'; import 'package:stackwallet/pages/settings_views/sub_widgets/settings_list_button.dart'; import 'package:stackwallet/route_generator.dart'; import 'package:stackwallet/themes/stack_colors.dart'; @@ -159,6 +160,18 @@ class GlobalSettingsView extends StatelessWidget { const SizedBox( height: 8, ), + SettingsListButton( + iconAssetName: Assets.svg.tor, + iconSize: 18, + title: "Tor Settings", + onPressed: () { + Navigator.of(context) + .pushNamed(TorSettingsView.routeName); + }, + ), + const SizedBox( + height: 8, + ), SettingsListButton( iconAssetName: Assets.svg.node, iconSize: 16, diff --git a/lib/pages/settings_views/global_settings_view/hidden_settings.dart b/lib/pages/settings_views/global_settings_view/hidden_settings.dart index 4e42e3733..52a523f22 100644 --- a/lib/pages/settings_views/global_settings_view/hidden_settings.dart +++ b/lib/pages/settings_views/global_settings_view/hidden_settings.dart @@ -167,77 +167,77 @@ class HiddenSettings extends StatelessWidget { // ), // ); // }), - const SizedBox( - height: 12, - ), - Consumer(builder: (_, ref, __) { - return GestureDetector( - onTap: () async { - ref - .read(priceAnd24hChangeNotifierProvider) - .tokenContractAddressesToCheck - .add( - "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"); - ref - .read(priceAnd24hChangeNotifierProvider) - .tokenContractAddressesToCheck - .add( - "0xdAC17F958D2ee523a2206206994597C13D831ec7"); - await ref - .read(priceAnd24hChangeNotifierProvider) - .updatePrice(); - - final x = ref - .read(priceAnd24hChangeNotifierProvider) - .getTokenPrice( - "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"); - - print( - "PRICE 0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48: $x"); - }, - child: RoundedWhiteContainer( - child: Text( - "Click me", - style: STextStyles.button(context).copyWith( - color: Theme.of(context) - .extension()! - .accentColorDark), - ), - ), - ); - }), - const SizedBox( - height: 12, - ), - Consumer(builder: (_, ref, __) { - return GestureDetector( - onTap: () async { - // final erc20 = Erc20ContractInfo( - // contractAddress: 'some con', - // name: "loonamsn", - // symbol: "DD", - // decimals: 19, - // ); - // - // final json = erc20.toJson(); - // - // print(json); - // - // final ee = EthContractInfo.fromJson(json); - // - // print(ee); - }, - child: RoundedWhiteContainer( - child: Text( - "Click me", - style: STextStyles.button(context).copyWith( - color: Theme.of(context) - .extension()! - .accentColorDark), - ), - ), - ); - }), + // const SizedBox( + // height: 12, + // ), + // Consumer(builder: (_, ref, __) { + // return GestureDetector( + // onTap: () async { + // ref + // .read(priceAnd24hChangeNotifierProvider) + // .tokenContractAddressesToCheck + // .add( + // "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"); + // ref + // .read(priceAnd24hChangeNotifierProvider) + // .tokenContractAddressesToCheck + // .add( + // "0xdAC17F958D2ee523a2206206994597C13D831ec7"); + // await ref + // .read(priceAnd24hChangeNotifierProvider) + // .updatePrice(); + // + // final x = ref + // .read(priceAnd24hChangeNotifierProvider) + // .getTokenPrice( + // "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"); + // + // print( + // "PRICE 0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48: $x"); + // }, + // child: RoundedWhiteContainer( + // child: Text( + // "Click me", + // style: STextStyles.button(context).copyWith( + // color: Theme.of(context) + // .extension()! + // .accentColorDark), + // ), + // ), + // ); + // }), + // const SizedBox( + // height: 12, + // ), + // Consumer(builder: (_, ref, __) { + // return GestureDetector( + // onTap: () async { + // // final erc20 = Erc20ContractInfo( + // // contractAddress: 'some con', + // // name: "loonamsn", + // // symbol: "DD", + // // decimals: 19, + // // ); + // // + // // final json = erc20.toJson(); + // // + // // print(json); + // // + // // final ee = EthContractInfo.fromJson(json); + // // + // // print(ee); + // }, + // child: RoundedWhiteContainer( + // child: Text( + // "Click me", + // style: STextStyles.button(context).copyWith( + // color: Theme.of(context) + // .extension()! + // .accentColorDark), + // ), + // ), + // ); + // }), const SizedBox( height: 12, ), diff --git a/lib/pages/settings_views/global_settings_view/manage_nodes_views/add_edit_node_view.dart b/lib/pages/settings_views/global_settings_view/manage_nodes_views/add_edit_node_view.dart index 56b008093..2bb833fd1 100644 --- a/lib/pages/settings_views/global_settings_view/manage_nodes_views/add_edit_node_view.dart +++ b/lib/pages/settings_views/global_settings_view/manage_nodes_views/add_edit_node_view.dart @@ -27,6 +27,7 @@ import 'package:stackwallet/utilities/flutter_secure_storage_interface.dart'; import 'package:stackwallet/utilities/logger.dart'; import 'package:stackwallet/utilities/test_epic_box_connection.dart'; import 'package:stackwallet/utilities/test_monero_node_connection.dart'; +import 'package:stackwallet/utilities/test_stellar_node_connection.dart'; import 'package:stackwallet/utilities/text_styles.dart'; import 'package:stackwallet/utilities/util.dart'; import 'package:stackwallet/widgets/background.dart'; @@ -193,13 +194,20 @@ class _AddEditNodeViewState extends ConsumerState { try { // await client.getSyncStatus(); } catch (_) {} + break; + case Coin.stellar: + case Coin.stellarTestnet: + try { + testPassed = + await testStellarNodeConnection(formData.host!, formData.port!); + } catch (_) {} + break; case Coin.nano: case Coin.banano: - case Coin.stellar: - case Coin.stellarTestnet: + case Coin.tezos: throw UnimplementedError(); - //TODO: check network/node + //TODO: check network/node } if (showFlushBar && mounted) { @@ -730,6 +738,7 @@ class _NodeFormState extends ConsumerState { case Coin.namecoin: case Coin.bitcoincash: case Coin.particl: + case Coin.tezos: case Coin.bitcoinTestNet: case Coin.litecoinTestNet: case Coin.bitcoincashTestnet: diff --git a/lib/pages/settings_views/global_settings_view/manage_nodes_views/node_details_view.dart b/lib/pages/settings_views/global_settings_view/manage_nodes_views/node_details_view.dart index 59ff1efad..c05cbbca5 100644 --- a/lib/pages/settings_views/global_settings_view/manage_nodes_views/node_details_view.dart +++ b/lib/pages/settings_views/global_settings_view/manage_nodes_views/node_details_view.dart @@ -26,6 +26,7 @@ import 'package:stackwallet/utilities/logger.dart'; import 'package:stackwallet/utilities/test_epic_box_connection.dart'; import 'package:stackwallet/utilities/test_eth_node_connection.dart'; import 'package:stackwallet/utilities/test_monero_node_connection.dart'; +import 'package:stackwallet/utilities/test_stellar_node_connection.dart'; import 'package:stackwallet/utilities/text_styles.dart'; import 'package:stackwallet/utilities/util.dart'; import 'package:stackwallet/widgets/background.dart'; @@ -172,10 +173,17 @@ class _NodeDetailsViewState extends ConsumerState { case Coin.nano: case Coin.banano: + case Coin.tezos: + throw UnimplementedError(); + //TODO: check network/node case Coin.stellar: case Coin.stellarTestnet: - throw UnimplementedError(); - //TODO: check network/node + try { + testPassed = await testStellarNodeConnection(node!.host, node.port); + } catch (_) { + testPassed = false; + } + break; } if (testPassed) { diff --git a/lib/pages/settings_views/global_settings_view/tor_settings/tor_settings_view.dart b/lib/pages/settings_views/global_settings_view/tor_settings/tor_settings_view.dart new file mode 100644 index 000000000..097a68b93 --- /dev/null +++ b/lib/pages/settings_views/global_settings_view/tor_settings/tor_settings_view.dart @@ -0,0 +1,499 @@ +/* + * This file is part of Stack Wallet. + * + * Copyright (c) 2023 Cypher Stack + * All Rights Reserved. + * The code is distributed under GPLv3 license, see LICENSE file for details. + * Generated by Cypher Stack on 2023-05-26 + * + */ + +import 'dart:async'; + +import 'package:flutter/material.dart'; +import 'package:flutter_riverpod/flutter_riverpod.dart'; +import 'package:flutter_svg/flutter_svg.dart'; +import 'package:stackwallet/providers/global/prefs_provider.dart'; +import 'package:stackwallet/services/event_bus/events/global/tor_connection_status_changed_event.dart'; +import 'package:stackwallet/services/tor_service.dart'; +import 'package:stackwallet/themes/stack_colors.dart'; +import 'package:stackwallet/utilities/assets.dart'; +import 'package:stackwallet/utilities/constants.dart'; +import 'package:stackwallet/utilities/logger.dart'; +import 'package:stackwallet/utilities/text_styles.dart'; +import 'package:stackwallet/widgets/background.dart'; +import 'package:stackwallet/widgets/conditional_parent.dart'; +import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart'; +import 'package:stackwallet/widgets/custom_buttons/draggable_switch_button.dart'; +import 'package:stackwallet/widgets/desktop/secondary_button.dart'; +import 'package:stackwallet/widgets/rounded_white_container.dart'; +import 'package:stackwallet/widgets/stack_dialog.dart'; +import 'package:stackwallet/widgets/tor_subscription.dart'; + +class TorSettingsView extends ConsumerStatefulWidget { + const TorSettingsView({Key? key}) : super(key: key); + + static const String routeName = "/torSettings"; + + @override + ConsumerState createState() => _TorSettingsViewState(); +} + +class _TorSettingsViewState extends ConsumerState { + @override + Widget build(BuildContext context) { + return Background( + child: Scaffold( + backgroundColor: Colors.transparent, + appBar: AppBar( + automaticallyImplyLeading: false, + backgroundColor: + Theme.of(context).extension()!.backgroundAppBar, + leading: AppBarBackButton( + onPressed: () { + Navigator.of(context).pop(); + }, + ), + title: Text( + "Tor settings", + style: STextStyles.navBarTitle(context), + ), + actions: [ + AspectRatio( + aspectRatio: 1, + child: AppBarIconButton( + icon: SvgPicture.asset( + Assets.svg.circleQuestion, + ), + onPressed: () { + showDialog( + context: context, + useSafeArea: false, + barrierDismissible: true, + builder: (context) { + return const StackDialog( + title: "What is Tor?", + message: + "Short for \"The Onion Router\", is an open-source software that enables internet communication" + " to remain anonymous by routing internet traffic through a series of layered nodes," + " to obscure the origin and destination of data.", + rightButton: SecondaryButton( + label: "Close", + ), + ); + }, + ); + }, + ), + ), + ], + ), + body: Padding( + padding: const EdgeInsets.symmetric(horizontal: 16.0), + child: Column( + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + const Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Padding( + padding: EdgeInsets.all(10.0), + child: TorIcon(), + ), + ], + ), + const SizedBox( + height: 30, + ), + const TorButton(), + const SizedBox( + height: 8, + ), + RoundedWhiteContainer( + child: Consumer( + builder: (_, ref, __) { + return RawMaterialButton( + // splashColor: Theme.of(context).extension()!.highlight, + materialTapTargetSize: MaterialTapTargetSize.shrinkWrap, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular( + Constants.size.circularBorderRadius, + ), + ), + onPressed: null, + child: Padding( + padding: const EdgeInsets.symmetric(vertical: 8), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Row( + children: [ + Text( + "Tor killswitch", + style: STextStyles.titleBold12(context), + ), + const SizedBox(width: 8), + GestureDetector( + onTap: () { + showDialog( + context: context, + useSafeArea: false, + barrierDismissible: true, + builder: (context) { + return const StackDialog( + title: "What is Tor killswitch?", + message: + "A security feature that protects your information from accidental exposure by" + " disconnecting your device from the Tor network if the" + " connection is disrupted or compromised.", + rightButton: SecondaryButton( + label: "Close", + ), + ); + }, + ); + }, + child: SvgPicture.asset( + Assets.svg.circleInfo, + height: 16, + width: 16, + color: Theme.of(context) + .extension()! + .infoItemLabel, + ), + ), + ], + ), + SizedBox( + height: 20, + width: 40, + child: DraggableSwitchButton( + isOn: ref.watch( + prefsChangeNotifierProvider + .select((value) => value.torKillSwitch), + ), + onValueChanged: (newValue) { + ref + .read(prefsChangeNotifierProvider) + .torKillSwitch = newValue; + }, + ), + ), + ], + ), + ), + ); + }, + ), + ), + ], + ), + ), + ), + ); + } +} + +class TorIcon extends ConsumerStatefulWidget { + const TorIcon({super.key}); + + @override + ConsumerState createState() => _TorIconState(); +} + +class _TorIconState extends ConsumerState { + late TorConnectionStatus _status; + + Color _color( + TorConnectionStatus status, + StackColors colors, + ) { + switch (status) { + case TorConnectionStatus.disconnected: + return colors.textSubtitle3; + + case TorConnectionStatus.connected: + return colors.accentColorGreen; + + case TorConnectionStatus.connecting: + return colors.accentColorYellow; + } + } + + String _label( + TorConnectionStatus status, + StackColors colors, + ) { + switch (status) { + case TorConnectionStatus.disconnected: + return "CONNECT"; + + case TorConnectionStatus.connected: + return "STOP"; + + case TorConnectionStatus.connecting: + return "CONNECTING"; + } + } + + bool _tapLock = false; + + Future onTap() async { + if (_tapLock) { + return; + } + _tapLock = true; + try { + // Connect or disconnect when the user taps the status. + switch (_status) { + case TorConnectionStatus.disconnected: + await _connectTor(ref, context); + break; + + case TorConnectionStatus.connected: + await _disconnectTor(ref, context); + + break; + + case TorConnectionStatus.connecting: + // Do nothing. + break; + } + } catch (_) { + // any exceptions should already be handled with error dialogs + // this try catch is just extra protection to ensure _tapLock gets reset + // in the finally block in the event of an unknown error + } finally { + _tapLock = false; + } + } + + @override + void initState() { + _status = ref.read(pTorService).enabled + ? TorConnectionStatus.connected + : TorConnectionStatus.disconnected; + + super.initState(); + } + + @override + Widget build(BuildContext context) { + return TorSubscription( + onTorStatusChanged: (status) { + setState(() { + _status = status; + }); + }, + child: ConditionalParent( + condition: _status != TorConnectionStatus.connecting, + builder: (child) => GestureDetector( + onTap: onTap, + child: child, + ), + child: SizedBox( + width: 220, + height: 220, + child: Stack( + alignment: AlignmentDirectional.center, + children: [ + SvgPicture.asset( + Assets.svg.tor, + color: _color( + _status, + Theme.of(context).extension()!, + ), + width: 200, + height: 200, + ), + Text( + _label( + _status, + Theme.of(context).extension()!, + ), + style: STextStyles.smallMed14(context).copyWith( + color: Theme.of(context).extension()!.popupBG, + ), + ), + ], + ), + ), + ), + ); + } +} + +class TorButton extends ConsumerStatefulWidget { + const TorButton({super.key}); + + @override + ConsumerState createState() => _TorButtonState(); +} + +class _TorButtonState extends ConsumerState { + late TorConnectionStatus _status; + + Color _color( + TorConnectionStatus status, + StackColors colors, + ) { + switch (status) { + case TorConnectionStatus.disconnected: + return colors.textSubtitle3; + + case TorConnectionStatus.connected: + return colors.accentColorGreen; + + case TorConnectionStatus.connecting: + return colors.accentColorYellow; + } + } + + String _label( + TorConnectionStatus status, + StackColors colors, + ) { + switch (status) { + case TorConnectionStatus.disconnected: + return "Disconnected"; + + case TorConnectionStatus.connected: + return "Connected"; + + case TorConnectionStatus.connecting: + return "Connecting"; + } + } + + bool _tapLock = false; + + Future onTap() async { + if (_tapLock) { + return; + } + _tapLock = true; + try { + // Connect or disconnect when the user taps the status. + switch (_status) { + case TorConnectionStatus.disconnected: + await _connectTor(ref, context); + break; + + case TorConnectionStatus.connected: + await _disconnectTor(ref, context); + + break; + + case TorConnectionStatus.connecting: + // Do nothing. + break; + } + } catch (_) { + // any exceptions should already be handled with error dialogs + // this try catch is just extra protection to ensure _tapLock gets reset + // in the finally block in the event of an unknown error + } finally { + _tapLock = false; + } + } + + @override + void initState() { + _status = ref.read(pTorService).enabled + ? TorConnectionStatus.connected + : TorConnectionStatus.disconnected; + + super.initState(); + } + + @override + Widget build(BuildContext context) { + return TorSubscription( + onTorStatusChanged: (status) { + setState(() { + _status = status; + }); + }, + child: GestureDetector( + onTap: onTap, + child: RoundedWhiteContainer( + child: Padding( + padding: const EdgeInsets.symmetric(vertical: 8.0), + child: Row( + children: [ + Text( + "Tor status", + style: STextStyles.titleBold12(context), + ), + const Spacer(), + Text( + _label( + _status, + Theme.of(context).extension()!, + ), + style: STextStyles.itemSubtitle(context).copyWith( + color: _color( + _status, + Theme.of(context).extension()!, + ), + ), + ), + ], + ), + ), + ), + ), + ); + } +} + +/// Connect to the Tor network. +/// +/// This method is called when the user taps the "Connect" button. +/// +/// Throws an exception if the Tor service fails to start. +/// +/// Returns a Future that completes when the Tor service has started. +Future _connectTor(WidgetRef ref, BuildContext context) async { + // Init the Tor service if it hasn't already been. + ref.read(pTorService).init(); + + // Start the Tor service. + try { + await ref.read(pTorService).start(); + + // Toggle the useTor preference on success. + ref.read(prefsChangeNotifierProvider).useTor = true; + } catch (e, s) { + Logging.instance.log( + "Error starting tor: $e\n$s", + level: LogLevel.Error, + ); + // TODO: show dialog with error message + } + + return; +} + +/// Disconnect from the Tor network. +/// +/// This method is called when the user taps the "Disconnect" button. +/// +/// Throws an exception if the Tor service fails to stop. +/// +/// Returns a Future that completes when the Tor service has stopped. +Future _disconnectTor(WidgetRef ref, BuildContext context) async { + // Stop the Tor service. + try { + await ref.read(pTorService).stop(); + + // Toggle the useTor preference on success. + ref.read(prefsChangeNotifierProvider).useTor = false; + } catch (e, s) { + Logging.instance.log( + "Error stopping tor: $e\n$s", + level: LogLevel.Error, + ); + // TODO: show dialog with error message + } +} diff --git a/lib/pages/settings_views/wallet_settings_view/wallet_network_settings_view/wallet_network_settings_view.dart b/lib/pages/settings_views/wallet_settings_view/wallet_network_settings_view/wallet_network_settings_view.dart index b447a53ee..48f805691 100644 --- a/lib/pages/settings_views/wallet_settings_view/wallet_network_settings_view/wallet_network_settings_view.dart +++ b/lib/pages/settings_views/wallet_settings_view/wallet_network_settings_view/wallet_network_settings_view.dart @@ -27,12 +27,15 @@ import 'package:stackwallet/services/coins/wownero/wownero_wallet.dart'; import 'package:stackwallet/services/event_bus/events/global/blocks_remaining_event.dart'; import 'package:stackwallet/services/event_bus/events/global/node_connection_status_changed_event.dart'; import 'package:stackwallet/services/event_bus/events/global/refresh_percent_changed_event.dart'; +import 'package:stackwallet/services/event_bus/events/global/tor_connection_status_changed_event.dart'; import 'package:stackwallet/services/event_bus/events/global/wallet_sync_status_changed_event.dart'; import 'package:stackwallet/services/event_bus/global_event_bus.dart'; +import 'package:stackwallet/services/tor_service.dart'; import 'package:stackwallet/themes/stack_colors.dart'; import 'package:stackwallet/utilities/assets.dart'; import 'package:stackwallet/utilities/constants.dart'; import 'package:stackwallet/utilities/enums/coin_enum.dart'; +import 'package:stackwallet/utilities/logger.dart'; import 'package:stackwallet/utilities/text_styles.dart'; import 'package:stackwallet/utilities/util.dart'; import 'package:stackwallet/widgets/animated_text.dart'; @@ -92,6 +95,13 @@ class _WalletNetworkSettingsViewState late int _blocksRemaining; bool _advancedIsExpanded = false; + /// The current status of the Tor connection. + late TorConnectionStatus _torConnectionStatus; + + /// The subscription to the TorConnectionStatusChangedEvent. + late final StreamSubscription + _torConnectionStatusSubscription; + Future _attemptRescan() async { if (!Platform.isLinux) await Wakelock.enable(); @@ -268,6 +278,25 @@ class _WalletNetworkSettingsViewState // } // }, // ); + + // Initialize the TorConnectionStatus. + _torConnectionStatus = ref.read(pTorService).enabled + ? TorConnectionStatus.connected + : TorConnectionStatus.disconnected; + + // Subscribe to the TorConnectionStatusChangedEvent. + _torConnectionStatusSubscription = + eventBus.on().listen( + (event) async { + // Rebuild the widget. + setState(() { + _torConnectionStatus = event.newStatus; + }); + + // TODO implement spinner or animations and control from here + }, + ); + super.initState(); } @@ -277,6 +306,7 @@ class _WalletNetworkSettingsViewState _syncStatusSubscription.cancel(); _refreshSubscription.cancel(); _blocksRemainingSubscription?.cancel(); + _torConnectionStatusSubscription.cancel(); super.dispose(); } @@ -340,92 +370,98 @@ class _WalletNetworkSettingsViewState style: STextStyles.navBarTitle(context), ), actions: [ - Padding( - padding: const EdgeInsets.only( - top: 10, - bottom: 10, - right: 10, - ), - child: AspectRatio( - aspectRatio: 1, - child: AppBarIconButton( - key: const Key( - "walletNetworkSettingsAddNewNodeViewButton"), - size: 36, - shadows: const [], - color: Theme.of(context) - .extension()! - .background, - icon: SvgPicture.asset( - Assets.svg.verticalEllipsis, + if (ref + .read(walletsChangeNotifierProvider) + .getManager(widget.walletId) + .coin != + Coin.epicCash) + Padding( + padding: const EdgeInsets.only( + top: 10, + bottom: 10, + right: 10, + ), + child: AspectRatio( + aspectRatio: 1, + child: AppBarIconButton( + key: const Key( + "walletNetworkSettingsAddNewNodeViewButton"), + size: 36, + shadows: const [], color: Theme.of(context) .extension()! - .accentColorDark, - width: 20, - height: 20, - ), - onPressed: () { - showDialog( - barrierColor: Colors.transparent, - barrierDismissible: true, - context: context, - builder: (_) { - return Stack( - children: [ - Positioned( - top: 9, - right: 10, - child: Container( - decoration: BoxDecoration( - color: Theme.of(context) - .extension()! - .popupBG, - borderRadius: BorderRadius.circular( - Constants.size.circularBorderRadius), - // boxShadow: [CFColors.standardBoxShadow], - boxShadow: const [], - ), - child: Column( - crossAxisAlignment: - CrossAxisAlignment.start, - children: [ - GestureDetector( - onTap: () { - Navigator.of(context).pop(); - showDialog( - context: context, - useSafeArea: false, - barrierDismissible: true, - builder: (context) { - return ConfirmFullRescanDialog( - onConfirm: _attemptRescan, - ); - }, - ); - }, - child: RoundedWhiteContainer( - child: Material( - color: Colors.transparent, - child: Text( - "Rescan blockchain", - style: - STextStyles.baseXS(context), + .background, + icon: SvgPicture.asset( + Assets.svg.verticalEllipsis, + color: Theme.of(context) + .extension()! + .accentColorDark, + width: 20, + height: 20, + ), + onPressed: () { + showDialog( + barrierColor: Colors.transparent, + barrierDismissible: true, + context: context, + builder: (_) { + return Stack( + children: [ + Positioned( + top: 9, + right: 10, + child: Container( + decoration: BoxDecoration( + color: Theme.of(context) + .extension()! + .popupBG, + borderRadius: BorderRadius.circular( + Constants + .size.circularBorderRadius), + // boxShadow: [CFColors.standardBoxShadow], + boxShadow: const [], + ), + child: Column( + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + GestureDetector( + onTap: () { + Navigator.of(context).pop(); + showDialog( + context: context, + useSafeArea: false, + barrierDismissible: true, + builder: (context) { + return ConfirmFullRescanDialog( + onConfirm: _attemptRescan, + ); + }, + ); + }, + child: RoundedWhiteContainer( + child: Material( + color: Colors.transparent, + child: Text( + "Rescan blockchain", + style: STextStyles.baseXS( + context), + ), ), ), ), - ), - ], + ], + ), ), ), - ), - ], - ); - }, - ); - }, + ], + ); + }, + ); + }, + ), ), ), - ), ], ), body: Padding( @@ -521,14 +557,6 @@ class _WalletNetworkSettingsViewState "Synchronized", style: STextStyles.w600_12(context), ), - Text( - "100%", - style: STextStyles.syncPercent(context).copyWith( - color: Theme.of(context) - .extension()! - .accentColorGreen, - ), - ), ], ), ), @@ -749,6 +777,161 @@ class _WalletNetworkSettingsViewState SizedBox( height: isDesktop ? 32 : 20, ), + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text( + "Tor status", + textAlign: TextAlign.left, + style: isDesktop + ? STextStyles.desktopTextExtraExtraSmall(context) + : STextStyles.smallMed12(context), + ), + if (ref.watch( + prefsChangeNotifierProvider.select((value) => value.useTor))) + GestureDetector( + onTap: () async { + // Stop the Tor service. + try { + await ref.read(pTorService).stop(); + + // Toggle the useTor preference on success. + ref.read(prefsChangeNotifierProvider).useTor = false; + } catch (e, s) { + Logging.instance.log( + "Error stopping tor: $e\n$s", + level: LogLevel.Error, + ); + } + }, + child: Text( + "Disconnect", + style: STextStyles.link2(context), + ), + ), + if (!ref.watch( + prefsChangeNotifierProvider.select((value) => value.useTor))) + GestureDetector( + onTap: () async { + // Init the Tor service if it hasn't already been. + ref.read(pTorService).init(); + + // Start the Tor service. + try { + await ref.read(pTorService).start(); + + // Toggle the useTor preference on success. + ref.read(prefsChangeNotifierProvider).useTor = true; + } catch (e, s) { + Logging.instance.log( + "Error starting tor: $e\n$s", + level: LogLevel.Error, + ); + } + }, + child: Text( + "Connect", + style: STextStyles.link2(context), + ), + ), + ], + ), + SizedBox( + height: isDesktop ? 12 : 9, + ), + RoundedWhiteContainer( + borderColor: isDesktop + ? Theme.of(context).extension()!.background + : null, + padding: + isDesktop ? const EdgeInsets.all(16) : const EdgeInsets.all(12), + child: Row( + children: [ + if (ref.watch(prefsChangeNotifierProvider + .select((value) => value.useTor))) + Container( + width: _iconSize, + height: _iconSize, + decoration: BoxDecoration( + color: Theme.of(context) + .extension()! + .accentColorGreen + .withOpacity(0.2), + borderRadius: BorderRadius.circular(_iconSize), + ), + child: Center( + child: SvgPicture.asset( + Assets.svg.tor, + height: isDesktop ? 19 : 14, + width: isDesktop ? 19 : 14, + color: Theme.of(context) + .extension()! + .accentColorGreen, + ), + ), + ), + if (!ref.watch(prefsChangeNotifierProvider + .select((value) => value.useTor))) + Container( + width: _iconSize, + height: _iconSize, + decoration: BoxDecoration( + color: Theme.of(context) + .extension()! + .textDark + .withOpacity(0.08), + borderRadius: BorderRadius.circular(_iconSize), + ), + child: Center( + child: SvgPicture.asset( + Assets.svg.tor, + height: isDesktop ? 19 : 14, + width: isDesktop ? 19 : 14, + color: Theme.of(context) + .extension()! + .textDark, + ), + ), + ), + SizedBox( + width: _boxPadding, + ), + Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + "Tor status", + style: STextStyles.desktopTextExtraExtraSmall(context) + .copyWith( + color: Theme.of(context) + .extension()! + .textDark, + ), + ), + if (_torConnectionStatus == TorConnectionStatus.connected) + Text( + "Connected", + style: STextStyles.desktopTextExtraExtraSmall(context), + ), + if (_torConnectionStatus == TorConnectionStatus.connecting) + Text( + "Connecting...", + style: STextStyles.desktopTextExtraExtraSmall(context), + ), + if (_torConnectionStatus == + TorConnectionStatus.disconnected) + Text( + "Disconnected", + style: STextStyles.desktopTextExtraExtraSmall(context), + ), + ], + ), + ], + ), + ), + SizedBox( + height: isDesktop ? 32 : 20, + ), Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ @@ -786,11 +969,21 @@ class _WalletNetworkSettingsViewState .select((value) => value.getManager(widget.walletId).coin)), popBackToRoute: WalletNetworkSettingsView.routeName, ), - if (isDesktop) + if (isDesktop && + ref + .read(walletsChangeNotifierProvider) + .getManager(widget.walletId) + .coin != + Coin.epicCash) const SizedBox( height: 32, ), - if (isDesktop) + if (isDesktop && + ref + .read(walletsChangeNotifierProvider) + .getManager(widget.walletId) + .coin != + Coin.epicCash) Padding( padding: const EdgeInsets.only( bottom: 12, @@ -806,7 +999,12 @@ class _WalletNetworkSettingsViewState ], ), ), - if (isDesktop) + if (isDesktop && + ref + .read(walletsChangeNotifierProvider) + .getManager(widget.walletId) + .coin != + Coin.epicCash) RoundedWhiteContainer( borderColor: isDesktop ? Theme.of(context).extension()!.background diff --git a/lib/pages/settings_views/wallet_settings_view/wallet_settings_view.dart b/lib/pages/settings_views/wallet_settings_view/wallet_settings_view.dart index 6b7e57bef..fcacc60d4 100644 --- a/lib/pages/settings_views/wallet_settings_view/wallet_settings_view.dart +++ b/lib/pages/settings_views/wallet_settings_view/wallet_settings_view.dart @@ -13,7 +13,6 @@ import 'dart:async'; import 'package:event_bus/event_bus.dart'; import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:stackwallet/db/hive/db.dart'; import 'package:stackwallet/models/epicbox_config_model.dart'; import 'package:stackwallet/notifications/show_flush_bar.dart'; import 'package:stackwallet/pages/address_book_views/address_book_view.dart'; @@ -37,14 +36,11 @@ import 'package:stackwallet/services/event_bus/global_event_bus.dart'; import 'package:stackwallet/themes/stack_colors.dart'; import 'package:stackwallet/utilities/assets.dart'; import 'package:stackwallet/utilities/enums/coin_enum.dart'; -import 'package:stackwallet/utilities/show_loading.dart'; import 'package:stackwallet/utilities/text_styles.dart'; import 'package:stackwallet/utilities/util.dart'; import 'package:stackwallet/widgets/background.dart'; import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart'; -import 'package:stackwallet/widgets/desktop/secondary_button.dart'; import 'package:stackwallet/widgets/rounded_white_container.dart'; -import 'package:stackwallet/widgets/stack_dialog.dart'; import 'package:tuple/tuple.dart'; /// [eventBus] should only be set during testing @@ -310,61 +306,6 @@ class _WalletSettingsViewState extends ConsumerState { ); }, ), - if (coin == Coin.firo) - const SizedBox( - height: 8, - ), - if (coin == Coin.firo) - Consumer( - builder: (_, ref, __) { - return SettingsListButton( - iconAssetName: Assets.svg.eye, - title: "Clear electrumx cache", - onPressed: () async { - String? result; - await showDialog( - useSafeArea: false, - barrierDismissible: true, - context: context, - builder: (_) => StackOkDialog( - title: - "Are you sure you want to clear " - "${coin.prettyName} electrumx cache?", - onOkPressed: (value) { - result = value; - }, - leftButton: SecondaryButton( - label: "Cancel", - onPressed: () { - Navigator.of(context).pop(); - }, - ), - ), - ); - - if (result == "OK" && mounted) { - await showLoading( - whileFuture: Future.wait( - [ - Future.delayed( - const Duration( - milliseconds: 1500, - ), - ), - DB.instance - .clearSharedTransactionCache( - coin: coin, - ), - ], - ), - context: context, - message: "Clearing cache...", - ); - } - }, - ); - }, - ), if (coin == Coin.nano || coin == Coin.banano) const SizedBox( height: 8, diff --git a/lib/pages/wallet_view/sub_widgets/tx_icon.dart b/lib/pages/wallet_view/sub_widgets/tx_icon.dart index 46972c49b..d86ad6e8d 100644 --- a/lib/pages/wallet_view/sub_widgets/tx_icon.dart +++ b/lib/pages/wallet_view/sub_widgets/tx_icon.dart @@ -35,7 +35,6 @@ class TxIcon extends ConsumerWidget { String _getAssetName( bool isCancelled, bool isReceived, bool isPending, IThemeAssets assets) { - if (!isReceived && transaction.subType == TransactionSubType.mint) { if (isCancelled) { return Assets.svg.anonymizeFailed; @@ -48,7 +47,7 @@ class TxIcon extends ConsumerWidget { if (isReceived) { if (isCancelled) { - return assets.receiveCancelled; + return assets.receive; } if (isPending) { return assets.receivePending; diff --git a/lib/pages/wallet_view/transaction_views/transaction_details_view.dart b/lib/pages/wallet_view/transaction_views/transaction_details_view.dart index 88d0d8b1a..f358aef5e 100644 --- a/lib/pages/wallet_view/transaction_views/transaction_details_view.dart +++ b/lib/pages/wallet_view/transaction_views/transaction_details_view.dart @@ -358,6 +358,8 @@ class _TransactionDetailsViewState final currentHeight = ref.watch(walletsChangeNotifierProvider .select((value) => value.getManager(walletId).currentHeight)); + print("THIS TRANSACTION IS $_transaction"); + return ConditionalParent( condition: !isDesktop, builder: (child) => Background( @@ -1577,11 +1579,7 @@ class _TransactionDetailsViewState ), floatingActionButtonLocation: FloatingActionButtonLocation.centerFloat, floatingActionButton: (coin == Coin.epicCash && - _transaction.isConfirmed( - currentHeight, - coin.requiredConfirmations, - ) == - false && + _transaction.getConfirmations(currentHeight) < 1 && _transaction.isCancelled == false) ? ConditionalParent( condition: isDesktop, diff --git a/lib/pages/wallet_view/wallet_view.dart b/lib/pages/wallet_view/wallet_view.dart index 7c6ca034b..e38a38cdd 100644 --- a/lib/pages/wallet_view/wallet_view.dart +++ b/lib/pages/wallet_view/wallet_view.dart @@ -72,6 +72,7 @@ import 'package:stackwallet/widgets/custom_buttons/blue_text_button.dart'; import 'package:stackwallet/widgets/custom_loading_overlay.dart'; import 'package:stackwallet/widgets/desktop/secondary_button.dart'; import 'package:stackwallet/widgets/loading_indicator.dart'; +import 'package:stackwallet/widgets/small_tor_icon.dart'; import 'package:stackwallet/widgets/stack_dialog.dart'; import 'package:stackwallet/widgets/wallet_navigation_bar/components/icons/buy_nav_icon.dart'; import 'package:stackwallet/widgets/wallet_navigation_bar/components/icons/coin_control_nav_icon.dart'; @@ -555,6 +556,17 @@ class _WalletViewState extends ConsumerState { ], ), actions: [ + const Padding( + padding: EdgeInsets.only( + top: 10, + bottom: 10, + right: 10, + ), + child: AspectRatio( + aspectRatio: 1, + child: SmallTorIcon(), + ), + ), Padding( padding: const EdgeInsets.only( top: 10, diff --git a/lib/pages_desktop_specific/desktop_buy/desktop_buy_view.dart b/lib/pages_desktop_specific/desktop_buy/desktop_buy_view.dart index e56d2644c..8827641fa 100644 --- a/lib/pages_desktop_specific/desktop_buy/desktop_buy_view.dart +++ b/lib/pages_desktop_specific/desktop_buy/desktop_buy_view.dart @@ -9,76 +9,137 @@ */ import 'package:flutter/material.dart'; +import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:stackwallet/pages/buy_view/buy_form.dart'; +import 'package:stackwallet/providers/global/prefs_provider.dart'; +import 'package:stackwallet/themes/stack_colors.dart'; import 'package:stackwallet/utilities/text_styles.dart'; import 'package:stackwallet/widgets/desktop/desktop_app_bar.dart'; +import 'package:stackwallet/widgets/desktop/desktop_dialog.dart'; import 'package:stackwallet/widgets/desktop/desktop_scaffold.dart'; import 'package:stackwallet/widgets/rounded_white_container.dart'; -class DesktopBuyView extends StatefulWidget { +class DesktopBuyView extends ConsumerStatefulWidget { const DesktopBuyView({Key? key}) : super(key: key); static const String routeName = "/desktopBuyView"; @override - State createState() => _DesktopBuyViewState(); + ConsumerState createState() => _DesktopBuyViewState(); } -class _DesktopBuyViewState extends State { +class _DesktopBuyViewState extends ConsumerState { + late bool torEnabled = false; + + @override + void initState() { + WidgetsBinding.instance.addPostFrameCallback((_) async { + setState(() { + torEnabled = ref.read(prefsChangeNotifierProvider).useTor; + }); + }); + super.initState(); + } + @override Widget build(BuildContext context) { - return DesktopScaffold( - appBar: DesktopAppBar( - isCompactHeight: true, - leading: Padding( - padding: const EdgeInsets.only( - left: 24, - ), - child: Text( - "Buy crypto", - style: STextStyles.desktopH3(context), - ), - ), - ), - body: Padding( - padding: const EdgeInsets.only( - left: 24, - right: 24, - bottom: 24, - ), - child: Row( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Expanded( - child: Column( - mainAxisSize: MainAxisSize.min, - crossAxisAlignment: CrossAxisAlignment.start, - children: const [ - SizedBox( - height: 16, - ), - RoundedWhiteContainer( - padding: EdgeInsets.all(24), - child: BuyForm(), - ), - ], + return Stack( + children: [ + DesktopScaffold( + appBar: DesktopAppBar( + isCompactHeight: true, + leading: Padding( + padding: const EdgeInsets.only( + left: 24, + ), + child: Text( + "Buy crypto", + style: STextStyles.desktopH3(context), ), ), - const SizedBox( - width: 16, + ), + body: Padding( + padding: const EdgeInsets.only( + left: 24, + right: 24, + bottom: 24, ), - // Expanded( - // child: Row( - // children: const [ - // Expanded( - // child: DesktopTradeHistory(), - // ), - // ], - // ), - // ), - ], + child: Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Expanded( + child: Column( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.start, + children: const [ + SizedBox( + height: 16, + ), + RoundedWhiteContainer( + padding: EdgeInsets.all(24), + child: BuyForm(), + ), + ], + ), + ), + const SizedBox( + width: 16, + ), + // Expanded( + // child: Row( + // children: const [ + // Expanded( + // child: DesktopTradeHistory(), + // ), + // ], + // ), + // ), + ], + ), + ), ), - ), + if (torEnabled) + Container( + color: Theme.of(context) + .extension()! + .overlay + .withOpacity(0.7), + height: MediaQuery.of(context).size.height, + width: MediaQuery.of(context).size.width, + child: DesktopDialog( + maxHeight: 200, + maxWidth: 350, + child: Padding( + padding: const EdgeInsets.all( + 15.0, + ), + child: Column( + // crossAxisAlignment: CrossAxisAlignment.center, + // mainAxisAlignment: MainAxisAlignment.center, + children: [ + Text( + "Tor is enabled", + textAlign: TextAlign.center, + style: STextStyles.pageTitleH1(context), + ), + const SizedBox( + height: 30, + ), + Text( + "Purchasing not available while Tor is enabled", + textAlign: TextAlign.center, + style: STextStyles.desktopTextMedium(context).copyWith( + color: Theme.of(context) + .extension()! + .infoItemLabel, + ), + ), + ], + ), + ), + ), + ), + ], ); } } diff --git a/lib/pages_desktop_specific/desktop_exchange/exchange_steps/subwidgets/desktop_step_4.dart b/lib/pages_desktop_specific/desktop_exchange/exchange_steps/subwidgets/desktop_step_4.dart index 8b30b2e2a..437e45210 100644 --- a/lib/pages_desktop_specific/desktop_exchange/exchange_steps/subwidgets/desktop_step_4.dart +++ b/lib/pages_desktop_specific/desktop_exchange/exchange_steps/subwidgets/desktop_step_4.dart @@ -155,6 +155,23 @@ class _DesktopStep4State extends ConsumerState { height: 1, color: Theme.of(context).extension()!.background, ), + if (ref.watch(desktopExchangeModelProvider + .select((value) => value!.trade?.payInExtraId)) != + null) + DesktopStepItem( + vertical: true, + label: "Memo", + value: ref.watch(desktopExchangeModelProvider + .select((value) => value!.trade?.payInExtraId)) ?? + "Error", + ), + if (ref.watch(desktopExchangeModelProvider + .select((value) => value!.trade?.payInExtraId)) != + null) + Container( + height: 1, + color: Theme.of(context).extension()!.background, + ), DesktopStepItem( label: "Amount", value: diff --git a/lib/pages_desktop_specific/desktop_menu.dart b/lib/pages_desktop_specific/desktop_menu.dart index 1a0a1f09f..64faa0d16 100644 --- a/lib/pages_desktop_specific/desktop_menu.dart +++ b/lib/pages_desktop_specific/desktop_menu.dart @@ -15,10 +15,12 @@ import 'package:flutter/services.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/flutter_svg.dart'; import 'package:stackwallet/pages_desktop_specific/desktop_menu_item.dart'; +import 'package:stackwallet/pages_desktop_specific/settings/settings_menu.dart'; import 'package:stackwallet/providers/desktop/current_desktop_menu_item.dart'; import 'package:stackwallet/themes/stack_colors.dart'; import 'package:stackwallet/utilities/assets.dart'; import 'package:stackwallet/utilities/text_styles.dart'; +import 'package:stackwallet/widgets/desktop/desktop_tor_status_button.dart'; import 'package:stackwallet/widgets/desktop/living_stack_icon.dart'; enum DesktopMenuItemId { @@ -52,11 +54,10 @@ class _DesktopMenuState extends ConsumerState { final Duration duration = const Duration(milliseconds: 250); late final List controllers; + late final DMIController torButtonController; double _width = expandedWidth; - // final _buyDataLoadingService = BuyDataLoadingService(); - void updateSelectedMenuItem(DesktopMenuItemId idKey) { widget.onSelectionWillChange?.call(idKey); @@ -72,6 +73,8 @@ class _DesktopMenuState extends ConsumerState { e.toggle?.call(); } + torButtonController.toggle?.call(); + setState(() { _width = expanded ? minimizedWidth : expandedWidth; }); @@ -91,6 +94,8 @@ class _DesktopMenuState extends ConsumerState { DMIController(), ]; + torButtonController = DMIController(); + super.initState(); } @@ -99,6 +104,8 @@ class _DesktopMenuState extends ConsumerState { for (var e in controllers) { e.dispose(); } + torButtonController.dispose(); + super.dispose(); } @@ -140,7 +147,26 @@ class _DesktopMenuState extends ConsumerState { ), ), const SizedBox( - height: 60, + height: 5, + ), + AnimatedContainer( + duration: duration, + width: _width == expandedWidth + ? _width - 32 // 16 padding on either side + : _width - 16, // 8 padding on either side + child: DesktopTorStatusButton( + transitionDuration: duration, + controller: torButtonController, + onPressed: () { + ref.read(currentDesktopMenuItemProvider.state).state = + DesktopMenuItemId.settings; + ref.watch(selectedSettingsMenuItemStateProvider.state).state = + 4; + }, + ), + ), + const SizedBox( + height: 40, ), Expanded( child: AnimatedContainer( diff --git a/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/desktop_receive.dart b/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/desktop_receive.dart index 292517699..22da0f217 100644 --- a/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/desktop_receive.dart +++ b/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/desktop_receive.dart @@ -219,14 +219,20 @@ class _DesktopReceiveState extends ConsumerState { if (coin != Coin.epicCash && coin != Coin.ethereum && coin != Coin.banano && - coin != Coin.nano) + coin != Coin.nano && + coin != Coin.stellar && + coin != Coin.stellarTestnet && + coin != Coin.tezos) const SizedBox( height: 20, ), if (coin != Coin.epicCash && coin != Coin.ethereum && coin != Coin.banano && - coin != Coin.nano) + coin != Coin.nano && + coin != Coin.stellar && + coin != Coin.stellarTestnet && + coin != Coin.tezos) SecondaryButton( buttonHeight: ButtonHeight.l, onPressed: generateNewAddress, diff --git a/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/desktop_send.dart b/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/desktop_send.dart index 3d65eb6e2..f9f24cb76 100644 --- a/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/desktop_send.dart +++ b/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/desktop_send.dart @@ -97,12 +97,16 @@ class _DesktopSendState extends ConsumerState { late TextEditingController cryptoAmountController; late TextEditingController baseAmountController; // late TextEditingController feeController; + late TextEditingController memoController; late final SendViewAutoFillData? _data; final _addressFocusNode = FocusNode(); final _cryptoFocus = FocusNode(); final _baseFocus = FocusNode(); + final _memoFocus = FocusNode(); + + late final bool isStellar; String? _note; String? _onChainNote; @@ -326,10 +330,12 @@ class _DesktopSendState extends ConsumerState { }, ); } else { + final memo = isStellar ? memoController.text : null; txDataFuture = manager.prepareSend( address: _address!, amount: amount, args: { + "memo": memo, "feeRate": ref.read(feeRateTypeStateProvider), "satsPerVByte": isCustomFee ? customFeeRate : null, "UTXOs": (manager.hasCoinControlSupport && @@ -663,6 +669,23 @@ class _DesktopSendState extends ConsumerState { } } + Future pasteMemo() async { + if (memoController.text.isNotEmpty) { + setState(() { + memoController.text = ""; + }); + } else { + final ClipboardData? data = await clipboard.getData(Clipboard.kTextPlain); + if (data?.text != null && data!.text!.isNotEmpty) { + String content = data.text!.trim(); + + setState(() { + memoController.text = content; + }); + } + } + } + void fiatTextFieldOnChanged(String baseAmountString) { final baseAmount = Amount.tryParseFiatString( baseAmountString, @@ -762,10 +785,12 @@ class _DesktopSendState extends ConsumerState { coin = ref.read(walletsChangeNotifierProvider).getManager(walletId).coin; clipboard = widget.clipboard; scanner = widget.barcodeScanner; + isStellar = coin == Coin.stellar || coin == Coin.stellarTestnet; sendToController = TextEditingController(); cryptoAmountController = TextEditingController(); baseAmountController = TextEditingController(); + memoController = TextEditingController(); // feeController = TextEditingController(); onCryptoAmountChanged = _cryptoAmountChanged; @@ -814,11 +839,13 @@ class _DesktopSendState extends ConsumerState { sendToController.dispose(); cryptoAmountController.dispose(); baseAmountController.dispose(); + memoController.dispose(); // feeController.dispose(); _addressFocusNode.dispose(); _cryptoFocus.dispose(); _baseFocus.dispose(); + _memoFocus.dispose(); super.dispose(); } @@ -1367,6 +1394,67 @@ class _DesktopSendState extends ConsumerState { } }, ), + if (isStellar) + const SizedBox( + height: 10, + ), + if (isStellar) + ClipRRect( + borderRadius: BorderRadius.circular( + Constants.size.circularBorderRadius, + ), + child: TextField( + minLines: 1, + maxLines: 5, + key: const Key("sendViewMemoFieldKey"), + controller: memoController, + readOnly: false, + autocorrect: false, + enableSuggestions: false, + focusNode: _memoFocus, + onChanged: (_) { + setState(() {}); + }, + style: STextStyles.desktopTextExtraSmall(context).copyWith( + color: Theme.of(context) + .extension()! + .textFieldActiveText, + height: 1.8, + ), + decoration: standardInputDecoration( + "Enter memo (optional)", + _memoFocus, + context, + desktopMed: true, + ).copyWith( + contentPadding: const EdgeInsets.only( + left: 16, + top: 11, + bottom: 12, + right: 5, + ), + suffixIcon: Padding( + padding: memoController.text.isEmpty + ? const EdgeInsets.only(right: 8) + : const EdgeInsets.only(right: 0), + child: UnconstrainedBox( + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceAround, + children: [ + TextFieldIconButton( + key: const Key("sendViewPasteMemoButtonKey"), + onTap: pasteMemo, + child: memoController.text.isEmpty + ? const ClipboardIcon() + : const XIcon(), + ), + ], + ), + ), + ), + ), + ), + ), if (!isPaynymSend) const SizedBox( height: 20, diff --git a/lib/pages_desktop_specific/ordinals/desktop_ordinal_details_view.dart b/lib/pages_desktop_specific/ordinals/desktop_ordinal_details_view.dart index b0225f286..f1c6093aa 100644 --- a/lib/pages_desktop_specific/ordinals/desktop_ordinal_details_view.dart +++ b/lib/pages_desktop_specific/ordinals/desktop_ordinal_details_view.dart @@ -3,21 +3,23 @@ import 'dart:io'; import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/flutter_svg.dart'; -import 'package:http/http.dart'; import 'package:path_provider/path_provider.dart'; import 'package:permission_handler/permission_handler.dart'; import 'package:stackwallet/models/isar/models/blockchain_data/utxo.dart'; import 'package:stackwallet/models/isar/ordinal.dart'; +import 'package:stackwallet/networking/http.dart'; import 'package:stackwallet/notifications/show_flush_bar.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/wallets_provider.dart'; +import 'package:stackwallet/services/tor_service.dart'; import 'package:stackwallet/themes/stack_colors.dart'; import 'package:stackwallet/utilities/amount/amount.dart'; import 'package:stackwallet/utilities/amount/amount_formatter.dart'; import 'package:stackwallet/utilities/assets.dart'; import 'package:stackwallet/utilities/constants.dart'; import 'package:stackwallet/utilities/enums/coin_enum.dart'; +import 'package:stackwallet/utilities/prefs.dart'; import 'package:stackwallet/utilities/show_loading.dart'; import 'package:stackwallet/utilities/text_styles.dart'; import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart'; @@ -50,11 +52,16 @@ class _DesktopOrdinalDetailsViewState late final UTXO? utxo; Future _savePngToFile() async { - final response = await get(Uri.parse(widget.ordinal.content)); + HTTP client = HTTP(); - if (response.statusCode != 200) { - throw Exception( - "statusCode=${response.statusCode} body=${response.bodyBytes}"); + final response = await client.get( + url: Uri.parse(widget.ordinal.content), + proxyInfo: + Prefs.instance.useTor ? TorService.sharedInstance.proxyInfo : null, + ); + + if (response.code != 200) { + throw Exception("statusCode=${response.code} body=${response.bodyBytes}"); } final bytes = response.bodyBytes; diff --git a/lib/pages_desktop_specific/settings/desktop_settings_view.dart b/lib/pages_desktop_specific/settings/desktop_settings_view.dart index 2a8c180f9..6a785fc8a 100644 --- a/lib/pages_desktop_specific/settings/desktop_settings_view.dart +++ b/lib/pages_desktop_specific/settings/desktop_settings_view.dart @@ -19,6 +19,7 @@ import 'package:stackwallet/pages_desktop_specific/settings/settings_menu/langua import 'package:stackwallet/pages_desktop_specific/settings/settings_menu/nodes_settings.dart'; import 'package:stackwallet/pages_desktop_specific/settings/settings_menu/security_settings.dart'; import 'package:stackwallet/pages_desktop_specific/settings/settings_menu/syncing_preferences_settings.dart'; +import 'package:stackwallet/pages_desktop_specific/settings/settings_menu/tor_settings/tor_settings.dart'; import 'package:stackwallet/route_generator.dart'; import 'package:stackwallet/themes/stack_colors.dart'; import 'package:stackwallet/utilities/text_styles.dart'; @@ -56,7 +57,12 @@ class _DesktopSettingsViewState extends ConsumerState { key: Key("settingsLanguageDesktopKey"), onGenerateRoute: RouteGenerator.generateRoute, initialRoute: LanguageOptionSettings.routeName, - ), //language + ), + const Navigator( + key: Key("settingsTorDesktopKey"), + onGenerateRoute: RouteGenerator.generateRoute, + initialRoute: TorSettings.routeName, + ), //tor const Navigator( key: Key("settingsNodesDesktopKey"), onGenerateRoute: RouteGenerator.generateRoute, diff --git a/lib/pages_desktop_specific/settings/settings_menu.dart b/lib/pages_desktop_specific/settings/settings_menu.dart index 4f3175a72..ba2c21781 100644 --- a/lib/pages_desktop_specific/settings/settings_menu.dart +++ b/lib/pages_desktop_specific/settings/settings_menu.dart @@ -32,6 +32,7 @@ class _SettingsMenuState extends ConsumerState { "Security", "Currency", "Language", + "Tor settings", "Nodes", "Syncing preferences", "Appearance", diff --git a/lib/pages_desktop_specific/settings/settings_menu/tor_settings/tor_settings.dart b/lib/pages_desktop_specific/settings/settings_menu/tor_settings/tor_settings.dart new file mode 100644 index 000000000..212387035 --- /dev/null +++ b/lib/pages_desktop_specific/settings/settings_menu/tor_settings/tor_settings.dart @@ -0,0 +1,409 @@ +/* + * This file is part of Stack Wallet. + * + * Copyright (c) 2023 Cypher Stack + * All Rights Reserved. + * The code is distributed under GPLv3 license, see LICENSE file for details. + * Generated by Cypher Stack on 2023-05-26 + * + */ + +import 'dart:async'; + +import 'package:event_bus/event_bus.dart'; +import 'package:flutter/gestures.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_riverpod/flutter_riverpod.dart'; +import 'package:flutter_svg/flutter_svg.dart'; +import 'package:stackwallet/providers/global/prefs_provider.dart'; +import 'package:stackwallet/services/event_bus/events/global/tor_connection_status_changed_event.dart'; +import 'package:stackwallet/services/event_bus/global_event_bus.dart'; +import 'package:stackwallet/services/tor_service.dart'; +import 'package:stackwallet/themes/stack_colors.dart'; +import 'package:stackwallet/utilities/assets.dart'; +import 'package:stackwallet/utilities/logger.dart'; +import 'package:stackwallet/utilities/text_styles.dart'; +import 'package:stackwallet/utilities/util.dart'; +import 'package:stackwallet/widgets/custom_buttons/draggable_switch_button.dart'; +import 'package:stackwallet/widgets/desktop/desktop_dialog.dart'; +import 'package:stackwallet/widgets/desktop/desktop_dialog_close_button.dart'; +import 'package:stackwallet/widgets/desktop/secondary_button.dart'; +import 'package:stackwallet/widgets/rounded_white_container.dart'; + +class TorSettings extends ConsumerStatefulWidget { + const TorSettings({Key? key}) : super(key: key); + + static const String routeName = "/torDesktopSettings"; + + @override + ConsumerState createState() => _TorSettingsState(); +} + +class _TorSettingsState extends ConsumerState { + /// The global event bus. + EventBus eventBus = GlobalEventBus.instance; + + /// Subscription to the TorConnectionStatusChangedEvent. + late StreamSubscription + _torConnectionStatusSubscription; + + /// The current status of the Tor connection. + late TorConnectionStatus _torConnectionStatus; + + /// Build the connect/disconnect button. + Widget _buildConnectButton(TorConnectionStatus status) { + switch (status) { + case TorConnectionStatus.disconnected: + return SecondaryButton( + label: "Connect to Tor", + width: 200, + buttonHeight: ButtonHeight.m, + onPressed: () async { + // Init the Tor service if it hasn't already been. + ref.read(pTorService).init(); + + // Start the Tor service. + try { + await ref.read(pTorService).start(); + + // Toggle the useTor preference on success. + ref.read(prefsChangeNotifierProvider).useTor = true; + } catch (e, s) { + Logging.instance.log( + "Error starting tor: $e\n$s", + level: LogLevel.Error, + ); + } + }, + ); + case TorConnectionStatus.connecting: + return AbsorbPointer( + child: SecondaryButton( + label: "Connecting to Tor", + width: 200, + buttonHeight: ButtonHeight.m, + onPressed: () {}, + ), + ); + case TorConnectionStatus.connected: + return SecondaryButton( + label: "Disconnect from Tor", + width: 200, + buttonHeight: ButtonHeight.m, + onPressed: () async { + // Stop the Tor service. + try { + await ref.read(pTorService).stop(); + + // Toggle the useTor preference on success. + ref.read(prefsChangeNotifierProvider).useTor = false; + } catch (e, s) { + Logging.instance.log( + "Error stopping tor: $e\n$s", + level: LogLevel.Error, + ); + } + }, + ); + } + } + + @override + void initState() { + // Initialize the global event bus. + eventBus = GlobalEventBus.instance; + + // Set the initial Tor connection status. + _torConnectionStatus = ref.read(pTorService).enabled + ? TorConnectionStatus.connected + : TorConnectionStatus.disconnected; + + // Subscribe to the TorConnectionStatusChangedEvent. + _torConnectionStatusSubscription = + eventBus.on().listen( + (event) async { + // Rebuild the widget. + setState(() { + _torConnectionStatus = event.newStatus; + }); + }, + ); + + super.initState(); + } + + @override + void dispose() { + // Clean up the TorConnectionStatusChangedEvent subscription. + _torConnectionStatusSubscription.cancel(); + + super.dispose(); + } + + @override + Widget build(BuildContext context) { + final isDesktop = Util.isDesktop; + + /// todo: redo the padding + return Column( + children: [ + Padding( + padding: const EdgeInsets.only( + right: 30, + ), + child: RoundedWhiteContainer( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Padding( + padding: const EdgeInsets.all(8.0), + child: SvgPicture.asset( + Assets.svg.circleTor, + width: 48, + height: 48, + ), + ), + Padding( + padding: const EdgeInsets.all(8.0), + child: SvgPicture.asset( + _torConnectionStatus == TorConnectionStatus.connected + ? Assets.svg.connectedButton + : _torConnectionStatus == + TorConnectionStatus.connecting + ? Assets.svg.connectingButton + : Assets.svg.disconnectedButton, + width: 48, + height: 48, + ), + ), + ], + ), + Padding( + padding: const EdgeInsets.all(10), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + "Tor settings", + style: STextStyles.desktopTextSmall(context), + ), + RichText( + textAlign: TextAlign.start, + text: TextSpan( + children: [ + TextSpan( + text: + "\nConnect to the Tor Network with one click.", + style: STextStyles.desktopTextExtraExtraSmall( + context), + ), + TextSpan( + text: "\tWhat is Tor?", + style: STextStyles.richLink(context).copyWith( + fontSize: 14, + ), + recognizer: TapGestureRecognizer() + ..onTap = () { + showDialog( + context: context, + useSafeArea: false, + barrierDismissible: true, + builder: (context) { + return DesktopDialog( + maxWidth: 580, + maxHeight: double.infinity, + child: Column( + children: [ + Row( + mainAxisAlignment: + MainAxisAlignment.end, + children: [ + DesktopDialogCloseButton( + onPressedOverride: () => + Navigator.of(context) + .pop(true), + ), + ], + ), + Padding( + padding: const EdgeInsets.all(20), + child: Column( + mainAxisSize: MainAxisSize.max, + children: [ + Text( + "What is Tor?", + style: + STextStyles.desktopH2( + context), + ), + const SizedBox( + height: 20, + ), + Text( + "Short for \"The Onion Router\", is an open-source software that enables internet communication" + " to remain anonymous by routing internet traffic through a series of layered nodes," + " to obscure the origin and destination of data.", + style: STextStyles + .desktopTextMedium( + context) + .copyWith( + color: Theme.of(context) + .extension< + StackColors>()! + .textDark3, + ), + ), + ], + ), + ), + ], + ), + ); + }, + ); + }, + ), + ], + ), + ), + ], + ), + ), + const SizedBox( + height: 10, + ), + Padding( + padding: const EdgeInsets.all(10.0), + child: _buildConnectButton(_torConnectionStatus), + ), + const SizedBox( + height: 30, + ), + Padding( + padding: const EdgeInsets.all(10.0), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Row( + children: [ + RichText( + textAlign: TextAlign.start, + text: TextSpan( + children: [ + TextSpan( + text: "Tor killswitch", + style: STextStyles.desktopTextExtraExtraSmall( + context) + .copyWith( + color: Theme.of(context) + .extension()! + .textDark), + ), + TextSpan( + text: "\nWhat is Tor killswitch?", + style: STextStyles.richLink(context).copyWith( + fontSize: 14, + ), + recognizer: TapGestureRecognizer() + ..onTap = () { + showDialog( + context: context, + useSafeArea: false, + barrierDismissible: true, + builder: (context) { + return DesktopDialog( + maxWidth: 580, + maxHeight: double.infinity, + child: Column( + children: [ + Row( + mainAxisAlignment: + MainAxisAlignment.end, + children: [ + DesktopDialogCloseButton( + onPressedOverride: () => + Navigator.of(context) + .pop(true), + ), + ], + ), + Padding( + padding: + const EdgeInsets.all(20), + child: Column( + mainAxisSize: + MainAxisSize.max, + children: [ + Text( + "What is Tor killswitch?", + style: STextStyles + .desktopH2(context), + ), + const SizedBox( + height: 20, + ), + Text( + "A security feature that protects your information from accidental exposure by" + " disconnecting your device from the Tor network if the" + " connection is disrupted or compromised.", + style: STextStyles + .desktopTextMedium( + context) + .copyWith( + color: Theme.of( + context) + .extension< + StackColors>()! + .textDark3, + ), + ), + ], + ), + ), + ], + ), + ); + }, + ); + }, + ), + ], + ), + ), + ], + ), + Padding( + padding: const EdgeInsets.only(right: 8.0), + child: SizedBox( + height: 20, + width: 40, + child: DraggableSwitchButton( + isOn: ref.watch( + prefsChangeNotifierProvider + .select((value) => value.torKillSwitch), + ), + onValueChanged: (newValue) { + ref + .read(prefsChangeNotifierProvider) + .torKillSwitch = newValue; + }, + ), + ), + ), + ], + ), + ), + const SizedBox( + height: 10, + ), + ], + ), + ), + ), + ], + ); + } +} diff --git a/lib/providers/global/http_provider.dart b/lib/providers/global/http_provider.dart new file mode 100644 index 000000000..84f8793c0 --- /dev/null +++ b/lib/providers/global/http_provider.dart @@ -0,0 +1,4 @@ +import 'package:flutter_riverpod/flutter_riverpod.dart'; +import 'package:stackwallet/networking/http.dart'; + +final pHTTP = Provider((ref) => HTTP()); diff --git a/lib/route_generator.dart b/lib/route_generator.dart index be744f583..4c52bc236 100644 --- a/lib/route_generator.dart +++ b/lib/route_generator.dart @@ -27,6 +27,7 @@ import 'package:stackwallet/pages/add_wallet_views/add_token_view/edit_wallet_to import 'package:stackwallet/pages/add_wallet_views/add_wallet_view/add_wallet_view.dart'; import 'package:stackwallet/pages/add_wallet_views/create_or_restore_wallet_view/create_or_restore_wallet_view.dart'; import 'package:stackwallet/pages/add_wallet_views/name_your_wallet_view/name_your_wallet_view.dart'; +import 'package:stackwallet/pages/add_wallet_views/new_wallet_options/new_wallet_options_view.dart'; import 'package:stackwallet/pages/add_wallet_views/new_wallet_recovery_phrase_view/new_wallet_recovery_phrase_view.dart'; import 'package:stackwallet/pages/add_wallet_views/new_wallet_recovery_phrase_warning_view/new_wallet_recovery_phrase_warning_view.dart'; import 'package:stackwallet/pages/add_wallet_views/restore_wallet_view/restore_options_view/restore_options_view.dart'; @@ -110,6 +111,7 @@ import 'package:stackwallet/pages/settings_views/global_settings_view/support_vi import 'package:stackwallet/pages/settings_views/global_settings_view/syncing_preferences_views/syncing_options_view.dart'; import 'package:stackwallet/pages/settings_views/global_settings_view/syncing_preferences_views/syncing_preferences_view.dart'; import 'package:stackwallet/pages/settings_views/global_settings_view/syncing_preferences_views/wallet_syncing_options_view.dart'; +import 'package:stackwallet/pages/settings_views/global_settings_view/tor_settings/tor_settings_view.dart'; import 'package:stackwallet/pages/settings_views/wallet_settings_view/wallet_backup_views/wallet_backup_view.dart'; import 'package:stackwallet/pages/settings_views/wallet_settings_view/wallet_network_settings_view/wallet_network_settings_view.dart'; import 'package:stackwallet/pages/settings_views/wallet_settings_view/wallet_settings_view.dart'; @@ -167,6 +169,7 @@ import 'package:stackwallet/pages_desktop_specific/settings/settings_menu/langua import 'package:stackwallet/pages_desktop_specific/settings/settings_menu/nodes_settings.dart'; import 'package:stackwallet/pages_desktop_specific/settings/settings_menu/security_settings.dart'; import 'package:stackwallet/pages_desktop_specific/settings/settings_menu/syncing_preferences_settings.dart'; +import 'package:stackwallet/pages_desktop_specific/settings/settings_menu/tor_settings/tor_settings.dart'; import 'package:stackwallet/services/coins/manager.dart'; import 'package:stackwallet/services/event_bus/events/global/node_connection_status_changed_event.dart'; import 'package:stackwallet/services/event_bus/events/global/wallet_sync_status_changed_event.dart'; @@ -683,6 +686,18 @@ class RouteGenerator { builder: (_) => const LanguageSettingsView(), settings: RouteSettings(name: settings.name)); + case TorSettingsView.routeName: + return getRoute( + shouldUseMaterialRoute: useMaterialPageRoute, + builder: (_) => const TorSettingsView(), + settings: RouteSettings(name: settings.name)); + + case TorSettings.routeName: + return getRoute( + shouldUseMaterialRoute: useMaterialPageRoute, + builder: (_) => const TorSettings(), + settings: RouteSettings(name: settings.name)); + case AboutView.routeName: return getRoute( shouldUseMaterialRoute: useMaterialPageRoute, @@ -1131,6 +1146,21 @@ class RouteGenerator { } return _routeError("${settings.name} invalid args: ${args.toString()}"); + case NewWalletOptionsView.routeName: + if (args is Tuple2) { + return getRoute( + shouldUseMaterialRoute: useMaterialPageRoute, + builder: (_) => NewWalletOptionsView( + walletName: args.item1, + coin: args.item2, + ), + settings: RouteSettings( + name: settings.name, + ), + ); + } + return _routeError("${settings.name} invalid args: ${args.toString()}"); + case RestoreWalletView.routeName: if (args is Tuple5) { return getRoute( diff --git a/lib/services/buy/simplex/simplex_api.dart b/lib/services/buy/simplex/simplex_api.dart index 8158c6b8c..1b2d26e26 100644 --- a/lib/services/buy/simplex/simplex_api.dart +++ b/lib/services/buy/simplex/simplex_api.dart @@ -12,12 +12,13 @@ import 'dart:async'; import 'dart:convert'; import 'package:decimal/decimal.dart'; -import 'package:http/http.dart' as http; import 'package:stackwallet/models/buy/response_objects/crypto.dart'; import 'package:stackwallet/models/buy/response_objects/fiat.dart'; import 'package:stackwallet/models/buy/response_objects/order.dart'; import 'package:stackwallet/models/buy/response_objects/quote.dart'; +import 'package:stackwallet/networking/http.dart'; import 'package:stackwallet/services/buy/buy_response.dart'; +import 'package:stackwallet/services/tor_service.dart'; import 'package:stackwallet/utilities/enums/coin_enum.dart'; import 'package:stackwallet/utilities/enums/fiat_enum.dart'; import 'package:stackwallet/utilities/logger.dart'; @@ -35,8 +36,7 @@ class SimplexAPI { static final SimplexAPI _instance = SimplexAPI._(); static SimplexAPI get instance => _instance; - /// set this to override using standard http client. Useful for testing - http.Client? client; + HTTP client = HTTP(); Uri _buildUri(String path, Map? params) { if (scheme == "http") { @@ -55,10 +55,15 @@ class SimplexAPI { }; Uri url = _buildUri('api.php', data); - var res = await http.post(url, headers: headers); - if (res.statusCode != 200) { + var res = await client.post( + url: url, + headers: headers, + proxyInfo: + Prefs.instance.useTor ? TorService.sharedInstance.proxyInfo : null, + ); + if (res.code != 200) { throw Exception( - 'getAvailableCurrencies exception: statusCode= ${res.statusCode}'); + 'getAvailableCurrencies exception: statusCode= ${res.code}'); } final jsonArray = jsonDecode(res.body); // TODO handle if invalid json @@ -116,10 +121,15 @@ class SimplexAPI { }; Uri url = _buildUri('api.php', data); - var res = await http.post(url, headers: headers); - if (res.statusCode != 200) { + var res = await client.post( + url: url, + headers: headers, + proxyInfo: + Prefs.instance.useTor ? TorService.sharedInstance.proxyInfo : null, + ); + if (res.code != 200) { throw Exception( - 'getAvailableCurrencies exception: statusCode= ${res.statusCode}'); + 'getAvailableCurrencies exception: statusCode= ${res.code}'); } final jsonArray = jsonDecode(res.body); // TODO validate json @@ -192,9 +202,14 @@ class SimplexAPI { } Uri url = _buildUri('api.php', data); - var res = await http.get(url, headers: headers); - if (res.statusCode != 200) { - throw Exception('getQuote exception: statusCode= ${res.statusCode}'); + var res = await client.get( + url: url, + headers: headers, + proxyInfo: + Prefs.instance.useTor ? TorService.sharedInstance.proxyInfo : null, + ); + if (res.code != 200) { + throw Exception('getQuote exception: statusCode= ${res.code}'); } final jsonArray = jsonDecode(res.body); if (jsonArray.containsKey('error') as bool) { @@ -294,9 +309,14 @@ class SimplexAPI { } Uri url = _buildUri('api.php', data); - var res = await http.get(url, headers: headers); - if (res.statusCode != 200) { - throw Exception('newOrder exception: statusCode= ${res.statusCode}'); + var res = await client.get( + url: url, + headers: headers, + proxyInfo: + Prefs.instance.useTor ? TorService.sharedInstance.proxyInfo : null, + ); + if (res.code != 200) { + throw Exception('newOrder exception: statusCode= ${res.code}'); } final jsonArray = jsonDecode(res.body); // TODO check if valid json if (jsonArray.containsKey('error') as bool) { diff --git a/lib/services/coins/banano/banano_wallet.dart b/lib/services/coins/banano/banano_wallet.dart index e2032aa09..9f314f3a3 100644 --- a/lib/services/coins/banano/banano_wallet.dart +++ b/lib/services/coins/banano/banano_wallet.dart @@ -1,7 +1,6 @@ import 'dart:async'; import 'dart:convert'; -import 'package:http/http.dart' as http; import 'package:isar/isar.dart'; import 'package:nanodart/nanodart.dart'; import 'package:stackwallet/db/hive/db.dart'; @@ -10,6 +9,7 @@ import 'package:stackwallet/models/balance.dart'; import 'package:stackwallet/models/isar/models/isar_models.dart'; import 'package:stackwallet/models/node_model.dart'; import 'package:stackwallet/models/paymint/fee_object_model.dart'; +import 'package:stackwallet/networking/http.dart'; import 'package:stackwallet/services/coins/coin_service.dart'; import 'package:stackwallet/services/event_bus/events/global/node_connection_status_changed_event.dart'; import 'package:stackwallet/services/event_bus/events/global/updated_in_background_event.dart'; @@ -19,6 +19,7 @@ import 'package:stackwallet/services/mixins/wallet_cache.dart'; import 'package:stackwallet/services/mixins/wallet_db.dart'; import 'package:stackwallet/services/nano_api.dart'; import 'package:stackwallet/services/node_service.dart'; +import 'package:stackwallet/services/tor_service.dart'; import 'package:stackwallet/services/transaction_notification_tracker.dart'; import 'package:stackwallet/utilities/amount/amount.dart'; import 'package:stackwallet/utilities/constants.dart'; @@ -145,10 +146,12 @@ class BananoWallet extends CoinServiceAPI with WalletCache, WalletDB { Balance get balance => _balance ??= getCachedBalance(); Balance? _balance; + HTTP client = HTTP(); + Future requestWork(String hash) async { - return http + return client .post( - Uri.parse("https://rpc.nano.to"), // this should be a + url: Uri.parse("https://rpc.nano.to"), // this should be a headers: {'Content-type': 'application/json'}, body: json.encode( { @@ -156,17 +159,19 @@ class BananoWallet extends CoinServiceAPI with WalletCache, WalletDB { "hash": hash, }, ), + proxyInfo: + Prefs.instance.useTor ? TorService.sharedInstance.proxyInfo : null, ) - .then((http.Response response) { - if (response.statusCode == 200) { + .then((client) { + if (client.code == 200) { final Map decoded = - json.decode(response.body) as Map; + json.decode(client.body) as Map; if (decoded.containsKey("error")) { throw Exception("Received error ${decoded["error"]}"); } return decoded["work"] as String?; } else { - throw Exception("Received error ${response.statusCode}"); + throw Exception("Received error ${client.code}"); } }); } @@ -185,10 +190,12 @@ class BananoWallet extends CoinServiceAPI with WalletCache, WalletDB { final headers = { "Content-Type": "application/json", }; - final balanceResponse = await http.post( - Uri.parse(getCurrentNode().host), + final balanceResponse = await client.post( + url: Uri.parse(getCurrentNode().host), headers: headers, body: balanceBody, + proxyInfo: + Prefs.instance.useTor ? TorService.sharedInstance.proxyInfo : null, ); final balanceData = jsonDecode(balanceResponse.body); @@ -203,10 +210,12 @@ class BananoWallet extends CoinServiceAPI with WalletCache, WalletDB { "representative": "true", "account": publicAddress, }); - final infoResponse = await http.post( - Uri.parse(getCurrentNode().host), + final infoResponse = await client.post( + url: Uri.parse(getCurrentNode().host), headers: headers, body: infoBody, + proxyInfo: + Prefs.instance.useTor ? TorService.sharedInstance.proxyInfo : null, ); final String frontier = @@ -256,10 +265,12 @@ class BananoWallet extends CoinServiceAPI with WalletCache, WalletDB { "subtype": "send", "block": sendBlock, }); - final processResponse = await http.post( - Uri.parse(getCurrentNode().host), + final processResponse = await client.post( + url: Uri.parse(getCurrentNode().host), headers: headers, body: processBody, + proxyInfo: + Prefs.instance.useTor ? TorService.sharedInstance.proxyInfo : null, ); final Map decoded = @@ -328,8 +339,13 @@ class BananoWallet extends CoinServiceAPI with WalletCache, WalletDB { final headers = { "Content-Type": "application/json", }; - final response = await http.post(Uri.parse(getCurrentNode().host), - headers: headers, body: body); + final response = await client.post( + url: Uri.parse(getCurrentNode().host), + headers: headers, + body: body, + proxyInfo: + Prefs.instance.useTor ? TorService.sharedInstance.proxyInfo : null, + ); final data = jsonDecode(response.body); _balance = Balance( total: Amount( @@ -367,10 +383,12 @@ class BananoWallet extends CoinServiceAPI with WalletCache, WalletDB { "representative": "true", "account": publicAddress, }); - final infoResponse = await http.post( - Uri.parse(getCurrentNode().host), + final infoResponse = await client.post( + url: Uri.parse(getCurrentNode().host), headers: headers, body: infoBody, + proxyInfo: + Prefs.instance.useTor ? TorService.sharedInstance.proxyInfo : null, ); final infoData = jsonDecode(infoResponse.body); @@ -385,10 +403,12 @@ class BananoWallet extends CoinServiceAPI with WalletCache, WalletDB { "account": publicAddress, }); - final balanceResponse = await http.post( - Uri.parse(getCurrentNode().host), + final balanceResponse = await client.post( + url: Uri.parse(getCurrentNode().host), headers: headers, body: balanceBody, + proxyInfo: + Prefs.instance.useTor ? TorService.sharedInstance.proxyInfo : null, ); final balanceData = jsonDecode(balanceResponse.body); @@ -458,10 +478,12 @@ class BananoWallet extends CoinServiceAPI with WalletCache, WalletDB { "subtype": "receive", "block": receiveBlock, }); - final processResponse = await http.post( - Uri.parse(getCurrentNode().host), + final processResponse = await client.post( + url: Uri.parse(getCurrentNode().host), headers: headers, body: processBody, + proxyInfo: + Prefs.instance.useTor ? TorService.sharedInstance.proxyInfo : null, ); final Map decoded = @@ -472,14 +494,18 @@ class BananoWallet extends CoinServiceAPI with WalletCache, WalletDB { } Future confirmAllReceivable() async { - final receivableResponse = await http.post(Uri.parse(getCurrentNode().host), - headers: {"Content-Type": "application/json"}, - body: jsonEncode({ - "action": "receivable", - "source": "true", - "account": await currentReceivingAddress, - "count": "-1", - })); + final receivableResponse = await client.post( + url: Uri.parse(getCurrentNode().host), + headers: {"Content-Type": "application/json"}, + body: jsonEncode({ + "action": "receivable", + "source": "true", + "account": await currentReceivingAddress, + "count": "-1", + }), + proxyInfo: + Prefs.instance.useTor ? TorService.sharedInstance.proxyInfo : null, + ); final receivableData = await jsonDecode(receivableResponse.body); if (receivableData["blocks"] == "") { @@ -501,13 +527,17 @@ class BananoWallet extends CoinServiceAPI with WalletCache, WalletDB { await confirmAllReceivable(); 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({ - "action": "account_history", - "account": publicAddress, - "count": "-1", - })); + final response = await client.post( + url: Uri.parse(getCurrentNode().host), + headers: {"Content-Type": "application/json"}, + body: jsonEncode({ + "action": "account_history", + "account": publicAddress, + "count": "-1", + }), + proxyInfo: + Prefs.instance.useTor ? TorService.sharedInstance.proxyInfo : null, + ); final data = await jsonDecode(response.body); final transactions = data["history"] is List ? data["history"] as List : []; @@ -600,7 +630,9 @@ class BananoWallet extends CoinServiceAPI with WalletCache, WalletDB { } @override - Future initializeNew() async { + Future initializeNew( + ({String mnemonicPassphrase, int wordCount})? data, + ) async { if ((await mnemonicString) != null || (await mnemonicPassphrase) != null) { throw Exception( "Attempted to overwrite mnemonic on generate new wallet!"); @@ -817,17 +849,19 @@ class BananoWallet extends CoinServiceAPI with WalletCache, WalletDB { Future testNetworkConnection() async { final uri = Uri.parse(getCurrentNode().host); - final response = await http.post( - uri, + final response = await client.post( + url: uri, headers: {"Content-Type": "application/json"}, body: jsonEncode( { "action": "version", }, ), + proxyInfo: + Prefs.instance.useTor ? TorService.sharedInstance.proxyInfo : null, ); - return response.statusCode == 200; + return response.code == 200; } Timer? _networkAliveTimer; @@ -913,10 +947,12 @@ class BananoWallet extends CoinServiceAPI with WalletCache, WalletDB { final headers = { "Content-Type": "application/json", }; - final infoResponse = await http.post( - Uri.parse(getCurrentNode().host), + final infoResponse = await client.post( + url: Uri.parse(getCurrentNode().host), headers: headers, body: infoBody, + proxyInfo: + Prefs.instance.useTor ? TorService.sharedInstance.proxyInfo : null, ); final infoData = jsonDecode(infoResponse.body); diff --git a/lib/services/coins/bitcoin/bitcoin_wallet.dart b/lib/services/coins/bitcoin/bitcoin_wallet.dart index f40be0e3c..cb8eadeef 100644 --- a/lib/services/coins/bitcoin/bitcoin_wallet.dart +++ b/lib/services/coins/bitcoin/bitcoin_wallet.dart @@ -1290,7 +1290,9 @@ class BitcoinWallet extends CoinServiceAPI bool get isConnected => _isConnected; @override - Future initializeNew() async { + Future initializeNew( + ({String mnemonicPassphrase, int wordCount})? data, + ) async { Logging.instance .log("Generating new ${coin.prettyName} wallet.", level: LogLevel.Info); @@ -1301,7 +1303,7 @@ class BitcoinWallet extends CoinServiceAPI await _prefs.init(); try { - await _generateNewWallet(); + await _generateNewWallet(data); } catch (e, s) { Logging.instance.log("Exception rethrown from initializeNew(): $e\n$s", level: LogLevel.Fatal); @@ -1499,7 +1501,9 @@ class BitcoinWallet extends CoinServiceAPI } } - Future _generateNewWallet() async { + Future _generateNewWallet( + ({String mnemonicPassphrase, int wordCount})? data, + ) async { Logging.instance .log("IS_INTEGRATION_TEST: $integrationTestFlag", level: LogLevel.Info); if (!integrationTestFlag) { @@ -1533,10 +1537,21 @@ class BitcoinWallet extends CoinServiceAPI throw Exception( "Attempted to overwrite mnemonic on generate new wallet!"); } + final int strength; + if (data == null || data.wordCount == 12) { + strength = 128; + } else if (data.wordCount == 24) { + strength = 256; + } else { + throw Exception("Invalid word count"); + } await _secureStore.write( key: '${_walletId}_mnemonic', - value: bip39.generateMnemonic(strength: 128)); - await _secureStore.write(key: '${_walletId}_mnemonicPassphrase', value: ""); + value: bip39.generateMnemonic(strength: strength)); + await _secureStore.write( + key: '${_walletId}_mnemonicPassphrase', + value: data?.mnemonicPassphrase ?? "", + ); // Generate and add addresses to relevant arrays final initialAddresses = await Future.wait([ diff --git a/lib/services/coins/bitcoincash/bitcoincash_wallet.dart b/lib/services/coins/bitcoincash/bitcoincash_wallet.dart index 9ac2164a6..5b674cb1e 100644 --- a/lib/services/coins/bitcoincash/bitcoincash_wallet.dart +++ b/lib/services/coins/bitcoincash/bitcoincash_wallet.dart @@ -1186,7 +1186,9 @@ class BitcoinCashWallet extends CoinServiceAPI bool get isConnected => _isConnected; @override - Future initializeNew() async { + Future initializeNew( + ({String mnemonicPassphrase, int wordCount})? data, + ) async { Logging.instance .log("Generating new ${coin.prettyName} wallet.", level: LogLevel.Info); @@ -1196,7 +1198,7 @@ class BitcoinCashWallet extends CoinServiceAPI } await _prefs.init(); try { - await _generateNewWallet(); + await _generateNewWallet(data); } catch (e, s) { Logging.instance.log("Exception rethrown from initializeNew(): $e\n$s", level: LogLevel.Fatal); @@ -1425,7 +1427,9 @@ class BitcoinCashWallet extends CoinServiceAPI } } - Future _generateNewWallet() async { + Future _generateNewWallet( + ({String mnemonicPassphrase, int wordCount})? data, + ) async { Logging.instance .log("IS_INTEGRATION_TEST: $integrationTestFlag", level: LogLevel.Info); if (!integrationTestFlag) { @@ -1459,10 +1463,21 @@ class BitcoinCashWallet extends CoinServiceAPI throw Exception( "Attempted to overwrite mnemonic on generate new wallet!"); } + final int strength; + if (data == null || data.wordCount == 12) { + strength = 128; + } else if (data.wordCount == 24) { + strength = 256; + } else { + throw Exception("Invalid word count"); + } await _secureStore.write( key: '${_walletId}_mnemonic', - value: bip39.generateMnemonic(strength: 128)); - await _secureStore.write(key: '${_walletId}_mnemonicPassphrase', value: ""); + value: bip39.generateMnemonic(strength: strength)); + await _secureStore.write( + key: '${_walletId}_mnemonicPassphrase', + value: data?.mnemonicPassphrase ?? "", + ); // Generate and add addresses to relevant arrays final initialAddresses = await Future.wait([ diff --git a/lib/services/coins/coin_service.dart b/lib/services/coins/coin_service.dart index 5aa6e382d..360372095 100644 --- a/lib/services/coins/coin_service.dart +++ b/lib/services/coins/coin_service.dart @@ -1,6 +1,6 @@ -/* +/* * 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. @@ -28,6 +28,7 @@ import 'package:stackwallet/services/coins/namecoin/namecoin_wallet.dart'; import 'package:stackwallet/services/coins/nano/nano_wallet.dart'; import 'package:stackwallet/services/coins/particl/particl_wallet.dart'; import 'package:stackwallet/services/coins/stellar/stellar_wallet.dart'; +import 'package:stackwallet/services/coins/tezos/tezos_wallet.dart'; import 'package:stackwallet/services/coins/wownero/wownero_wallet.dart'; import 'package:stackwallet/services/transaction_notification_tracker.dart'; import 'package:stackwallet/utilities/amount/amount.dart'; @@ -228,6 +229,24 @@ abstract class CoinServiceAPI { tracker: tracker, ); + case Coin.stellarTestnet: + return StellarWallet( + walletId: walletId, + walletName: walletName, + coin: coin, + secureStore: secureStorageInterface, + tracker: tracker, + ); + + case Coin.tezos: + return TezosWallet( + walletId: walletId, + walletName: walletName, + coin: coin, + secureStore: secureStorageInterface, + tracker: tracker, + ); + case Coin.wownero: return WowneroWallet( walletId: walletId, @@ -285,15 +304,6 @@ abstract class CoinServiceAPI { cachedClient: cachedClient, tracker: tracker, ); - - case Coin.stellarTestnet: - return StellarWallet( - walletId: walletId, - walletName: walletName, - coin: coin, - secureStore: secureStorageInterface, - tracker: tracker, - ); } } @@ -348,7 +358,9 @@ abstract class CoinServiceAPI { required int height, }); - Future initializeNew(); + Future initializeNew( + ({String mnemonicPassphrase, int wordCount})? data, + ); Future initializeExisting(); Future exit(); diff --git a/lib/services/coins/dogecoin/dogecoin_wallet.dart b/lib/services/coins/dogecoin/dogecoin_wallet.dart index 754834ad1..3d6ae5794 100644 --- a/lib/services/coins/dogecoin/dogecoin_wallet.dart +++ b/lib/services/coins/dogecoin/dogecoin_wallet.dart @@ -1147,7 +1147,9 @@ class DogecoinWallet extends CoinServiceAPI bool get isConnected => _isConnected; @override - Future initializeNew() async { + Future initializeNew( + ({String mnemonicPassphrase, int wordCount})? data, + ) async { Logging.instance .log("Generating new ${coin.prettyName} wallet.", level: LogLevel.Info); @@ -1157,7 +1159,7 @@ class DogecoinWallet extends CoinServiceAPI } await _prefs.init(); try { - await _generateNewWallet(); + await _generateNewWallet(data); } catch (e, s) { Logging.instance.log("Exception rethrown from initializeNew(): $e\n$s", level: LogLevel.Fatal); @@ -1349,7 +1351,9 @@ class DogecoinWallet extends CoinServiceAPI } } - Future _generateNewWallet() async { + Future _generateNewWallet( + ({String mnemonicPassphrase, int wordCount})? data, + ) async { Logging.instance .log("IS_INTEGRATION_TEST: $integrationTestFlag", level: LogLevel.Info); if (!integrationTestFlag) { @@ -1383,12 +1387,20 @@ class DogecoinWallet extends CoinServiceAPI throw Exception( "Attempted to overwrite mnemonic on generate new wallet!"); } + final int strength; + if (data == null || data.wordCount == 12) { + strength = 128; + } else if (data.wordCount == 24) { + strength = 256; + } else { + throw Exception("Invalid word count"); + } await _secureStore.write( key: '${_walletId}_mnemonic', - value: bip39.generateMnemonic(strength: 128)); + value: bip39.generateMnemonic(strength: strength)); await _secureStore.write( key: '${_walletId}_mnemonicPassphrase', - value: "", + value: data?.mnemonicPassphrase ?? "", ); // Generate and add addresses diff --git a/lib/services/coins/ecash/ecash_wallet.dart b/lib/services/coins/ecash/ecash_wallet.dart index e891db692..c35f7f4c6 100644 --- a/lib/services/coins/ecash/ecash_wallet.dart +++ b/lib/services/coins/ecash/ecash_wallet.dart @@ -506,7 +506,9 @@ class ECashWallet extends CoinServiceAPI } } - Future _generateNewWallet() async { + Future _generateNewWallet( + ({String mnemonicPassphrase, int wordCount})? data, + ) async { Logging.instance .log("IS_INTEGRATION_TEST: $integrationTestFlag", level: LogLevel.Info); if (!integrationTestFlag) { @@ -544,10 +546,21 @@ class ECashWallet extends CoinServiceAPI throw Exception( "Attempted to overwrite mnemonic on generate new wallet!"); } + final int strength; + if (data == null || data.wordCount == 12) { + strength = 128; + } else if (data.wordCount == 24) { + strength = 256; + } else { + throw Exception("Invalid word count"); + } await _secureStore.write( key: '${_walletId}_mnemonic', - value: bip39.generateMnemonic(strength: 128)); - await _secureStore.write(key: '${_walletId}_mnemonicPassphrase', value: ""); + value: bip39.generateMnemonic(strength: strength)); + await _secureStore.write( + key: '${_walletId}_mnemonicPassphrase', + value: data?.mnemonicPassphrase ?? "", + ); const int startingIndex = 0; const int receiveChain = 0; @@ -2778,7 +2791,9 @@ class ECashWallet extends CoinServiceAPI bool get isConnected => _isConnected; @override - Future initializeNew() async { + Future initializeNew( + ({String mnemonicPassphrase, int wordCount})? data, + ) async { Logging.instance .log("Generating new ${coin.prettyName} wallet.", level: LogLevel.Info); @@ -2789,7 +2804,7 @@ class ECashWallet extends CoinServiceAPI await _prefs.init(); try { - await _generateNewWallet(); + await _generateNewWallet(data); } catch (e, s) { Logging.instance.log("Exception rethrown from initializeNew(): $e\n$s", level: LogLevel.Fatal); diff --git a/lib/services/coins/epiccash/epiccash_wallet.dart b/lib/services/coins/epiccash/epiccash_wallet.dart index b62129248..2dacb1639 100644 --- a/lib/services/coins/epiccash/epiccash_wallet.dart +++ b/lib/services/coins/epiccash/epiccash_wallet.dart @@ -176,7 +176,7 @@ Future executeNative(Map arguments) async { final selectionStrategyIsAll = arguments['selectionStrategyIsAll'] as int?; final minimumConfirmations = arguments['minimumConfirmations'] as int?; - final message = arguments['onChainNote'] as String?; + final message = arguments['message'] as String?; final amount = arguments['amount'] as int?; final address = arguments['address'] as String?; @@ -421,34 +421,31 @@ class EpicCashWallet extends CoinServiceAPI late SecureStorageInterface _secureStore; + /// returns an empty String on success, error message on failure Future cancelPendingTransactionAndPost(String txSlateId) async { - String? result; try { - result = await cancelPendingTransaction(txSlateId); - Logging.instance.log("result?: $result", level: LogLevel.Info); + final String wallet = (await _secureStore.read( + key: '${_walletId}_wallet', + ))!; + + final result = await m.protect(() async { + return await compute( + _cancelTransactionWrapper, + Tuple2( + wallet, + txSlateId, + ), + ); + }); + Logging.instance.log( + "cancel $txSlateId result: $result", + level: LogLevel.Info, + ); + return result; } catch (e, s) { Logging.instance.log("$e, $s", level: LogLevel.Error); + return e.toString(); } - return result!; - } - -// - /// returns an empty String on success, error message on failure - Future cancelPendingTransaction(String txSlateId) async { - final String wallet = - (await _secureStore.read(key: '${_walletId}_wallet'))!; - - String? result; - await m.protect(() async { - result = await compute( - _cancelTransactionWrapper, - Tuple2( - wallet, - txSlateId, - ), - ); - }); - return result!; } @override @@ -492,7 +489,7 @@ class EpicCashWallet extends CoinServiceAPI Logging.instance .log("this is a string $message", level: LogLevel.Error); stop(receivePort); - throw Exception("txHttpSend isolate failed"); + throw Exception(message); } stop(receivePort); Logging.instance @@ -667,25 +664,8 @@ class EpicCashWallet extends CoinServiceAPI await epicUpdateLastScannedBlock(await getRestoreHeight()); - if (!await startScans()) { - refreshMutex = false; - GlobalEventBus.instance.fire( - NodeConnectionStatusChangedEvent( - NodeConnectionStatus.disconnected, - walletId, - coin, - ), - ); - GlobalEventBus.instance.fire( - WalletSyncStatusChangedEvent( - WalletSyncStatus.unableToSync, - walletId, - coin, - ), - ); - return; - } - await refresh(); + await _startScans(); + GlobalEventBus.instance.fire( WalletSyncStatusChangedEvent( WalletSyncStatus.synced, @@ -694,12 +674,23 @@ class EpicCashWallet extends CoinServiceAPI ), ); } catch (e, s) { + GlobalEventBus.instance.fire( + WalletSyncStatusChangedEvent( + WalletSyncStatus.unableToSync, + walletId, + coin, + ), + ); + + Logging.instance.log( + "Exception rethrown from fullRescan(): $e\n$s", + level: LogLevel.Error, + printFullLength: true, + ); + rethrow; + } finally { refreshMutex = false; - Logging.instance - .log("$e, $s", level: LogLevel.Error, printFullLength: true); } - refreshMutex = false; - return; } @override @@ -766,7 +757,9 @@ class EpicCashWallet extends CoinServiceAPI } @override - Future initializeNew() async { + Future initializeNew( + ({String mnemonicPassphrase, int wordCount})? data, + ) async { await _prefs.init(); await updateNode(false); final mnemonic = await _getMnemonicList(); @@ -1163,58 +1156,97 @@ class EpicCashWallet extends CoinServiceAPI // TODO: refresh anything that needs to be refreshed/updated due to epicbox info changed } - Future startScans() async { + Future _startScans() async { try { + //First stop the current listener if (ListenerManager.pointer != null) { + Logging.instance + .log("LISTENER HANDLER IS NOT NULL ....", level: LogLevel.Info); + Logging.instance + .log("STOPPING ANY WALLET LISTENER ....", level: LogLevel.Info); epicboxListenerStop(ListenerManager.pointer!); } - final wallet = await _secureStore.read(key: '${_walletId}_wallet'); - var restoreHeight = epicGetRestoreHeight(); - var chainHeight = await this.chainHeight; - if (epicGetLastScannedBlock() == null) { - await epicUpdateLastScannedBlock(await getRestoreHeight()); - } - int lastScannedBlock = epicGetLastScannedBlock()!; - const MAX_PER_LOOP = 10000; - await getSyncPercent; - for (; lastScannedBlock < chainHeight;) { - chainHeight = await this.chainHeight; - lastScannedBlock = epicGetLastScannedBlock()!; - Logging.instance.log( - "chainHeight: $chainHeight, restoreHeight: $restoreHeight, lastScannedBlock: $lastScannedBlock", - level: LogLevel.Info); - int? nextScannedBlock; - await m.protect(() async { - ReceivePort receivePort = await getIsolate({ - "function": "scanOutPuts", - "wallet": wallet!, - "startHeight": lastScannedBlock, - "numberOfBlocks": MAX_PER_LOOP, - }, name: walletName); + // max number of blocks to scan per loop iteration + const scanChunkSize = 10000; - var message = await receivePort.first; - if (message is String) { - Logging.instance - .log("this is a string $message", level: LogLevel.Error); - stop(receivePort); - throw Exception("scanOutPuts isolate failed"); + // force firing of scan progress event + await getSyncPercent; + + // fetch current chain height and last scanned block (should be the + // restore height if full rescan or a wallet restore) + int chainHeight = await this.chainHeight; + int lastScannedBlock = + epicGetLastScannedBlock() ?? await getRestoreHeight(); + + // loop while scanning in chain in chunks (of blocks?) + while (lastScannedBlock < chainHeight) { + Logging.instance.log( + "chainHeight: $chainHeight, lastScannedBlock: $lastScannedBlock", + level: LogLevel.Info, + ); + + final int nextScannedBlock = await m.protect(() async { + ReceivePort? receivePort; + try { + receivePort = await getIsolate({ + "function": "scanOutPuts", + "wallet": wallet!, + "startHeight": lastScannedBlock, + "numberOfBlocks": scanChunkSize, + }, name: walletName); + + // get response + final message = await receivePort.first; + + // check for error message + if (message is String) { + throw Exception("scanOutPuts isolate failed: $message"); + } + + // attempt to grab next scanned block number + final nextScanned = int.tryParse(message['outputs'] as String); + if (nextScanned == null) { + throw Exception( + "scanOutPuts failed to parse next scanned block number from: $message", + ); + } + + return nextScanned; + } catch (_) { + rethrow; + } finally { + if (receivePort != null) { + // kill isolate + stop(receivePort); + } } - nextScannedBlock = int.parse(message['outputs'] as String); - stop(receivePort); - Logging.instance - .log('Closing scanOutPuts!\n $message', level: LogLevel.Info); }); - await epicUpdateLastScannedBlock(nextScannedBlock!); + + // update local cache + await epicUpdateLastScannedBlock(nextScannedBlock); + + // force firing of scan progress event await getSyncPercent; + + // update while loop condition variables + chainHeight = await this.chainHeight; + lastScannedBlock = nextScannedBlock; } - Logging.instance.log("successfully at the tip", level: LogLevel.Info); + + Logging.instance.log( + "_startScans successfully at the tip", + level: LogLevel.Info, + ); + //Once scanner completes restart listener await listenToEpicbox(); - return true; } catch (e, s) { - Logging.instance.log("$e, $s", level: LogLevel.Warning); - return false; + Logging.instance.log( + "_startScans failed: $e\n$s", + level: LogLevel.Error, + ); + rethrow; } } @@ -1494,24 +1526,7 @@ class EpicCashWallet extends CoinServiceAPI final int curAdd = await setCurrentIndex(); await _getReceivingAddressForIndex(curAdd); - if (!await startScans()) { - refreshMutex = false; - GlobalEventBus.instance.fire( - NodeConnectionStatusChangedEvent( - NodeConnectionStatus.disconnected, - walletId, - coin, - ), - ); - GlobalEventBus.instance.fire( - WalletSyncStatusChangedEvent( - WalletSyncStatus.unableToSync, - walletId, - coin, - ), - ); - return; - } + await _startScans(); unawaited(startSync()); @@ -1685,26 +1700,13 @@ class EpicCashWallet extends CoinServiceAPI final List> txnsData = []; - // int latestTxnBlockHeight = - // DB.instance.get(boxName: walletId, key: "storedTxnDataHeight") - // as int? ?? - // 0; final slatesToCommits = await getSlatesToCommits(); for (var tx in jsonTransactions) { Logging.instance.log("tx: $tx", level: LogLevel.Info); // // TODO: does "confirmed" mean finalized? If so please remove this todo final isConfirmed = tx["confirmed"] as bool; - // // TODO: since we are now caching tx history in hive are we losing anything by skipping here? - // // TODO: we can skip this filtering if it causes issues as the cache is later merged with updated data anyways - // // this would just make processing and updating cache more efficient - // if (txHeight > 0 && - // txHeight < latestTxnBlockHeight - MINIMUM_CONFIRMATIONS && - // isConfirmed) { - // continue; - // } - // Logging.instance.log("Transactions listed below"); - // Logging.instance.log(jsonTransactions); + int amt = 0; if (tx["tx_type"] == "TxReceived" || tx["tx_type"] == "TxReceivedCancelled") { @@ -1725,7 +1727,6 @@ class EpicCashWallet extends CoinServiceAPI String? commitId = slatesToCommits[slateId]?['commitId'] as String?; tx['numberOfMessages'] = tx['messages']?['messages']?.length; tx['onChainNote'] = tx['messages']?['messages']?[0]?['message']; - print("ON CHAIN MESSAGE IS ${tx['onChainNote']}"); int? height; @@ -1738,7 +1739,6 @@ class EpicCashWallet extends CoinServiceAPI final isIncoming = (tx["tx_type"] == "TxReceived" || tx["tx_type"] == "TxReceivedCancelled"); - final txn = isar_models.Transaction( walletId: walletId, txid: commitId ?? tx["id"].toString(), @@ -1763,7 +1763,9 @@ class EpicCashWallet extends CoinServiceAPI otherData: tx['onChainNote'].toString(), inputs: [], outputs: [], - numberOfMessages: ((tx["numberOfMessages"] == null) ? 0 : tx["numberOfMessages"]) as int, + numberOfMessages: ((tx["numberOfMessages"] == null) + ? 0 + : tx["numberOfMessages"]) as int, ); // txn.address = @@ -1805,24 +1807,7 @@ class EpicCashWallet extends CoinServiceAPI } } - // - // midSortedTx["inputSize"] = tx["num_inputs"]; - // midSortedTx["outputSize"] = tx["num_outputs"]; - // midSortedTx["aliens"] = []; - // midSortedTx["inputs"] = []; - // midSortedTx["outputs"] = []; - - // key id not used afaik? - // midSortedTx["key_id"] = tx["parent_key_id"]; - - // if (txHeight >= latestTxnBlockHeight) { - // latestTxnBlockHeight = txHeight; - // } - txnsData.add(Tuple2(txn, transactionAddress)); - // cachedMap?.remove(tx["id"].toString()); - // cachedMap?.remove(commitId); - // Logging.instance.log("cmap: $cachedMap", level: LogLevel.Info); } await db.addNewTransactionData(txnsData, walletId); @@ -1837,57 +1822,6 @@ class EpicCashWallet extends CoinServiceAPI ), ); } - - // midSortedArray - // .sort((a, b) => (b["timestamp"] as int) - (a["timestamp"] as int)); - // - // final Map result = {"dateTimeChunks": []}; - // final dateArray = []; - // - // for (int i = 0; i < midSortedArray.length; i++) { - // final txObject = midSortedArray[i]; - // final date = extractDateFromTimestamp(txObject["timestamp"] as int); - // - // final txTimeArray = [txObject["timestamp"], date]; - // - // if (dateArray.contains(txTimeArray[1])) { - // result["dateTimeChunks"].forEach((dynamic chunk) { - // if (extractDateFromTimestamp(chunk["timestamp"] as int) == - // txTimeArray[1]) { - // if (chunk["transactions"] == null) { - // chunk["transactions"] = >[]; - // } - // chunk["transactions"].add(txObject); - // } - // }); - // } else { - // dateArray.add(txTimeArray[1]); - // - // final chunk = { - // "timestamp": txTimeArray[0], - // "transactions": [txObject], - // };sendAll - // - // // result["dateTimeChunks"]. - // result["dateTimeChunks"].add(chunk); - // } - // } - // final transactionsMap = - // TransactionData.fromJson(result).getAllTransactions(); - // if (cachedMap != null) { - // transactionsMap.addAll(cachedMap); - // } - // - // final txModel = TransactionData.fromMap(transactionsMap); - // - // await DB.instance.put( - // boxName: walletId, - // key: 'storedTxnDataHeight', - // value: latestTxnBlockHeight); - // await DB.instance.put( - // boxName: walletId, key: 'latest_tx_model', value: txModel); - // - // return txModel; } @override diff --git a/lib/services/coins/ethereum/ethereum_wallet.dart b/lib/services/coins/ethereum/ethereum_wallet.dart index 62f3020e0..b3800a4e4 100644 --- a/lib/services/coins/ethereum/ethereum_wallet.dart +++ b/lib/services/coins/ethereum/ethereum_wallet.dart @@ -310,7 +310,9 @@ class EthereumWallet extends CoinServiceAPI with WalletCache, WalletDB { } @override - Future initializeNew() async { + Future initializeNew( + ({String mnemonicPassphrase, int wordCount})? data, + ) async { Logging.instance.log( "Generating new ${coin.prettyName} wallet.", level: LogLevel.Info, @@ -324,7 +326,7 @@ class EthereumWallet extends CoinServiceAPI with WalletCache, WalletDB { await _prefs.init(); try { - await _generateNewWallet(); + await _generateNewWallet(data); } catch (e, s) { Logging.instance.log( "Exception rethrown from initializeNew(): $e\n$s", @@ -338,7 +340,9 @@ class EthereumWallet extends CoinServiceAPI with WalletCache, WalletDB { ]); } - Future _generateNewWallet() async { + Future _generateNewWallet( + ({String mnemonicPassphrase, int wordCount})? data, + ) async { // Logging.instance // .log("IS_INTEGRATION_TEST: $integrationTestFlag", level: LogLevel.Info); // if (!integrationTestFlag) { @@ -366,14 +370,23 @@ class EthereumWallet extends CoinServiceAPI with WalletCache, WalletDB { "Attempted to overwrite mnemonic on generate new wallet!"); } - final String mnemonic = bip39.generateMnemonic(strength: 128); + final int strength; + if (data == null || data.wordCount == 12) { + strength = 128; + } else if (data.wordCount == 24) { + strength = 256; + } else { + throw Exception("Invalid word count"); + } + final String mnemonic = bip39.generateMnemonic(strength: strength); + final String passphrase = data?.mnemonicPassphrase ?? ""; await _secureStore.write(key: '${_walletId}_mnemonic', value: mnemonic); await _secureStore.write( key: '${_walletId}_mnemonicPassphrase', - value: "", + value: passphrase, ); - await _generateAndSaveAddress(mnemonic, ""); + await _generateAndSaveAddress(mnemonic, passphrase); Logging.instance.log("_generateNewWalletFinished", level: LogLevel.Info); } diff --git a/lib/services/coins/firo/firo_wallet.dart b/lib/services/coins/firo/firo_wallet.dart index a4cea6393..d765f8d0f 100644 --- a/lib/services/coins/firo/firo_wallet.dart +++ b/lib/services/coins/firo/firo_wallet.dart @@ -1875,7 +1875,9 @@ class FiroWallet extends CoinServiceAPI } @override - Future initializeNew() async { + Future initializeNew( + ({String mnemonicPassphrase, int wordCount})? data, + ) async { Logging.instance .log("Generating new ${coin.prettyName} wallet.", level: LogLevel.Info); @@ -1886,7 +1888,7 @@ class FiroWallet extends CoinServiceAPI await _prefs.init(); try { - await _generateNewWallet(); + await _generateNewWallet(data); } catch (e, s) { Logging.instance.log("Exception rethrown from initializeNew(): $e\n$s", level: LogLevel.Fatal); @@ -2124,7 +2126,9 @@ class FiroWallet extends CoinServiceAPI } /// Generates initial wallet values such as mnemonic, chain (receive/change) arrays and indexes. - Future _generateNewWallet() async { + Future _generateNewWallet( + ({String mnemonicPassphrase, int wordCount})? data, + ) async { Logging.instance .log("IS_INTEGRATION_TEST: $integrationTestFlag", level: LogLevel.Info); if (!integrationTestFlag) { @@ -2158,12 +2162,20 @@ class FiroWallet extends CoinServiceAPI longMutex = false; throw Exception("Attempted to overwrite mnemonic on initialize new!"); } + final int strength; + if (data == null || data.wordCount == 12) { + strength = 128; + } else if (data.wordCount == 24) { + strength = 256; + } else { + throw Exception("Invalid word count"); + } await _secureStore.write( key: '${_walletId}_mnemonic', - value: bip39.generateMnemonic(strength: 128)); + value: bip39.generateMnemonic(strength: strength)); await _secureStore.write( key: '${_walletId}_mnemonicPassphrase', - value: "", + value: data?.mnemonicPassphrase ?? "", ); // Generate and add addresses to relevant arrays @@ -3340,6 +3352,30 @@ class FiroWallet extends CoinServiceAPI List> allTransactions = []; + // some lelantus transactions aren't fetched via wallet addresses so they + // will never show as confirmed in the gui. + final unconfirmedTransactions = + await db.getTransactions(walletId).filter().heightIsNull().findAll(); + for (final tx in unconfirmedTransactions) { + final txn = await cachedElectrumXClient.getTransaction( + txHash: tx.txid, + verbose: true, + coin: coin, + ); + final height = txn["height"] as int?; + + if (height != null) { + // tx was mined + // add to allTxHashes + final info = { + "tx_hash": tx.txid, + "height": height, + "address": tx.address.value?.value, + }; + allTxHashes.add(info); + } + } + // final currentHeight = await chainHeight; for (final txHash in allTxHashes) { diff --git a/lib/services/coins/litecoin/litecoin_wallet.dart b/lib/services/coins/litecoin/litecoin_wallet.dart index 703ec5cf6..26718bc4e 100644 --- a/lib/services/coins/litecoin/litecoin_wallet.dart +++ b/lib/services/coins/litecoin/litecoin_wallet.dart @@ -1285,7 +1285,9 @@ class LitecoinWallet extends CoinServiceAPI bool get isConnected => _isConnected; @override - Future initializeNew() async { + Future initializeNew( + ({String mnemonicPassphrase, int wordCount})? data, + ) async { Logging.instance .log("Generating new ${coin.prettyName} wallet.", level: LogLevel.Info); @@ -1296,7 +1298,7 @@ class LitecoinWallet extends CoinServiceAPI await _prefs.init(); try { - await _generateNewWallet(); + await _generateNewWallet(data); } catch (e, s) { Logging.instance.log("Exception rethrown from initializeNew(): $e\n$s", level: LogLevel.Fatal); @@ -1535,7 +1537,9 @@ class LitecoinWallet extends CoinServiceAPI } } - Future _generateNewWallet() async { + Future _generateNewWallet( + ({String mnemonicPassphrase, int wordCount})? data, + ) async { Logging.instance .log("IS_INTEGRATION_TEST: $integrationTestFlag", level: LogLevel.Info); if (!integrationTestFlag) { @@ -1570,12 +1574,20 @@ class LitecoinWallet extends CoinServiceAPI throw Exception( "Attempted to overwrite mnemonic on generate new wallet!"); } + final int strength; + if (data == null || data.wordCount == 12) { + strength = 128; + } else if (data.wordCount == 24) { + strength = 256; + } else { + throw Exception("Invalid word count"); + } await _secureStore.write( key: '${_walletId}_mnemonic', - value: bip39.generateMnemonic(strength: 128)); + value: bip39.generateMnemonic(strength: strength)); await _secureStore.write( key: '${_walletId}_mnemonicPassphrase', - value: "", + value: data?.mnemonicPassphrase ?? "", ); // Generate and add addresses to relevant arrays diff --git a/lib/services/coins/manager.dart b/lib/services/coins/manager.dart index d94f7a99e..074c20499 100644 --- a/lib/services/coins/manager.dart +++ b/lib/services/coins/manager.dart @@ -181,7 +181,9 @@ class Manager with ChangeNotifier { Future testNetworkConnection() => _currentWallet.testNetworkConnection(); - Future initializeNew() => _currentWallet.initializeNew(); + Future initializeNew( + ({String mnemonicPassphrase, int wordCount})? data) => + _currentWallet.initializeNew(data); Future initializeExisting() => _currentWallet.initializeExisting(); Future recoverFromMnemonic({ required String mnemonic, diff --git a/lib/services/coins/monero/monero_wallet.dart b/lib/services/coins/monero/monero_wallet.dart index 5911e8592..a5284cc60 100644 --- a/lib/services/coins/monero/monero_wallet.dart +++ b/lib/services/coins/monero/monero_wallet.dart @@ -307,7 +307,9 @@ class MoneroWallet extends CoinServiceAPI with WalletCache, WalletDB { } @override - Future initializeNew() async { + Future initializeNew( + ({String mnemonicPassphrase, int wordCount})? data, + ) async { await _prefs.init(); // this should never fail diff --git a/lib/services/coins/namecoin/namecoin_wallet.dart b/lib/services/coins/namecoin/namecoin_wallet.dart index d0f30ecac..8b27fe426 100644 --- a/lib/services/coins/namecoin/namecoin_wallet.dart +++ b/lib/services/coins/namecoin/namecoin_wallet.dart @@ -1268,7 +1268,9 @@ class NamecoinWallet extends CoinServiceAPI bool get isConnected => _isConnected; @override - Future initializeNew() async { + Future initializeNew( + ({String mnemonicPassphrase, int wordCount})? data, + ) async { Logging.instance .log("Generating new ${coin.prettyName} wallet.", level: LogLevel.Info); @@ -1279,7 +1281,7 @@ class NamecoinWallet extends CoinServiceAPI await _prefs.init(); try { - await _generateNewWallet(); + await _generateNewWallet(data); } catch (e, s) { Logging.instance.log("Exception rethrown from initializeNew(): $e\n$s", level: LogLevel.Fatal); @@ -1517,7 +1519,9 @@ class NamecoinWallet extends CoinServiceAPI } } - Future _generateNewWallet() async { + Future _generateNewWallet( + ({String mnemonicPassphrase, int wordCount})? data, + ) async { Logging.instance .log("IS_INTEGRATION_TEST: $integrationTestFlag", level: LogLevel.Info); if (!integrationTestFlag) { @@ -1544,12 +1548,20 @@ class NamecoinWallet extends CoinServiceAPI throw Exception( "Attempted to overwrite mnemonic on generate new wallet!"); } + final int strength; + if (data == null || data.wordCount == 12) { + strength = 128; + } else if (data.wordCount == 24) { + strength = 256; + } else { + throw Exception("Invalid word count"); + } await _secureStore.write( key: '${_walletId}_mnemonic', - value: bip39.generateMnemonic(strength: 128)); + value: bip39.generateMnemonic(strength: strength)); await _secureStore.write( key: '${_walletId}_mnemonicPassphrase', - value: "", + value: data?.mnemonicPassphrase ?? "", ); // Generate and add addresses to relevant arrays diff --git a/lib/services/coins/nano/nano_wallet.dart b/lib/services/coins/nano/nano_wallet.dart index 391303675..56404ed1a 100644 --- a/lib/services/coins/nano/nano_wallet.dart +++ b/lib/services/coins/nano/nano_wallet.dart @@ -11,7 +11,6 @@ import 'dart:async'; import 'dart:convert'; -import 'package:http/http.dart' as http; import 'package:isar/isar.dart'; import 'package:nanodart/nanodart.dart'; import 'package:stackwallet/db/isar/main_db.dart'; @@ -19,6 +18,7 @@ import 'package:stackwallet/models/balance.dart'; import 'package:stackwallet/models/isar/models/isar_models.dart'; import 'package:stackwallet/models/node_model.dart'; import 'package:stackwallet/models/paymint/fee_object_model.dart'; +import 'package:stackwallet/networking/http.dart'; import 'package:stackwallet/services/coins/coin_service.dart'; import 'package:stackwallet/services/event_bus/events/global/node_connection_status_changed_event.dart'; import 'package:stackwallet/services/event_bus/events/global/updated_in_background_event.dart'; @@ -28,6 +28,7 @@ import 'package:stackwallet/services/mixins/wallet_cache.dart'; import 'package:stackwallet/services/mixins/wallet_db.dart'; import 'package:stackwallet/services/nano_api.dart'; import 'package:stackwallet/services/node_service.dart'; +import 'package:stackwallet/services/tor_service.dart'; import 'package:stackwallet/services/transaction_notification_tracker.dart'; import 'package:stackwallet/utilities/amount/amount.dart'; import 'package:stackwallet/utilities/constants.dart'; @@ -154,10 +155,12 @@ class NanoWallet extends CoinServiceAPI with WalletCache, WalletDB { Balance get balance => _balance ??= getCachedBalance(); Balance? _balance; + HTTP client = HTTP(); + Future requestWork(String hash) async { - return http + return client .post( - Uri.parse("https://rpc.nano.to"), // this should be a + url: Uri.parse("https://rpc.nano.to"), // this should be a headers: {'Content-type': 'application/json'}, body: json.encode( { @@ -165,9 +168,11 @@ class NanoWallet extends CoinServiceAPI with WalletCache, WalletDB { "hash": hash, }, ), + proxyInfo: + Prefs.instance.useTor ? TorService.sharedInstance.proxyInfo : null, ) - .then((http.Response response) { - if (response.statusCode == 200) { + .then((Response response) { + if (response.code == 200) { final Map decoded = json.decode(response.body) as Map; if (decoded.containsKey("error")) { @@ -175,7 +180,7 @@ class NanoWallet extends CoinServiceAPI with WalletCache, WalletDB { } return decoded["work"] as String?; } else { - throw Exception("Received error ${response.statusCode}"); + throw Exception("Received error ${response.body}"); } }); } @@ -194,10 +199,12 @@ class NanoWallet extends CoinServiceAPI with WalletCache, WalletDB { final headers = { "Content-Type": "application/json", }; - final balanceResponse = await http.post( - Uri.parse(getCurrentNode().host), + final balanceResponse = await client.post( + url: Uri.parse(getCurrentNode().host), headers: headers, body: balanceBody, + proxyInfo: + Prefs.instance.useTor ? TorService.sharedInstance.proxyInfo : null, ); final balanceData = jsonDecode(balanceResponse.body); @@ -212,10 +219,12 @@ class NanoWallet extends CoinServiceAPI with WalletCache, WalletDB { "representative": "true", "account": publicAddress, }); - final infoResponse = await http.post( - Uri.parse(getCurrentNode().host), + final infoResponse = await client.post( + url: Uri.parse(getCurrentNode().host), headers: headers, body: infoBody, + proxyInfo: + Prefs.instance.useTor ? TorService.sharedInstance.proxyInfo : null, ); final String frontier = @@ -265,10 +274,12 @@ class NanoWallet extends CoinServiceAPI with WalletCache, WalletDB { "subtype": "send", "block": sendBlock, }); - final processResponse = await http.post( - Uri.parse(getCurrentNode().host), + final processResponse = await client.post( + url: Uri.parse(getCurrentNode().host), headers: headers, body: processBody, + proxyInfo: + Prefs.instance.useTor ? TorService.sharedInstance.proxyInfo : null, ); final Map decoded = @@ -333,8 +344,13 @@ class NanoWallet extends CoinServiceAPI with WalletCache, WalletDB { final headers = { "Content-Type": "application/json", }; - final response = await http.post(Uri.parse(getCurrentNode().host), - headers: headers, body: body); + final response = await client.post( + url: Uri.parse(getCurrentNode().host), + headers: headers, + body: body, + proxyInfo: + Prefs.instance.useTor ? TorService.sharedInstance.proxyInfo : null, + ); final data = jsonDecode(response.body); _balance = Balance( total: Amount( @@ -372,10 +388,12 @@ class NanoWallet extends CoinServiceAPI with WalletCache, WalletDB { "representative": "true", "account": publicAddress, }); - final infoResponse = await http.post( - Uri.parse(getCurrentNode().host), + final infoResponse = await client.post( + url: Uri.parse(getCurrentNode().host), headers: headers, body: infoBody, + proxyInfo: + Prefs.instance.useTor ? TorService.sharedInstance.proxyInfo : null, ); final infoData = jsonDecode(infoResponse.body); @@ -390,10 +408,12 @@ class NanoWallet extends CoinServiceAPI with WalletCache, WalletDB { "account": publicAddress, }); - final balanceResponse = await http.post( - Uri.parse(getCurrentNode().host), + final balanceResponse = await client.post( + url: Uri.parse(getCurrentNode().host), headers: headers, body: balanceBody, + proxyInfo: + Prefs.instance.useTor ? TorService.sharedInstance.proxyInfo : null, ); final balanceData = jsonDecode(balanceResponse.body); @@ -463,10 +483,12 @@ class NanoWallet extends CoinServiceAPI with WalletCache, WalletDB { "subtype": "receive", "block": receiveBlock, }); - final processResponse = await http.post( - Uri.parse(getCurrentNode().host), + final processResponse = await client.post( + url: Uri.parse(getCurrentNode().host), headers: headers, body: processBody, + proxyInfo: + Prefs.instance.useTor ? TorService.sharedInstance.proxyInfo : null, ); final Map decoded = @@ -477,14 +499,18 @@ class NanoWallet extends CoinServiceAPI with WalletCache, WalletDB { } Future confirmAllReceivable() async { - final receivableResponse = await http.post(Uri.parse(getCurrentNode().host), - headers: {"Content-Type": "application/json"}, - body: jsonEncode({ - "action": "receivable", - "source": "true", - "account": await currentReceivingAddress, - "count": "-1", - })); + final receivableResponse = await client.post( + url: Uri.parse(getCurrentNode().host), + headers: {"Content-Type": "application/json"}, + body: jsonEncode({ + "action": "receivable", + "source": "true", + "account": await currentReceivingAddress, + "count": "-1", + }), + proxyInfo: + Prefs.instance.useTor ? TorService.sharedInstance.proxyInfo : null, + ); final receivableData = await jsonDecode(receivableResponse.body); if (receivableData["blocks"] == "") { @@ -506,13 +532,17 @@ class NanoWallet extends CoinServiceAPI with WalletCache, WalletDB { await confirmAllReceivable(); 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({ - "action": "account_history", - "account": publicAddress, - "count": "-1", - })); + final response = await client.post( + url: Uri.parse(getCurrentNode().host), + headers: {"Content-Type": "application/json"}, + body: jsonEncode({ + "action": "account_history", + "account": publicAddress, + "count": "-1", + }), + proxyInfo: + Prefs.instance.useTor ? TorService.sharedInstance.proxyInfo : null, + ); final data = await jsonDecode(response.body); final transactions = data["history"] is List ? data["history"] as List : []; @@ -607,7 +637,9 @@ class NanoWallet extends CoinServiceAPI with WalletCache, WalletDB { } @override - Future initializeNew() async { + Future initializeNew( + ({String mnemonicPassphrase, int wordCount})? data, + ) async { if ((await mnemonicString) != null || (await mnemonicPassphrase) != null) { throw Exception( "Attempted to overwrite mnemonic on generate new wallet!"); @@ -828,17 +860,19 @@ class NanoWallet extends CoinServiceAPI with WalletCache, WalletDB { Future testNetworkConnection() async { final uri = Uri.parse(getCurrentNode().host); - final response = await http.post( - uri, + final response = await client.post( + url: uri, headers: {"Content-Type": "application/json"}, body: jsonEncode( { "action": "version", }, ), + proxyInfo: + Prefs.instance.useTor ? TorService.sharedInstance.proxyInfo : null, ); - return response.statusCode == 200; + return response.code == 200; } Timer? _networkAliveTimer; @@ -924,10 +958,12 @@ class NanoWallet extends CoinServiceAPI with WalletCache, WalletDB { final headers = { "Content-Type": "application/json", }; - final infoResponse = await http.post( - Uri.parse(getCurrentNode().host), + final infoResponse = await client.post( + url: Uri.parse(getCurrentNode().host), headers: headers, body: infoBody, + proxyInfo: + Prefs.instance.useTor ? TorService.sharedInstance.proxyInfo : null, ); final infoData = jsonDecode(infoResponse.body); diff --git a/lib/services/coins/particl/particl_wallet.dart b/lib/services/coins/particl/particl_wallet.dart index 324e8d9e5..33064ef85 100644 --- a/lib/services/coins/particl/particl_wallet.dart +++ b/lib/services/coins/particl/particl_wallet.dart @@ -1195,7 +1195,9 @@ class ParticlWallet extends CoinServiceAPI bool get isConnected => _isConnected; @override - Future initializeNew() async { + Future initializeNew( + ({String mnemonicPassphrase, int wordCount})? data, + ) async { Logging.instance .log("Generating new ${coin.prettyName} wallet.", level: LogLevel.Info); @@ -1206,7 +1208,7 @@ class ParticlWallet extends CoinServiceAPI await _prefs.init(); try { - await _generateNewWallet(); + await _generateNewWallet(data); } catch (e, s) { Logging.instance.log("Exception rethrown from initializeNew(): $e\n$s", level: LogLevel.Fatal); @@ -1432,7 +1434,9 @@ class ParticlWallet extends CoinServiceAPI } } - Future _generateNewWallet() async { + Future _generateNewWallet( + ({String mnemonicPassphrase, int wordCount})? data, + ) async { Logging.instance .log("IS_INTEGRATION_TEST: $integrationTestFlag", level: LogLevel.Info); if (!integrationTestFlag) { @@ -1459,12 +1463,20 @@ class ParticlWallet extends CoinServiceAPI throw Exception( "Attempted to overwrite mnemonic on generate new wallet!"); } + final int strength; + if (data == null || data.wordCount == 12) { + strength = 128; + } else if (data.wordCount == 24) { + strength = 256; + } else { + throw Exception("Invalid word count"); + } await _secureStore.write( key: '${_walletId}_mnemonic', - value: bip39.generateMnemonic(strength: 128)); + value: bip39.generateMnemonic(strength: strength)); await _secureStore.write( key: '${_walletId}_mnemonicPassphrase', - value: "", + value: data?.mnemonicPassphrase ?? "", ); // Generate and add addresses to relevant arrays diff --git a/lib/services/coins/stellar/stellar_wallet.dart b/lib/services/coins/stellar/stellar_wallet.dart index c4c92373f..8efe7fbdd 100644 --- a/lib/services/coins/stellar/stellar_wallet.dart +++ b/lib/services/coins/stellar/stellar_wallet.dart @@ -1,6 +1,6 @@ import 'dart:async'; -import 'package:http/http.dart' as http; +import 'package:bip39/bip39.dart' as bip39; import 'package:isar/isar.dart'; import 'package:stackwallet/db/isar/main_db.dart'; import 'package:stackwallet/models/balance.dart' as SWBalance; @@ -28,6 +28,7 @@ import 'package:stackwallet/utilities/enums/fee_rate_type_enum.dart'; import 'package:stackwallet/utilities/flutter_secure_storage_interface.dart'; import 'package:stackwallet/utilities/logger.dart'; import 'package:stackwallet/utilities/prefs.dart'; +import 'package:stackwallet/utilities/test_stellar_node_connection.dart'; import 'package:stellar_flutter_sdk/stellar_flutter_sdk.dart'; import 'package:tuple/tuple.dart'; @@ -53,20 +54,25 @@ class StellarWallet extends CoinServiceAPI with WalletCache, WalletDB { initCache(walletId, coin); initWalletDB(mockableOverride: mockableOverride); - if (coin.name == "stellarTestnet") { - stellarSdk = StellarSDK.TESTNET; + if (coin.isTestNet) { stellarNetwork = Network.TESTNET; } else { - stellarSdk = StellarSDK.PUBLIC; stellarNetwork = Network.PUBLIC; } + + _updateNode(); + } + + void _updateNode() { + _xlmNode = NodeService(secureStorageInterface: _secureStore) + .getPrimaryNodeFor(coin: coin) ?? + DefaultNodes.getNodeFor(coin); + stellarSdk = StellarSDK("${_xlmNode!.host}:${_xlmNode!.port}"); } late final TransactionNotificationTracker txTracker; late SecureStorageInterface _secureStore; - // final StellarSDK stellarSdk = StellarSDK.PUBLIC; - @override bool get isFavorite => _isFavorite ??= getCachedIsFavorite(); bool? _isFavorite; @@ -175,6 +181,41 @@ class StellarWallet extends CoinServiceAPI with WalletCache, WalletDB { return exists; } + @override + Future> prepareSend( + {required String address, + required Amount amount, + Map? args}) async { + try { + final feeRate = args?["feeRate"]; + var fee = 1000; + if (feeRate is FeeRateType) { + final theFees = await fees; + switch (feeRate) { + case FeeRateType.fast: + fee = theFees.fast; + case FeeRateType.slow: + fee = theFees.slow; + case FeeRateType.average: + default: + fee = theFees.medium; + } + } + Map txData = { + "fee": fee, + "address": address, + "recipientAmt": amount, + "memo": args?["memo"] as String?, + }; + + Logging.instance.log("prepare send: $txData", level: LogLevel.Info); + return txData; + } catch (e, s) { + Logging.instance.log("Error getting fees $e - $s", level: LogLevel.Error); + rethrow; + } + } + @override Future confirmSend({required Map txData}) async { final secretSeed = await _secureStore.read(key: '${_walletId}_secretSeed'); @@ -182,34 +223,41 @@ class StellarWallet extends CoinServiceAPI with WalletCache, WalletDB { AccountResponse sender = await stellarSdk.accounts.account(senderKeyPair.accountId); final amountToSend = txData['recipientAmt'] as Amount; + final memo = txData["memo"] as String?; //First check if account exists, can be skipped, but if the account does not exist, // the transaction fee will be charged when the transaction fails. bool validAccount = await _accountExists(txData['address'] as String); - Transaction transaction; + TransactionBuilder transactionBuilder; if (!validAccount) { //Fund the account, user must ensure account is correct CreateAccountOperationBuilder createAccBuilder = CreateAccountOperationBuilder( txData['address'] as String, amountToSend.decimal.toString()); - transaction = TransactionBuilder(sender) - .addOperation(createAccBuilder.build()) - .build(); + transactionBuilder = + TransactionBuilder(sender).addOperation(createAccBuilder.build()); } else { - transaction = TransactionBuilder(sender) - .addOperation(PaymentOperationBuilder(txData['address'] as String, - Asset.NATIVE, amountToSend.decimal.toString()) - .build()) - .build(); + transactionBuilder = TransactionBuilder(sender).addOperation( + PaymentOperationBuilder(txData['address'] as String, Asset.NATIVE, + amountToSend.decimal.toString()) + .build()); } + + if (memo != null) { + transactionBuilder.addMemo(MemoText(memo)); + } + + final transaction = transactionBuilder.build(); + transaction.sign(senderKeyPair, stellarNetwork); try { - SubmitTransactionResponse response = - await stellarSdk.submitTransaction(transaction); - + SubmitTransactionResponse response = await stellarSdk + .submitTransaction(transaction) + .onError((error, stackTrace) => throw (error.toString())); if (!response.success) { - throw ("Unable to send transaction"); + throw ("${response.extras?.resultCodes?.transactionResultCode}" + " ::: ${response.extras?.resultCodes?.operationsResultCodes}"); } return response.hash!; } catch (e, s) { @@ -232,32 +280,15 @@ class StellarWallet extends CoinServiceAPI with WalletCache, WalletDB { (await _currentReceivingAddress)?.value ?? await getAddressSW(); Future getBaseFee() async { - // final nodeURI = Uri.parse("${getCurrentNode().host}:${getCurrentNode().port}"); - final nodeURI = Uri.parse(getCurrentNode().host); - final httpClient = http.Client(); - FeeStatsResponse fsp = - await FeeStatsRequestBuilder(httpClient, nodeURI).execute(); - return int.parse(fsp.lastLedgerBaseFee); + var fees = await stellarSdk.feeStats.execute(); + return int.parse(fees.lastLedgerBaseFee); } @override Future estimateFeeFor(Amount amount, int feeRate) async { var baseFee = await getBaseFee(); - int fee = 100; - switch (feeRate) { - case 0: - fee = baseFee * 10; - case 1: - case 2: - fee = baseFee * 50; - case 3: - fee = baseFee * 100; - case 4: - fee = baseFee * 200; - default: - fee = baseFee * 50; - } - return Amount(rawValue: BigInt.from(fee), fractionDigits: coin.decimals); + return Amount( + rawValue: BigInt.from(baseFee), fractionDigits: coin.decimals); } @override @@ -285,34 +316,74 @@ class StellarWallet extends CoinServiceAPI with WalletCache, WalletDB { @override Future get fees async { - // final nodeURI = Uri.parse("${getCurrentNode().host}:${getCurrentNode().port}"); - final nodeURI = Uri.parse(getCurrentNode().host); - - final httpClient = http.Client(); - FeeStatsResponse fsp = - await FeeStatsRequestBuilder(httpClient, nodeURI).execute(); - + int fee = await getBaseFee(); return FeeObject( - numberOfBlocksFast: 0, - numberOfBlocksAverage: 0, - numberOfBlocksSlow: 0, - fast: int.parse(fsp.lastLedgerBaseFee) * 100, - medium: int.parse(fsp.lastLedgerBaseFee) * 50, - slow: int.parse(fsp.lastLedgerBaseFee) * 10); + numberOfBlocksFast: 10, + numberOfBlocksAverage: 10, + numberOfBlocksSlow: 10, + fast: fee, + medium: fee, + slow: fee); } @override Future fullRescan( - int maxUnusedAddressGap, int maxNumberOfIndexesToCheck) async { - await _prefs.init(); - await updateTransactions(); - await updateChainHeight(); - await updateBalance(); + int maxUnusedAddressGap, + int maxNumberOfIndexesToCheck, + ) async { + try { + Logging.instance.log("Starting full rescan!", level: LogLevel.Info); + longMutex = true; + GlobalEventBus.instance.fire( + WalletSyncStatusChangedEvent( + WalletSyncStatus.syncing, + walletId, + coin, + ), + ); + + final _mnemonic = await mnemonicString; + final _mnemonicPassphrase = await mnemonicPassphrase; + + await db.deleteWalletBlockchainData(walletId); + + await _recoverWalletFromBIP32SeedPhrase( + mnemonic: _mnemonic!, + mnemonicPassphrase: _mnemonicPassphrase!, + isRescan: true, + ); + + await refresh(); + Logging.instance.log("Full rescan complete!", level: LogLevel.Info); + GlobalEventBus.instance.fire( + WalletSyncStatusChangedEvent( + WalletSyncStatus.synced, + walletId, + coin, + ), + ); + } catch (e, s) { + GlobalEventBus.instance.fire( + WalletSyncStatusChangedEvent( + WalletSyncStatus.unableToSync, + walletId, + coin, + ), + ); + + Logging.instance.log( + "Exception rethrown from fullRescan(): $e\n$s", + level: LogLevel.Error, + ); + rethrow; + } finally { + longMutex = false; + } } @override Future generateNewAddress() { - // TODO: implement generateNewAddress + // not used for stellar(?) throw UnimplementedError(); } @@ -326,7 +397,9 @@ class StellarWallet extends CoinServiceAPI with WalletCache, WalletDB { } @override - Future initializeNew() async { + Future initializeNew( + ({String mnemonicPassphrase, int wordCount})? data, + ) async { if ((await mnemonicString) != null || (await mnemonicPassphrase) != null) { throw Exception( "Attempted to overwrite mnemonic on generate new wallet!"); @@ -334,11 +407,26 @@ class StellarWallet extends CoinServiceAPI with WalletCache, WalletDB { await _prefs.init(); - String mnemonic = await Wallet.generate24WordsMnemonic(); + final int strength; + if (data == null || data.wordCount == 12) { + strength = 128; + } else if (data.wordCount == 24) { + strength = 256; + } else { + throw Exception("Invalid word count"); + } + final String mnemonic = bip39.generateMnemonic(strength: strength); + final String passphrase = data?.mnemonicPassphrase ?? ""; await _secureStore.write(key: '${_walletId}_mnemonic', value: mnemonic); - await _secureStore.write(key: '${_walletId}_mnemonicPassphrase', value: ""); + await _secureStore.write( + key: '${_walletId}_mnemonicPassphrase', + value: passphrase, + ); - Wallet wallet = await Wallet.from(mnemonic); + Wallet wallet = await Wallet.from( + mnemonic, + passphrase: passphrase, + ); KeyPair keyPair = await wallet.getKeyPair(index: 0); String address = keyPair.accountId; String secretSeed = @@ -394,78 +482,87 @@ class StellarWallet extends CoinServiceAPI with WalletCache, WalletDB { Future get mnemonicString => _secureStore.read(key: '${_walletId}_mnemonic'); - @override - Future> prepareSend( - {required String address, - required Amount amount, - Map? args}) async { - try { - final feeRate = args?["feeRate"]; - var fee = 1000; - if (feeRate is FeeRateType) { - final theFees = await fees; - switch (feeRate) { - case FeeRateType.fast: - fee = theFees.fast; - case FeeRateType.slow: - fee = theFees.slow; - case FeeRateType.average: - default: - fee = theFees.medium; - } - } - Map txData = { - "fee": fee, - "address": address, - "recipientAmt": amount, - }; + Future _recoverWalletFromBIP32SeedPhrase({ + required String mnemonic, + required String mnemonicPassphrase, + bool isRescan = false, + }) async { + final Wallet wallet = await Wallet.from( + mnemonic, + passphrase: mnemonicPassphrase, + ); + final KeyPair keyPair = await wallet.getKeyPair(index: 0); + final String address = keyPair.accountId; + String secretSeed = + keyPair.secretSeed; //This will be required for sending a tx - Logging.instance.log("prepare send: $txData", level: LogLevel.Info); - return txData; - } catch (e, s) { - Logging.instance.log("Error getting fees $e - $s", level: LogLevel.Error); - rethrow; + await _secureStore.write( + key: '${_walletId}_secretSeed', + value: secretSeed, + ); + + final swAddress = SWAddress.Address( + walletId: walletId, + value: address, + publicKey: keyPair.publicKey, + derivationIndex: 0, + derivationPath: null, + type: SWAddress.AddressType.unknown, + subType: SWAddress.AddressSubType.unknown, + ); + + if (isRescan) { + await db.updateOrPutAddresses([swAddress]); + } else { + await db.putAddress(swAddress); } } + bool longMutex = false; + @override - Future recoverFromMnemonic( - {required String mnemonic, - String? mnemonicPassphrase, - required int maxUnusedAddressGap, - required int maxNumberOfIndexesToCheck, - required int height}) async { - if ((await mnemonicString) != null || - (await this.mnemonicPassphrase) != null) { - throw Exception("Attempted to overwrite mnemonic on restore!"); + Future recoverFromMnemonic({ + required String mnemonic, + String? mnemonicPassphrase, + required int maxUnusedAddressGap, + required int maxNumberOfIndexesToCheck, + required int height, + }) async { + longMutex = true; + try { + if ((await mnemonicString) != null || + (await this.mnemonicPassphrase) != null) { + throw Exception("Attempted to overwrite mnemonic on restore!"); + } + + await _secureStore.write( + key: '${_walletId}_mnemonic', + value: mnemonic.trim(), + ); + await _secureStore.write( + key: '${_walletId}_mnemonicPassphrase', + value: mnemonicPassphrase ?? "", + ); + + await _recoverWalletFromBIP32SeedPhrase( + mnemonic: mnemonic, + mnemonicPassphrase: mnemonicPassphrase ?? "", + isRescan: false, + ); + + await Future.wait([ + updateCachedId(walletId), + updateCachedIsFavorite(false), + ]); + } catch (e, s) { + Logging.instance.log( + "Exception rethrown from recoverFromMnemonic(): $e\n$s", + level: LogLevel.Error); + + rethrow; + } finally { + longMutex = false; } - - var wallet = await Wallet.from(mnemonic); - var keyPair = await wallet.getKeyPair(index: 0); - var address = keyPair.accountId; - var secretSeed = keyPair.secretSeed; - - await _secureStore.write( - key: '${_walletId}_mnemonic', value: mnemonic.trim()); - await _secureStore.write( - key: '${_walletId}_mnemonicPassphrase', - value: mnemonicPassphrase ?? "", - ); - await _secureStore.write(key: '${_walletId}_secretSeed', value: secretSeed); - - final swAddress = SWAddress.Address( - walletId: walletId, - value: address, - publicKey: keyPair.publicKey, - derivationIndex: 0, - derivationPath: null, - type: SWAddress.AddressType.unknown, // TODO: set type - subType: SWAddress.AddressSubType.unknown); - - await db.putAddress(swAddress); - - await Future.wait( - [updateCachedId(walletId), updateCachedIsFavorite(false)]); } Future updateChainHeight() async { @@ -482,26 +579,34 @@ class StellarWallet extends CoinServiceAPI with WalletCache, WalletDB { try { List> transactionList = []; - - Page payments = await stellarSdk.payments - .forAccount(await getAddressSW()) - .order(RequestBuilderOrder.DESC) - .execute() - .onError( - (error, stackTrace) => throw ("Could not fetch transactions")); - + Page payments; + try { + payments = await stellarSdk.payments + .forAccount(await getAddressSW()) + .order(RequestBuilderOrder.DESC) + .execute() + .onError((error, stackTrace) => throw error!); + } catch (e) { + if (e is ErrorResponse && + e.body.contains("The resource at the url requested was not found. " + "This usually occurs for one of two reasons: " + "The url requested is not valid, or no data in our database " + "could be found with the parameters provided.")) { + // probably just doesn't have any history yet or whatever stellar needs + return; + } else { + Logging.instance.log( + "Stellar $walletName $walletId failed to fetch transactions", + level: LogLevel.Warning, + ); + rethrow; + } + } for (OperationResponse response in payments.records!) { // PaymentOperationResponse por; if (response is PaymentOperationResponse) { PaymentOperationResponse por = response; - Logging.instance.log( - "ALL TRANSACTIONS IS ${por.transactionSuccessful}", - level: LogLevel.Info); - - Logging.instance.log("THIS TX HASH IS ${por.transactionHash}", - level: LogLevel.Info); - SWTransaction.TransactionType type; if (por.sourceAccount == await getAddressSW()) { type = SWTransaction.TransactionType.outgoing; @@ -628,13 +733,35 @@ class StellarWallet extends CoinServiceAPI with WalletCache, WalletDB { Logging.instance.log( "Exception rethrown from updateTransactions(): $e\n$s", level: LogLevel.Error); + rethrow; } } Future updateBalance() async { try { - AccountResponse accountResponse = - await stellarSdk.accounts.account(await getAddressSW()); + AccountResponse accountResponse; + + try { + accountResponse = await stellarSdk.accounts + .account(await getAddressSW()) + .onError((error, stackTrace) => throw error!); + } catch (e) { + if (e is ErrorResponse && + e.body.contains("The resource at the url requested was not found. " + "This usually occurs for one of two reasons: " + "The url requested is not valid, or no data in our database " + "could be found with the parameters provided.")) { + // probably just doesn't have any history yet or whatever stellar needs + return; + } else { + Logging.instance.log( + "Stellar $walletName $walletId failed to fetch transactions", + level: LogLevel.Warning, + ); + rethrow; + } + } + for (Balance balance in accountResponse.balances) { switch (balance.assetType) { case Asset.TYPE_NATIVE: @@ -665,6 +792,7 @@ class StellarWallet extends CoinServiceAPI with WalletCache, WalletDB { "ERROR GETTING BALANCE $e\n$s", level: LogLevel.Info, ); + rethrow; } } @@ -739,9 +867,8 @@ class StellarWallet extends CoinServiceAPI with WalletCache, WalletDB { int get storedChainHeight => getCachedChainHeight(); @override - Future testNetworkConnection() { - // TODO: implement testNetworkConnection - throw UnimplementedError(); + Future testNetworkConnection() async { + return await testStellarNodeConnection(_xlmNode!.host, _xlmNode!.port); } @override @@ -750,10 +877,7 @@ class StellarWallet extends CoinServiceAPI with WalletCache, WalletDB { @override Future updateNode(bool shouldRefresh) async { - _xlmNode = NodeService(secureStorageInterface: _secureStore) - .getPrimaryNodeFor(coin: coin) ?? - DefaultNodes.getNodeFor(coin); - + _updateNode(); if (shouldRefresh) { unawaited(refresh()); } @@ -795,7 +919,7 @@ class StellarWallet extends CoinServiceAPI with WalletCache, WalletDB { } @override - // TODO: implement utxos + // not used Future> get utxos => throw UnimplementedError(); @override diff --git a/lib/services/coins/tezos/tezos_wallet.dart b/lib/services/coins/tezos/tezos_wallet.dart new file mode 100644 index 000000000..130671264 --- /dev/null +++ b/lib/services/coins/tezos/tezos_wallet.dart @@ -0,0 +1,776 @@ +import 'dart:async'; +import 'dart:convert'; + +import 'package:decimal/decimal.dart'; +import 'package:isar/isar.dart'; +import 'package:stackwallet/db/isar/main_db.dart'; +import 'package:stackwallet/models/balance.dart'; +import 'package:stackwallet/models/isar/models/blockchain_data/address.dart'; +import 'package:stackwallet/models/isar/models/blockchain_data/transaction.dart'; +import 'package:stackwallet/models/isar/models/blockchain_data/utxo.dart'; +import 'package:stackwallet/models/node_model.dart'; +import 'package:stackwallet/models/paymint/fee_object_model.dart'; +import 'package:stackwallet/networking/http.dart'; +import 'package:stackwallet/services/coins/coin_service.dart'; +import 'package:stackwallet/services/event_bus/events/global/node_connection_status_changed_event.dart'; +import 'package:stackwallet/services/event_bus/events/global/updated_in_background_event.dart'; +import 'package:stackwallet/services/event_bus/events/global/wallet_sync_status_changed_event.dart'; +import 'package:stackwallet/services/event_bus/global_event_bus.dart'; +import 'package:stackwallet/services/mixins/wallet_cache.dart'; +import 'package:stackwallet/services/mixins/wallet_db.dart'; +import 'package:stackwallet/services/node_service.dart'; +import 'package:stackwallet/services/tor_service.dart'; +import 'package:stackwallet/services/transaction_notification_tracker.dart'; +import 'package:stackwallet/utilities/amount/amount.dart'; +import 'package:stackwallet/utilities/constants.dart'; +import 'package:stackwallet/utilities/default_nodes.dart'; +import 'package:stackwallet/utilities/enums/coin_enum.dart'; +import 'package:stackwallet/utilities/enums/fee_rate_type_enum.dart'; +import 'package:stackwallet/utilities/flutter_secure_storage_interface.dart'; +import 'package:stackwallet/utilities/logger.dart'; +import 'package:stackwallet/utilities/prefs.dart'; +import 'package:tezart/tezart.dart'; +import 'package:tuple/tuple.dart'; + +const int MINIMUM_CONFIRMATIONS = 1; +const int _gasLimit = 10200; + +class TezosWallet extends CoinServiceAPI with WalletCache, WalletDB { + TezosWallet({ + required String walletId, + required String walletName, + required Coin coin, + required SecureStorageInterface secureStore, + required TransactionNotificationTracker tracker, + MainDB? mockableOverride, + }) { + txTracker = tracker; + _walletId = walletId; + _walletName = walletName; + _coin = coin; + _secureStore = secureStore; + initCache(walletId, coin); + initWalletDB(mockableOverride: mockableOverride); + } + + NodeModel? _xtzNode; + + NodeModel getCurrentNode() { + return _xtzNode ?? + NodeService(secureStorageInterface: _secureStore) + .getPrimaryNodeFor(coin: Coin.tezos) ?? + DefaultNodes.getNodeFor(Coin.tezos); + } + + Future getKeystore() async { + return Keystore.fromMnemonic((await mnemonicString).toString()); + } + + @override + String get walletId => _walletId; + late String _walletId; + + @override + String get walletName => _walletName; + late String _walletName; + + @override + set walletName(String name) => _walletName = name; + + @override + set isFavorite(bool markFavorite) { + _isFavorite = markFavorite; + updateCachedIsFavorite(markFavorite); + } + + @override + bool get isFavorite => _isFavorite ??= getCachedIsFavorite(); + bool? _isFavorite; + + @override + Coin get coin => _coin; + late Coin _coin; + + late SecureStorageInterface _secureStore; + late final TransactionNotificationTracker txTracker; + final _prefs = Prefs.instance; + + Timer? timer; + bool _shouldAutoSync = false; + Timer? _networkAliveTimer; + + @override + bool get shouldAutoSync => _shouldAutoSync; + + HTTP client = HTTP(); + + @override + set shouldAutoSync(bool shouldAutoSync) { + if (_shouldAutoSync != shouldAutoSync) { + _shouldAutoSync = shouldAutoSync; + if (!shouldAutoSync) { + timer?.cancel(); + timer = null; + stopNetworkAlivePinging(); + } else { + startNetworkAlivePinging(); + refresh(); + } + } + } + + void startNetworkAlivePinging() { + // call once on start right away + _periodicPingCheck(); + + // then periodically check + _networkAliveTimer = Timer.periodic( + Constants.networkAliveTimerDuration, + (_) async { + _periodicPingCheck(); + }, + ); + } + + void stopNetworkAlivePinging() { + _networkAliveTimer?.cancel(); + _networkAliveTimer = null; + } + + void _periodicPingCheck() async { + bool hasNetwork = await testNetworkConnection(); + + if (_isConnected != hasNetwork) { + NodeConnectionStatus status = hasNetwork + ? NodeConnectionStatus.connected + : NodeConnectionStatus.disconnected; + + GlobalEventBus.instance.fire( + NodeConnectionStatusChangedEvent( + status, + walletId, + coin, + ), + ); + + _isConnected = hasNetwork; + if (hasNetwork) { + unawaited(refresh()); + } + } + } + + @override + Balance get balance => _balance ??= getCachedBalance(); + Balance? _balance; + + @override + Future> prepareSend( + {required String address, + required Amount amount, + Map? args}) async { + try { + if (amount.decimals != coin.decimals) { + throw Exception("Amount decimals do not match coin decimals!"); + } + var fee = int.parse((await estimateFeeFor( + amount, (args!["feeRate"] as FeeRateType).index)) + .raw + .toString()); + Map txData = { + "fee": fee, + "address": address, + "recipientAmt": amount, + }; + return Future.value(txData); + } catch (e) { + return Future.error(e); + } + } + + @override + Future confirmSend({required Map txData}) async { + try { + final amount = txData["recipientAmt"] as Amount; + final amountInMicroTez = amount.decimal * Decimal.fromInt(1000000); + final microtezToInt = int.parse(amountInMicroTez.toString()); + + final int feeInMicroTez = int.parse(txData["fee"].toString()); + final String destinationAddress = txData["address"] as String; + final secretKey = + Keystore.fromMnemonic((await mnemonicString)!).secretKey; + + Logging.instance.log(secretKey, level: LogLevel.Info); + final sourceKeyStore = Keystore.fromSecretKey(secretKey); + final client = TezartClient(getCurrentNode().host); + + int? sendAmount = microtezToInt; + int gasLimit = _gasLimit; + int thisFee = feeInMicroTez; + + if (balance.spendable == txData["recipientAmt"] as Amount) { + //Fee guides for emptying a tz account + // https://github.com/TezTech/eztz/blob/master/PROTO_004_FEES.md + thisFee = thisFee + 32; + sendAmount = microtezToInt - thisFee; + gasLimit = _gasLimit + 320; + } + + final operation = await client.transferOperation( + source: sourceKeyStore, + destination: destinationAddress, + amount: sendAmount, + customFee: feeInMicroTez, + customGasLimit: gasLimit); + await operation.executeAndMonitor(); + return operation.result.id as String; + } catch (e) { + Logging.instance.log(e.toString(), level: LogLevel.Error); + return Future.error(e); + } + } + + @override + Future get currentReceivingAddress async { + var mneString = await mnemonicString; + if (mneString == null) { + throw Exception("No mnemonic found!"); + } + return Future.value((Keystore.fromMnemonic(mneString)).address); + } + + @override + Future estimateFeeFor(Amount amount, int feeRate) async { + var api = "https://api.tzstats.com/series/op?start_date=today&collapse=1d"; + var response = jsonDecode((await client.get( + url: Uri.parse(api), + proxyInfo: + Prefs.instance.useTor ? TorService.sharedInstance.proxyInfo : null, + )) + .body)[0]; + double totalFees = response[4] as double; + int totalTxs = response[8] as int; + int feePerTx = (totalFees / totalTxs * 1000000).floor(); + + return Amount( + rawValue: BigInt.from(feePerTx), + fractionDigits: coin.decimals, + ); + } + + @override + Future exit() { + _hasCalledExit = true; + return Future.value(); + } + + @override + Future get fees async { + var api = "https://api.tzstats.com/series/op?start_date=today&collapse=10d"; + var response = jsonDecode((await client.get( + url: Uri.parse(api), + proxyInfo: + Prefs.instance.useTor ? TorService.sharedInstance.proxyInfo : null, + )) + .body); + double totalFees = response[0][4] as double; + int totalTxs = response[0][8] as int; + int feePerTx = (totalFees / totalTxs * 1000000).floor(); + Logging.instance.log("feePerTx:$feePerTx", level: LogLevel.Info); + // TODO: fix numberOfBlocks - Since there is only one fee no need to set blocks + return FeeObject( + numberOfBlocksFast: 10, + numberOfBlocksAverage: 10, + numberOfBlocksSlow: 10, + fast: feePerTx, + medium: feePerTx, + slow: feePerTx, + ); + } + + @override + Future generateNewAddress() { + // TODO: implement generateNewAddress + throw UnimplementedError(); + } + + @override + bool get hasCalledExit => _hasCalledExit; + bool _hasCalledExit = false; + + @override + Future initializeExisting() async { + await _prefs.init(); + } + + @override + Future initializeNew( + ({String mnemonicPassphrase, int wordCount})? data, + ) async { + if ((await mnemonicString) != null || (await mnemonicPassphrase) != null) { + throw Exception( + "Attempted to overwrite mnemonic on generate new wallet!"); + } + + await _prefs.init(); + + var newKeystore = Keystore.random(); + await _secureStore.write( + key: '${_walletId}_mnemonic', + value: newKeystore.mnemonic, + ); + await _secureStore.write( + key: '${_walletId}_mnemonicPassphrase', + value: "", + ); + + final address = Address( + walletId: walletId, + value: newKeystore.address, + publicKey: [], + derivationIndex: 0, + derivationPath: null, + type: AddressType.unknown, + subType: AddressSubType.receiving, + ); + + await db.putAddress(address); + + await Future.wait([ + updateCachedId(walletId), + updateCachedIsFavorite(false), + ]); + } + + @override + bool get isConnected => _isConnected; + bool _isConnected = false; + + @override + bool get isRefreshing => refreshMutex; + bool refreshMutex = false; + + @override + // TODO: implement maxFee + Future get maxFee => throw UnimplementedError(); + + @override + Future> get mnemonic async { + final mnemonic = await mnemonicString; + final mnemonicPassphrase = await this.mnemonicPassphrase; + if (mnemonic == null) { + throw Exception("No mnemonic found!"); + } + if (mnemonicPassphrase == null) { + throw Exception("No mnemonic passphrase found!"); + } + return mnemonic.split(" "); + } + + @override + Future get mnemonicPassphrase => + _secureStore.read(key: '${_walletId}_mnemonicPassphrase'); + + @override + Future get mnemonicString => + _secureStore.read(key: '${_walletId}_mnemonic'); + + Future _recoverWalletFromSeedPhrase({ + required String mnemonic, + required String mnemonicPassphrase, + bool isRescan = false, + }) async { + final keystore = Keystore.fromMnemonic( + mnemonic, + password: mnemonicPassphrase, + ); + + final address = Address( + walletId: walletId, + value: keystore.address, + publicKey: [], + derivationIndex: 0, + derivationPath: null, + type: AddressType.unknown, + subType: AddressSubType.receiving, + ); + + if (isRescan) { + await db.updateOrPutAddresses([address]); + } else { + await db.putAddress(address); + } + } + + bool longMutex = false; + @override + Future fullRescan( + int maxUnusedAddressGap, + int maxNumberOfIndexesToCheck, + ) async { + try { + Logging.instance.log("Starting full rescan!", level: LogLevel.Info); + longMutex = true; + GlobalEventBus.instance.fire( + WalletSyncStatusChangedEvent( + WalletSyncStatus.syncing, + walletId, + coin, + ), + ); + + final _mnemonic = await mnemonicString; + final _mnemonicPassphrase = await mnemonicPassphrase; + + await db.deleteWalletBlockchainData(walletId); + + await _recoverWalletFromSeedPhrase( + mnemonic: _mnemonic!, + mnemonicPassphrase: _mnemonicPassphrase!, + isRescan: true, + ); + + await refresh(); + Logging.instance.log("Full rescan complete!", level: LogLevel.Info); + GlobalEventBus.instance.fire( + WalletSyncStatusChangedEvent( + WalletSyncStatus.synced, + walletId, + coin, + ), + ); + } catch (e, s) { + GlobalEventBus.instance.fire( + WalletSyncStatusChangedEvent( + WalletSyncStatus.unableToSync, + walletId, + coin, + ), + ); + + Logging.instance.log( + "Exception rethrown from fullRescan(): $e\n$s", + level: LogLevel.Error, + ); + rethrow; + } finally { + longMutex = false; + } + } + + @override + Future recoverFromMnemonic({ + required String mnemonic, + String? mnemonicPassphrase, + required int maxUnusedAddressGap, + required int maxNumberOfIndexesToCheck, + required int height, + }) async { + longMutex = true; + try { + if ((await mnemonicString) != null || + (await this.mnemonicPassphrase) != null) { + throw Exception("Attempted to overwrite mnemonic on restore!"); + } + await _secureStore.write( + key: '${_walletId}_mnemonic', value: mnemonic.trim()); + await _secureStore.write( + key: '${_walletId}_mnemonicPassphrase', + value: mnemonicPassphrase ?? "", + ); + + await _recoverWalletFromSeedPhrase( + mnemonic: mnemonic, + mnemonicPassphrase: mnemonicPassphrase ?? "", + isRescan: false, + ); + + await Future.wait([ + updateCachedId(walletId), + updateCachedIsFavorite(false), + ]); + + await refresh(); + } catch (e, s) { + Logging.instance.log( + "Exception rethrown from recoverFromMnemonic(): $e\n$s", + level: LogLevel.Error); + + rethrow; + } finally { + longMutex = false; + } + } + + Future updateBalance() async { + try { + String balanceCall = "https://api.mainnet.tzkt.io/v1/accounts/" + "${await currentReceivingAddress}/balance"; + var response = jsonDecode(await client + .get( + url: Uri.parse(balanceCall), + proxyInfo: Prefs.instance.useTor + ? TorService.sharedInstance.proxyInfo + : null, + ) + .then((value) => value.body)); + Amount balanceInAmount = Amount( + rawValue: BigInt.parse(response.toString()), + fractionDigits: coin.decimals); + _balance = Balance( + total: balanceInAmount, + spendable: balanceInAmount, + blockedTotal: + Amount(rawValue: BigInt.parse("0"), fractionDigits: coin.decimals), + pendingSpendable: + Amount(rawValue: BigInt.parse("0"), fractionDigits: coin.decimals), + ); + await updateCachedBalance(_balance!); + } catch (e, s) { + Logging.instance + .log("ERROR GETTING BALANCE ${e.toString()}", level: LogLevel.Error); + } + } + + Future updateTransactions() async { + String transactionsCall = "https://api.mainnet.tzkt.io/v1/accounts/" + "${await currentReceivingAddress}/operations"; + var response = jsonDecode(await client + .get( + url: Uri.parse(transactionsCall), + proxyInfo: Prefs.instance.useTor + ? TorService.sharedInstance.proxyInfo + : null, + ) + .then((value) => value.body)); + List> txs = []; + for (var tx in response as List) { + if (tx["type"] == "transaction") { + TransactionType txType; + final String myAddress = await currentReceivingAddress; + final String senderAddress = tx["sender"]["address"] as String; + final String targetAddress = tx["target"]["address"] as String; + if (senderAddress == myAddress && targetAddress == myAddress) { + txType = TransactionType.sentToSelf; + } else if (senderAddress == myAddress) { + txType = TransactionType.outgoing; + } else if (targetAddress == myAddress) { + txType = TransactionType.incoming; + } else { + txType = TransactionType.unknown; + } + + var theTx = Transaction( + walletId: walletId, + txid: tx["hash"].toString(), + timestamp: DateTime.parse(tx["timestamp"].toString()) + .toUtc() + .millisecondsSinceEpoch ~/ + 1000, + type: txType, + subType: TransactionSubType.none, + amount: tx["amount"] as int, + amountString: Amount( + rawValue: + BigInt.parse((tx["amount"] as int).toInt().toString()), + fractionDigits: coin.decimals) + .toJsonString(), + fee: tx["bakerFee"] as int, + height: int.parse(tx["level"].toString()), + isCancelled: false, + isLelantus: false, + slateId: "", + otherData: "", + inputs: [], + outputs: [], + nonce: 0, + numberOfMessages: null, + ); + final AddressSubType subType; + switch (txType) { + case TransactionType.incoming: + case TransactionType.sentToSelf: + subType = AddressSubType.receiving; + break; + case TransactionType.outgoing: + case TransactionType.unknown: + subType = AddressSubType.unknown; + break; + } + final theAddress = Address( + walletId: walletId, + value: targetAddress, + publicKey: [], + derivationIndex: 0, + derivationPath: null, + type: AddressType.unknown, + subType: subType, + ); + txs.add(Tuple2(theTx, theAddress)); + } + } + Logging.instance.log("Transactions: $txs", level: LogLevel.Info); + await db.addNewTransactionData(txs, walletId); + } + + Future updateChainHeight() async { + try { + var api = "${getCurrentNode().host}/chains/main/blocks/head/header/shell"; + var jsonParsedResponse = jsonDecode(await client + .get( + url: Uri.parse(api), + proxyInfo: Prefs.instance.useTor + ? TorService.sharedInstance.proxyInfo + : null, + ) + .then((value) => value.body)); + final int intHeight = int.parse(jsonParsedResponse["level"].toString()); + Logging.instance.log("Chain height: $intHeight", level: LogLevel.Info); + await updateCachedChainHeight(intHeight); + } catch (e, s) { + Logging.instance + .log("GET CHAIN HEIGHT ERROR ${e.toString()}", level: LogLevel.Error); + } + } + + @override + Future refresh() async { + if (refreshMutex) { + Logging.instance.log( + "$walletId $walletName refreshMutex denied", + level: LogLevel.Info, + ); + return; + } else { + refreshMutex = true; + } + + try { + GlobalEventBus.instance.fire( + WalletSyncStatusChangedEvent( + WalletSyncStatus.syncing, + walletId, + coin, + ), + ); + + await updateChainHeight(); + await updateBalance(); + await updateTransactions(); + GlobalEventBus.instance.fire( + WalletSyncStatusChangedEvent( + WalletSyncStatus.synced, + walletId, + coin, + ), + ); + + if (shouldAutoSync) { + timer ??= Timer.periodic(const Duration(seconds: 30), (timer) async { + Logging.instance.log( + "Periodic refresh check for $walletId $walletName in object instance: $hashCode", + level: LogLevel.Info); + + await refresh(); + GlobalEventBus.instance.fire( + UpdatedInBackgroundEvent( + "New data found in $walletId $walletName in background!", + walletId, + ), + ); + }); + } + } catch (e, s) { + Logging.instance.log( + "Failed to refresh stellar wallet $walletId: '$walletName': $e\n$s", + level: LogLevel.Warning, + ); + GlobalEventBus.instance.fire( + WalletSyncStatusChangedEvent( + WalletSyncStatus.unableToSync, + walletId, + coin, + ), + ); + } + + refreshMutex = false; + } + + @override + int get storedChainHeight => getCachedChainHeight(); + + @override + Future testNetworkConnection() async { + try { + await client.get( + url: Uri.parse( + "${getCurrentNode().host}:${getCurrentNode().port}/chains/main/blocks/head/header/shell"), + proxyInfo: + Prefs.instance.useTor ? TorService.sharedInstance.proxyInfo : null, + ); + return true; + } catch (e) { + return false; + } + } + + @override + Future> get transactions => + db.getTransactions(walletId).findAll(); + + @override + Future updateNode(bool shouldRefresh) async { + _xtzNode = NodeService(secureStorageInterface: _secureStore) + .getPrimaryNodeFor(coin: coin) ?? + DefaultNodes.getNodeFor(coin); + + if (shouldRefresh) { + await refresh(); + } + } + + @override + Future updateSentCachedTxData(Map txData) async { + final transaction = Transaction( + walletId: walletId, + txid: txData["txid"] as String, + timestamp: DateTime.now().millisecondsSinceEpoch ~/ 1000, + type: TransactionType.outgoing, + subType: TransactionSubType.none, + // precision may be lost here hence the following amountString + amount: (txData["recipientAmt"] as Amount).raw.toInt(), + amountString: (txData["recipientAmt"] as Amount).toJsonString(), + fee: txData["fee"] as int, + height: null, + isCancelled: false, + isLelantus: false, + otherData: null, + slateId: null, + nonce: null, + inputs: [], + outputs: [], + numberOfMessages: null, + ); + + final address = txData["address"] is String + ? await db.getAddress(walletId, txData["address"] as String) + : null; + + await db.addNewTransactionData( + [ + Tuple2(transaction, address), + ], + walletId, + ); + } + + @override + // TODO: implement utxos + Future> get utxos => throw UnimplementedError(); + + @override + bool validateAddress(String address) { + return RegExp(r"^tz[1-9A-HJ-NP-Za-km-z]{34}$").hasMatch(address); + } +} diff --git a/lib/services/coins/wownero/wownero_wallet.dart b/lib/services/coins/wownero/wownero_wallet.dart index 6f0863334..7b3691846 100644 --- a/lib/services/coins/wownero/wownero_wallet.dart +++ b/lib/services/coins/wownero/wownero_wallet.dart @@ -333,7 +333,10 @@ class WowneroWallet extends CoinServiceAPI with WalletCache, WalletDB { } @override - Future initializeNew({int seedWordsLength = 14}) async { + Future initializeNew( + ({String mnemonicPassphrase, int wordCount})? data, { + int seedWordsLength = 14, + }) async { await _prefs.init(); // this should never fail diff --git a/lib/services/ethereum/ethereum_api.dart b/lib/services/ethereum/ethereum_api.dart index 5e95e3aa1..19fa6b081 100644 --- a/lib/services/ethereum/ethereum_api.dart +++ b/lib/services/ethereum/ethereum_api.dart @@ -17,11 +17,14 @@ import 'package:stackwallet/dto/ethereum/eth_tx_dto.dart'; import 'package:stackwallet/dto/ethereum/pending_eth_tx_dto.dart'; import 'package:stackwallet/models/isar/models/ethereum/eth_contract.dart'; import 'package:stackwallet/models/paymint/fee_object_model.dart'; +import 'package:stackwallet/networking/http.dart'; +import 'package:stackwallet/services/tor_service.dart'; import 'package:stackwallet/utilities/amount/amount.dart'; import 'package:stackwallet/utilities/default_nodes.dart'; import 'package:stackwallet/utilities/eth_commons.dart'; import 'package:stackwallet/utilities/extensions/extensions.dart'; import 'package:stackwallet/utilities/logger.dart'; +import 'package:stackwallet/utilities/prefs.dart'; import 'package:tuple/tuple.dart'; class EthApiException implements Exception { @@ -46,19 +49,23 @@ class EthereumResponse { abstract class EthereumAPI { static String get stackBaseServer => DefaultNodes.ethereum.host; + static HTTP client = HTTP(); + static Future>> getEthTransactions({ required String address, int firstBlock = 0, bool includeTokens = false, }) async { try { - final response = await get( - Uri.parse( + final response = await client.get( + url: Uri.parse( "$stackBaseServer/export?addrs=$address&firstBlock=$firstBlock", ), + proxyInfo: + Prefs.instance.useTor ? TorService.sharedInstance.proxyInfo : null, ); - if (response.statusCode == 200) { + if (response.code == 200) { if (response.body.isNotEmpty) { final json = jsonDecode(response.body) as Map; final list = json["data"] as List?; @@ -86,7 +93,7 @@ abstract class EthereumAPI { } else { throw EthApiException( "getEthTransactions($address) failed with status code: " - "${response.statusCode}", + "${response.code}", ); } } on EthApiException catch (e) { @@ -173,13 +180,15 @@ abstract class EthereumAPI { List txns, ) async { try { - final response = await get( - Uri.parse( + final response = await client.get( + url: Uri.parse( "$stackBaseServer/transactions?transactions=${txns.map((e) => e.hash).join(" ")}&raw=true", ), + proxyInfo: + Prefs.instance.useTor ? TorService.sharedInstance.proxyInfo : null, ); - if (response.statusCode == 200) { + if (response.code == 200) { if (response.body.isNotEmpty) { final json = jsonDecode(response.body) as Map; final list = List>.from(json["data"] as List); @@ -208,7 +217,7 @@ abstract class EthereumAPI { } else { throw EthApiException( "getEthTransactionNonces($txns) failed with status code: " - "${response.statusCode}", + "${response.code}", ); } } on EthApiException catch (e) { @@ -231,13 +240,15 @@ abstract class EthereumAPI { static Future>> getEthTokenTransactionsByTxids(List txids) async { try { - final response = await get( - Uri.parse( + final response = await client.get( + url: Uri.parse( "$stackBaseServer/transactions?transactions=${txids.join(" ")}", ), + proxyInfo: + Prefs.instance.useTor ? TorService.sharedInstance.proxyInfo : null, ); - if (response.statusCode == 200) { + if (response.code == 200) { if (response.body.isNotEmpty) { final json = jsonDecode(response.body) as Map; final list = json["data"] as List?; @@ -257,13 +268,13 @@ abstract class EthereumAPI { } else { throw EthApiException( "getEthTokenTransactionsByTxids($txids) response is empty but status code is " - "${response.statusCode}", + "${response.code}", ); } } else { throw EthApiException( "getEthTokenTransactionsByTxids($txids) failed with status code: " - "${response.statusCode}", + "${response.code}", ); } } on EthApiException catch (e) { @@ -288,13 +299,15 @@ abstract class EthereumAPI { required String tokenContractAddress, }) async { try { - final response = await get( - Uri.parse( + final response = await client.get( + url: Uri.parse( "$stackBaseServer/export?addrs=$address&emitter=$tokenContractAddress&logs=true", ), + proxyInfo: + Prefs.instance.useTor ? TorService.sharedInstance.proxyInfo : null, ); - if (response.statusCode == 200) { + if (response.code == 200) { if (response.body.isNotEmpty) { final json = jsonDecode(response.body) as Map; final list = json["data"] as List?; @@ -321,7 +334,7 @@ abstract class EthereumAPI { } else { throw EthApiException( "getTokenTransactions($address, $tokenContractAddress) failed with status code: " - "${response.statusCode}", + "${response.code}", ); } } on EthApiException catch (e) { @@ -422,9 +435,13 @@ abstract class EthereumAPI { final uri = Uri.parse( "$stackBaseServer/tokens?addrs=$contractAddress $address", ); - final response = await get(uri); + final response = await client.get( + url: uri, + proxyInfo: + Prefs.instance.useTor ? TorService.sharedInstance.proxyInfo : null, + ); - if (response.statusCode == 200) { + if (response.code == 200) { final json = jsonDecode(response.body); if (json["data"] is List) { final map = json["data"].first as Map; @@ -442,7 +459,7 @@ abstract class EthereumAPI { } else { throw EthApiException( "getWalletTokenBalance($address) failed with status code: " - "${response.statusCode}", + "${response.code}", ); } } on EthApiException catch (e) { @@ -469,9 +486,13 @@ abstract class EthereumAPI { final uri = Uri.parse( "$stackBaseServer/state?addrs=$address&parts=all", ); - final response = await get(uri); + final response = await client.get( + url: uri, + proxyInfo: + Prefs.instance.useTor ? TorService.sharedInstance.proxyInfo : null, + ); - if (response.statusCode == 200) { + if (response.code == 200) { final json = jsonDecode(response.body); if (json["data"] is List) { final map = json["data"].first as Map; @@ -488,7 +509,7 @@ abstract class EthereumAPI { } else { throw EthApiException( "getAddressNonce($address) failed with status code: " - "${response.statusCode}", + "${response.code}", ); } } on EthApiException catch (e) { @@ -510,13 +531,15 @@ abstract class EthereumAPI { static Future> getGasOracle() async { try { - final response = await get( - Uri.parse( + final response = await client.get( + url: Uri.parse( "$stackBaseServer/gas-prices", ), + proxyInfo: + Prefs.instance.useTor ? TorService.sharedInstance.proxyInfo : null, ); - if (response.statusCode == 200) { + if (response.code == 200) { final json = jsonDecode(response.body) as Map; if (json["success"] == true) { try { @@ -541,7 +564,7 @@ abstract class EthereumAPI { } else { throw EthApiException( "getGasOracle() failed with status code: " - "${response.statusCode}", + "${response.code}", ); } } on EthApiException catch (e) { @@ -579,13 +602,15 @@ abstract class EthereumAPI { static Future> getTokenContractInfoByAddress( String contractAddress) async { try { - final response = await get( - Uri.parse( + final response = await client.get( + url: Uri.parse( "$stackBaseServer/tokens?addrs=$contractAddress&parts=all", ), + proxyInfo: + Prefs.instance.useTor ? TorService.sharedInstance.proxyInfo : null, ); - if (response.statusCode == 200) { + if (response.code == 200) { final json = jsonDecode(response.body) as Map; if (json["data"] is List) { final map = Map.from(json["data"].first as Map); @@ -621,7 +646,7 @@ abstract class EthereumAPI { } else { throw EthApiException( "getTokenByContractAddress($contractAddress) failed with status code: " - "${response.statusCode}", + "${response.code}", ); } } on EthApiException catch (e) { @@ -646,13 +671,15 @@ abstract class EthereumAPI { required String contractAddress, }) async { try { - final response = await get( - Uri.parse( + final response = await client.get( + url: Uri.parse( "$stackBaseServer/abis?addrs=$contractAddress&verbose=true", ), + proxyInfo: + Prefs.instance.useTor ? TorService.sharedInstance.proxyInfo : null, ); - if (response.statusCode == 200) { + if (response.code == 200) { final json = jsonDecode(response.body)["data"] as List; return EthereumResponse( @@ -662,7 +689,7 @@ abstract class EthereumAPI { } else { throw EthApiException( "getTokenAbi($name, $contractAddress) failed with status code: " - "${response.statusCode}", + "${response.code}", ); } } on EthApiException catch (e) { @@ -687,9 +714,13 @@ abstract class EthereumAPI { String contractAddress, ) async { try { - final response = await get(Uri.parse( - "$stackBaseServer/state?addrs=$contractAddress&parts=proxy")); - if (response.statusCode == 200) { + final response = await client.get( + url: Uri.parse( + "$stackBaseServer/state?addrs=$contractAddress&parts=proxy"), + proxyInfo: + Prefs.instance.useTor ? TorService.sharedInstance.proxyInfo : null, + ); + if (response.code == 200) { final json = jsonDecode(response.body); final list = json["data"] as List; final map = Map.from(list.first as Map); @@ -701,7 +732,7 @@ abstract class EthereumAPI { } else { throw EthApiException( "getProxyTokenImplementationAddress($contractAddress) failed with" - " status code: ${response.statusCode}", + " status code: ${response.code}", ); } } on EthApiException catch (e) { diff --git a/lib/services/event_bus/events/global/tor_connection_status_changed_event.dart b/lib/services/event_bus/events/global/tor_connection_status_changed_event.dart new file mode 100644 index 000000000..0a395b6a5 --- /dev/null +++ b/lib/services/event_bus/events/global/tor_connection_status_changed_event.dart @@ -0,0 +1,23 @@ +/* + * This file is part of Stack Wallet. + * + * Copyright (c) 2023 Cypher Stack + * All Rights Reserved. + * The code is distributed under GPLv3 license, see LICENSE file for details. + * Generated by Cypher Stack on 2023-05-26 + * + */ +import 'package:stackwallet/utilities/logger.dart'; + +enum TorConnectionStatus { disconnected, connecting, connected } + +class TorConnectionStatusChangedEvent { + TorConnectionStatus newStatus; + String message = ""; + + TorConnectionStatusChangedEvent(this.newStatus, this.message) { + Logging.instance.log( + "TorSyncStatusChangedEvent fired with arg newStatus = $newStatus ($message)", + level: LogLevel.Info); + } +} diff --git a/lib/services/event_bus/events/global/tor_status_changed_event.dart b/lib/services/event_bus/events/global/tor_status_changed_event.dart new file mode 100644 index 000000000..6f974bf75 --- /dev/null +++ b/lib/services/event_bus/events/global/tor_status_changed_event.dart @@ -0,0 +1,28 @@ +/* + * This file is part of Stack Wallet. + * + * Copyright (c) 2023 Cypher Stack + * All Rights Reserved. + * The code is distributed under GPLv3 license, see LICENSE file for details. + * Generated by Cypher Stack on 2023-05-26 + * + */ + +import 'package:stackwallet/utilities/logger.dart'; + +enum TorStatus { enabled, disabled } + +class TorPreferenceChangedEvent { + String? message; + TorStatus status; + + TorPreferenceChangedEvent({ + required this.status, + this.message, + }) { + Logging.instance.log( + "TorStatusChangedEvent changed to \"$status\" with message: $message", + level: LogLevel.Warning, + ); + } +} diff --git a/lib/services/exchange/change_now/change_now_api.dart b/lib/services/exchange/change_now/change_now_api.dart index a9d628448..d8b260495 100644 --- a/lib/services/exchange/change_now/change_now_api.dart +++ b/lib/services/exchange/change_now/change_now_api.dart @@ -12,7 +12,6 @@ import 'dart:convert'; import 'package:decimal/decimal.dart'; import 'package:flutter/foundation.dart'; -import 'package:http/http.dart' as http; import 'package:stackwallet/exceptions/exchange/exchange_exception.dart'; import 'package:stackwallet/exceptions/exchange/pair_unavailable_exception.dart'; import 'package:stackwallet/exceptions/exchange/unsupported_currency_exception.dart'; @@ -26,9 +25,12 @@ import 'package:stackwallet/models/exchange/response_objects/fixed_rate_market.d import 'package:stackwallet/models/exchange/response_objects/range.dart'; import 'package:stackwallet/models/isar/exchange_cache/currency.dart'; import 'package:stackwallet/models/isar/exchange_cache/pair.dart'; +import 'package:stackwallet/networking/http.dart'; import 'package:stackwallet/services/exchange/change_now/change_now_exchange.dart'; import 'package:stackwallet/services/exchange/exchange_response.dart'; +import 'package:stackwallet/services/tor_service.dart'; import 'package:stackwallet/utilities/logger.dart'; +import 'package:stackwallet/utilities/prefs.dart'; import 'package:tuple/tuple.dart'; class ChangeNowAPI { @@ -37,12 +39,13 @@ class ChangeNowAPI { static const String apiVersion = "/v1"; static const String apiVersionV2 = "/v2"; - ChangeNowAPI._(); - static final ChangeNowAPI _instance = ChangeNowAPI._(); - static ChangeNowAPI get instance => _instance; + final HTTP client; - /// set this to override using standard http client. Useful for testing - http.Client? client; + @visibleForTesting + ChangeNowAPI({HTTP? http}) : client = http ?? HTTP(); + + static final ChangeNowAPI _instance = ChangeNowAPI(); + static ChangeNowAPI get instance => _instance; Uri _buildUri(String path, Map? params) { return Uri.https(authority, apiVersion + path, params); @@ -53,21 +56,23 @@ class ChangeNowAPI { } Future _makeGetRequest(Uri uri) async { - final client = this.client ?? http.Client(); try { final response = await client.get( - uri, + url: uri, headers: {'Content-Type': 'application/json'}, + proxyInfo: + Prefs.instance.useTor ? TorService.sharedInstance.proxyInfo : null, ); - + String? data; try { - final parsed = jsonDecode(response.body); + data = response.body; + final parsed = jsonDecode(data); return parsed; } on FormatException catch (e) { return { "error": "Dart format exception", - "message": response.body, + "message": data, }; } } catch (e, s) { @@ -78,17 +83,19 @@ class ChangeNowAPI { } Future _makeGetRequestV2(Uri uri, String apiKey) async { - final client = this.client ?? http.Client(); try { final response = await client.get( - uri, + url: uri, headers: { // 'Content-Type': 'application/json', 'x-changenow-api-key': apiKey, }, + proxyInfo: + Prefs.instance.useTor ? TorService.sharedInstance.proxyInfo : null, ); - final parsed = jsonDecode(response.body); + final data = response.body; + final parsed = jsonDecode(data); return parsed; } catch (e, s) { @@ -102,21 +109,24 @@ class ChangeNowAPI { Uri uri, Map body, ) async { - final client = this.client ?? http.Client(); try { final response = await client.post( - uri, + url: uri, headers: {'Content-Type': 'application/json'}, body: jsonEncode(body), + proxyInfo: + Prefs.instance.useTor ? TorService.sharedInstance.proxyInfo : null, ); + String? data; try { - final parsed = jsonDecode(response.body); + data = response.body; + final parsed = jsonDecode(data); return parsed; } catch (_) { - Logging.instance.log("ChangeNOW api failed to parse: ${response.body}", - level: LogLevel.Error); + Logging.instance + .log("ChangeNOW api failed to parse: $data", level: LogLevel.Error); rethrow; } } catch (e, s) { diff --git a/lib/services/exchange/change_now/change_now_exchange.dart b/lib/services/exchange/change_now/change_now_exchange.dart index 953d17077..63c99cc40 100644 --- a/lib/services/exchange/change_now/change_now_exchange.dart +++ b/lib/services/exchange/change_now/change_now_exchange.dart @@ -274,4 +274,15 @@ class ChangeNowExchange extends Exchange { // TODO: implement getTrades throw UnimplementedError(); } + + // ChangeNow does not support Tor. + // + // This code isn't required because the Exchange abstract class has a + // default implementation that returns false. This serves as an example and + // reminder in case ChangeNow files are copied to create a new exchange (or + // if ChangeNow ever supports Tor). + /* + @override + bool get supportsTor => true; + */ } diff --git a/lib/services/exchange/exchange.dart b/lib/services/exchange/exchange.dart index 5b750ec6c..a8553854c 100644 --- a/lib/services/exchange/exchange.dart +++ b/lib/services/exchange/exchange.dart @@ -90,4 +90,25 @@ abstract class Exchange { Estimate? estimate, required bool reversed, }); + + /// List of exchanges which support Tor. + /// + /// Add to this list when adding a new exchange which supports Tor. + static List get exchangesWithTorSupport => [ + MajesticBankExchange.instance, + TrocadorExchange.instance, + ]; + + /// List of exchange names which support Tor. + /// + /// Convenience method for when you just want to check for a String + /// .exchangeName instead of Exchange instances. Shouldn't need to be updated + /// as long as the above List is updated. + static List get exchangeNamesWithTorSupport => + exchangesWithTorSupport.map((exchange) => exchange.name).toList(); + // Instead of using this, you can do like: + // currencies.removeWhere((element) => + // !Exchange.exchangesWithTorSupport.any((e) => e.name == element.exchangeName) + // ); + // But this helper may be more readable. } diff --git a/lib/services/exchange/exchange_data_loading_service.dart b/lib/services/exchange/exchange_data_loading_service.dart index ee0ed50a0..eecb80462 100644 --- a/lib/services/exchange/exchange_data_loading_service.dart +++ b/lib/services/exchange/exchange_data_loading_service.dart @@ -20,6 +20,7 @@ import 'package:stackwallet/services/exchange/majestic_bank/majestic_bank_exchan import 'package:stackwallet/services/exchange/trocador/trocador_exchange.dart'; import 'package:stackwallet/utilities/enums/exchange_rate_type_enum.dart'; import 'package:stackwallet/utilities/logger.dart'; +import 'package:stackwallet/utilities/prefs.dart'; import 'package:stackwallet/utilities/stack_file_system.dart'; import 'package:tuple/tuple.dart'; @@ -144,6 +145,8 @@ class ExchangeDataLoadingService { ); final start = DateTime.now(); try { + /* + // Old exchange data loading code. await Future.wait([ _loadChangeNowCurrencies(), // _loadChangeNowFixedRatePairs(), @@ -157,6 +160,20 @@ class ExchangeDataLoadingService { // quicker to load available currencies on the fly for a specific base currency // await _loadChangeNowFixedRatePairs(); // await _loadChangeNowEstimatedRatePairs(); + */ + + // If using Tor, don't load data for exchanges which don't support Tor. + // + // Add to this list when adding an exchange which doesn't supports Tor. + if (!Prefs.instance.useTor) { + await _loadChangeNowCurrencies(); + } + + // Exchanges which support Tor just get treated normally. + await Future.wait([ + loadMajesticBankCurrencies(), + loadTrocadorCurrencies(), + ]); Logging.instance.log( "ExchangeDataLoadingService.loadAll finished in ${DateTime.now().difference(start).inSeconds} seconds", diff --git a/lib/services/exchange/majestic_bank/majestic_bank_api.dart b/lib/services/exchange/majestic_bank/majestic_bank_api.dart index 613899f9c..d32209ae5 100644 --- a/lib/services/exchange/majestic_bank/majestic_bank_api.dart +++ b/lib/services/exchange/majestic_bank/majestic_bank_api.dart @@ -11,7 +11,6 @@ import 'dart:convert'; import 'package:decimal/decimal.dart'; -import 'package:http/http.dart' as http; import 'package:stackwallet/exceptions/exchange/exchange_exception.dart'; import 'package:stackwallet/exceptions/exchange/majestic_bank/mb_exception.dart'; import 'package:stackwallet/exceptions/exchange/pair_unavailable_exception.dart'; @@ -20,8 +19,11 @@ import 'package:stackwallet/models/exchange/majestic_bank/mb_order.dart'; import 'package:stackwallet/models/exchange/majestic_bank/mb_order_calculation.dart'; import 'package:stackwallet/models/exchange/majestic_bank/mb_order_status.dart'; import 'package:stackwallet/models/exchange/majestic_bank/mb_rate.dart'; +import 'package:stackwallet/networking/http.dart'; import 'package:stackwallet/services/exchange/exchange_response.dart'; +import 'package:stackwallet/services/tor_service.dart'; import 'package:stackwallet/utilities/logger.dart'; +import 'package:stackwallet/utilities/prefs.dart'; class MajesticBankAPI { static const String scheme = "https"; @@ -35,22 +37,23 @@ class MajesticBankAPI { static MajesticBankAPI get instance => _instance; - /// set this to override using standard http client. Useful for testing - http.Client? client; + HTTP client = HTTP(); Uri _buildUri({required String endpoint, Map? params}) { return Uri.https(authority, "/api/$version/$endpoint", params); } Future _makeGetRequest(Uri uri) async { - final client = this.client ?? http.Client(); + // final client = this.client ?? http.Client(); int code = -1; try { final response = await client.get( - uri, + url: uri, + proxyInfo: + Prefs.instance.useTor ? TorService.sharedInstance.proxyInfo : null, ); - code = response.statusCode; + code = response.code; final parsed = jsonDecode(response.body); diff --git a/lib/services/exchange/majestic_bank/majestic_bank_exchange.dart b/lib/services/exchange/majestic_bank/majestic_bank_exchange.dart index 60e97d723..3ba914fb9 100644 --- a/lib/services/exchange/majestic_bank/majestic_bank_exchange.dart +++ b/lib/services/exchange/majestic_bank/majestic_bank_exchange.dart @@ -324,4 +324,8 @@ class MajesticBankExchange extends Exchange { return ExchangeResponse(exception: response.exception); } } + + // Majestic Bank supports tor. + @override + bool get supportsTor => true; } diff --git a/lib/services/exchange/simpleswap/simpleswap_api.dart b/lib/services/exchange/simpleswap/simpleswap_api.dart index adca1f567..d52f8aa21 100644 --- a/lib/services/exchange/simpleswap/simpleswap_api.dart +++ b/lib/services/exchange/simpleswap/simpleswap_api.dart @@ -12,7 +12,6 @@ import 'dart:convert'; import 'package:decimal/decimal.dart'; import 'package:flutter/foundation.dart'; -import 'package:http/http.dart' as http; import 'package:stackwallet/exceptions/exchange/exchange_exception.dart'; import 'package:stackwallet/external_api_keys.dart'; import 'package:stackwallet/models/exchange/response_objects/fixed_rate_market.dart'; @@ -20,9 +19,12 @@ import 'package:stackwallet/models/exchange/response_objects/range.dart'; import 'package:stackwallet/models/exchange/response_objects/trade.dart'; import 'package:stackwallet/models/exchange/simpleswap/sp_currency.dart'; import 'package:stackwallet/models/isar/exchange_cache/pair.dart'; +import 'package:stackwallet/networking/http.dart'; import 'package:stackwallet/services/exchange/exchange_response.dart'; import 'package:stackwallet/services/exchange/simpleswap/simpleswap_exchange.dart'; +import 'package:stackwallet/services/tor_service.dart'; import 'package:stackwallet/utilities/logger.dart'; +import 'package:stackwallet/utilities/prefs.dart'; import 'package:tuple/tuple.dart'; import 'package:uuid/uuid.dart'; @@ -34,22 +36,22 @@ class SimpleSwapAPI { static final SimpleSwapAPI _instance = SimpleSwapAPI._(); static SimpleSwapAPI get instance => _instance; - /// set this to override using standard http client. Useful for testing - http.Client? client; + HTTP client = HTTP(); Uri _buildUri(String path, Map? params) { return Uri.https(authority, path, params); } Future _makeGetRequest(Uri uri) async { - final client = this.client ?? http.Client(); int code = -1; try { final response = await client.get( - uri, + url: uri, + proxyInfo: + Prefs.instance.useTor ? TorService.sharedInstance.proxyInfo : null, ); - code = response.statusCode; + code = response.code; final parsed = jsonDecode(response.body); @@ -67,15 +69,16 @@ class SimpleSwapAPI { Uri uri, Map body, ) async { - final client = this.client ?? http.Client(); try { final response = await client.post( - uri, + url: uri, headers: {'Content-Type': 'application/json'}, body: jsonEncode(body), + proxyInfo: + Prefs.instance.useTor ? TorService.sharedInstance.proxyInfo : null, ); - if (response.statusCode == 200) { + if (response.code == 200) { final parsed = jsonDecode(response.body); return parsed; } diff --git a/lib/services/exchange/trocador/trocador_api.dart b/lib/services/exchange/trocador/trocador_api.dart index 4c9b2cbac..8dadfb499 100644 --- a/lib/services/exchange/trocador/trocador_api.dart +++ b/lib/services/exchange/trocador/trocador_api.dart @@ -12,14 +12,16 @@ import 'dart:convert'; import 'package:flutter/foundation.dart'; import 'package:flutter_native_splash/cli_commands.dart'; -import 'package:http/http.dart' as http; import 'package:stackwallet/exceptions/exchange/exchange_exception.dart'; +import 'package:stackwallet/networking/http.dart'; import 'package:stackwallet/services/exchange/exchange_response.dart'; import 'package:stackwallet/services/exchange/trocador/response_objects/trocador_coin.dart'; import 'package:stackwallet/services/exchange/trocador/response_objects/trocador_rate.dart'; import 'package:stackwallet/services/exchange/trocador/response_objects/trocador_trade.dart'; import 'package:stackwallet/services/exchange/trocador/response_objects/trocador_trade_new.dart'; +import 'package:stackwallet/services/tor_service.dart'; import 'package:stackwallet/utilities/logger.dart'; +import 'package:stackwallet/utilities/prefs.dart'; const kTrocadorApiKey = "8rFqf7QLxX1mUBiNPEMaLUpV2biz6n"; const kTrocadorRefCode = "9eHm9BkQfS"; @@ -31,6 +33,7 @@ abstract class TrocadorAPI { static const String markup = "1"; static const String minKYCRating = "C"; + static HTTP client = HTTP(); static Uri _buildUri({ required String method, @@ -46,12 +49,14 @@ abstract class TrocadorAPI { int code = -1; try { debugPrint("URI: $uri"); - final response = await http.get( - uri, + final response = await client.get( + url: uri, headers: {'Content-Type': 'application/json'}, + proxyInfo: + Prefs.instance.useTor ? TorService.sharedInstance.proxyInfo : null, ); - code = response.statusCode; + code = response.code; debugPrint("CODE: $code"); debugPrint("BODY: ${response.body}"); diff --git a/lib/services/exchange/trocador/trocador_exchange.dart b/lib/services/exchange/trocador/trocador_exchange.dart index e4f14ff17..d5a819b46 100644 --- a/lib/services/exchange/trocador/trocador_exchange.dart +++ b/lib/services/exchange/trocador/trocador_exchange.dart @@ -401,4 +401,8 @@ class TrocadorExchange extends Exchange { return ExchangeResponse(exception: response.exception); } } + + // Trocador supports Tor. + @override + bool get supportsTor => true; } diff --git a/lib/services/litescribe_api.dart b/lib/services/litescribe_api.dart index 1acc047b8..ea4013457 100644 --- a/lib/services/litescribe_api.dart +++ b/lib/services/litescribe_api.dart @@ -1,8 +1,10 @@ import 'dart:convert'; -import 'package:http/http.dart' as http; import 'package:stackwallet/dto/ordinals/inscription_data.dart'; import 'package:stackwallet/dto/ordinals/litescribe_response.dart'; +import 'package:stackwallet/networking/http.dart'; +import 'package:stackwallet/services/tor_service.dart'; +import 'package:stackwallet/utilities/prefs.dart'; class LitescribeAPI { static final LitescribeAPI _instance = LitescribeAPI._internal(); @@ -13,12 +15,17 @@ class LitescribeAPI { } LitescribeAPI._internal(); + HTTP client = HTTP(); late String baseUrl; Future _getResponse(String endpoint) async { - final response = await http.get(Uri.parse('$baseUrl$endpoint')); - if (response.statusCode == 200) { + final response = await client.get( + url: Uri.parse('$baseUrl$endpoint'), + proxyInfo: + Prefs.instance.useTor ? TorService.sharedInstance.proxyInfo : null, + ); + if (response.code == 200) { return LitescribeResponse(data: _validateJson(response.body)); } else { throw Exception( diff --git a/lib/services/monkey_service.dart b/lib/services/monkey_service.dart index 46dfbb0ef..eb3687fcd 100644 --- a/lib/services/monkey_service.dart +++ b/lib/services/monkey_service.dart @@ -1,13 +1,16 @@ import 'dart:typed_data'; import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:http/http.dart' as http; +import 'package:stackwallet/networking/http.dart'; +import 'package:stackwallet/services/tor_service.dart'; import 'package:stackwallet/utilities/logger.dart'; +import 'package:stackwallet/utilities/prefs.dart'; final pMonKeyService = Provider((ref) => MonKeyService()); class MonKeyService { static const baseURL = "https://monkey.banano.cc/api/v1/monkey/"; + HTTP client = HTTP(); Future fetchMonKey({ required String address, @@ -20,13 +23,17 @@ class MonKeyService { url += '?format=png&size=512&background=false'; } - final response = await http.get(Uri.parse(url)); + final response = await client.get( + url: Uri.parse(url), + proxyInfo: + Prefs.instance.useTor ? TorService.sharedInstance.proxyInfo : null, + ); - if (response.statusCode == 200) { - return response.bodyBytes; + if (response.code == 200) { + return Uint8List.fromList(response.bodyBytes); } else { throw Exception( - "statusCode=${response.statusCode} body=${response.body}", + "statusCode=${response.code} body=${response.body}", ); } } catch (e, s) { diff --git a/lib/services/nano_api.dart b/lib/services/nano_api.dart index 3173bfbe6..c0d194a31 100644 --- a/lib/services/nano_api.dart +++ b/lib/services/nano_api.dart @@ -1,7 +1,9 @@ import 'dart:convert'; -import 'package:http/http.dart' as http; import 'package:nanodart/nanodart.dart'; +import 'package:stackwallet/networking/http.dart'; +import 'package:stackwallet/services/tor_service.dart'; +import 'package:stackwallet/utilities/prefs.dart'; class NanoAPI { static Future< @@ -16,9 +18,11 @@ class NanoAPI { NAccountInfo? accountInfo; Exception? exception; + HTTP client = HTTP(); + try { - final response = await http.post( - server, + final response = await client.post( + url: server, headers: { "Content-Type": "application/json", }, @@ -27,6 +31,8 @@ class NanoAPI { "representative": "true", "account": account, }), + proxyInfo: + Prefs.instance.useTor ? TorService.sharedInstance.proxyInfo : null, ); final map = jsonDecode(response.body); @@ -105,8 +111,10 @@ class NanoAPI { required Uri server, required Map block, }) async { - final response = await http.post( - server, + HTTP client = HTTP(); + + final response = await client.post( + url: server, headers: { "Content-Type": "application/json", }, @@ -116,6 +124,8 @@ class NanoAPI { "subtype": "change", "block": block, }), + proxyInfo: + Prefs.instance.useTor ? TorService.sharedInstance.proxyInfo : null, ); return jsonDecode(response.body); diff --git a/lib/services/price.dart b/lib/services/price.dart index 66842c9d8..a4ffff961 100644 --- a/lib/services/price.dart +++ b/lib/services/price.dart @@ -13,8 +13,9 @@ import 'dart:convert'; import 'package:decimal/decimal.dart'; import 'package:flutter/foundation.dart'; -import 'package:http/http.dart'; import 'package:stackwallet/db/hive/db.dart'; +import 'package:stackwallet/networking/http.dart'; +import 'package:stackwallet/services/tor_service.dart'; import 'package:stackwallet/utilities/enums/coin_enum.dart'; import 'package:stackwallet/utilities/logger.dart'; import 'package:stackwallet/utilities/prefs.dart'; @@ -32,7 +33,7 @@ class PriceAPI { static const Duration refreshIntervalDuration = Duration(seconds: refreshInterval); - final Client client; + final HTTP client; PriceAPI(this.client); @@ -96,16 +97,18 @@ class PriceAPI { } Map> result = {}; try { - final uri = - Uri.parse("https://api.coingecko.com/api/v3/coins/markets?vs_currency" - "=${baseCurrency.toLowerCase()}" - "&ids=monero,bitcoin,litecoin,ecash,epic-cash,zcoin,dogecoin," - "bitcoin-cash,namecoin,wownero,ethereum,particl,nano,banano,stellar" - "&order=market_cap_desc&per_page=50&page=1&sparkline=false"); + final uri = Uri.parse( + "https://api.coingecko.com/api/v3/coins/markets?vs_currency" + "=${baseCurrency.toLowerCase()}" + "&ids=monero,bitcoin,litecoin,ecash,epic-cash,zcoin,dogecoin," + "bitcoin-cash,namecoin,wownero,ethereum,particl,nano,banano,stellar,tezos" + "&order=market_cap_desc&per_page=50&page=1&sparkline=false"); final coinGeckoResponse = await client.get( - uri, + url: uri, headers: {'Content-Type': 'application/json'}, + proxyInfo: + Prefs.instance.useTor ? TorService.sharedInstance.proxyInfo : null, ); final coinGeckoData = jsonDecode(coinGeckoResponse.body) as List; @@ -136,6 +139,8 @@ class PriceAPI { static Future?> availableBaseCurrencies() async { final externalCalls = Prefs.instance.externalCalls; + HTTP client = HTTP(); + if ((!Logger.isTestEnv && !externalCalls) || !(await Prefs.instance.isExternalCallsSet())) { Logging.instance.log("User does not want to use external calls", @@ -146,9 +151,11 @@ class PriceAPI { "https://api.coingecko.com/api/v3/simple/supported_vs_currencies"; try { final uri = Uri.parse(uriString); - final response = await Client().get( - uri, + final response = await client.get( + url: uri, headers: {'Content-Type': 'application/json'}, + proxyInfo: + Prefs.instance.useTor ? TorService.sharedInstance.proxyInfo : null, ); final json = jsonDecode(response.body) as List; @@ -186,8 +193,10 @@ class PriceAPI { "=$contractAddressesString&include_24hr_change=true"); final coinGeckoResponse = await client.get( - uri, + url: uri, headers: {'Content-Type': 'application/json'}, + proxyInfo: + Prefs.instance.useTor ? TorService.sharedInstance.proxyInfo : null, ); final coinGeckoData = jsonDecode(coinGeckoResponse.body) as Map; diff --git a/lib/services/price_service.dart b/lib/services/price_service.dart index 46c0ff85a..8a0b2741a 100644 --- a/lib/services/price_service.dart +++ b/lib/services/price_service.dart @@ -13,6 +13,7 @@ import 'dart:async'; import 'package:decimal/decimal.dart'; import 'package:flutter/foundation.dart'; import 'package:http/http.dart'; +import 'package:stackwallet/networking/http.dart'; import 'package:stackwallet/services/price.dart'; import 'package:stackwallet/utilities/enums/coin_enum.dart'; import 'package:tuple/tuple.dart'; @@ -29,7 +30,7 @@ class PriceService extends ChangeNotifier { final Map> _cachedTokenPrices = {}; - final _priceAPI = PriceAPI(Client()); + final _priceAPI = PriceAPI(HTTP()); Tuple2 getPrice(Coin coin) => _cachedPrices[coin]!; diff --git a/lib/services/tor_service.dart b/lib/services/tor_service.dart new file mode 100644 index 000000000..ead6ab5fa --- /dev/null +++ b/lib/services/tor_service.dart @@ -0,0 +1,142 @@ +import 'dart:io'; + +import 'package:flutter_riverpod/flutter_riverpod.dart'; +import 'package:stackwallet/services/event_bus/events/global/tor_connection_status_changed_event.dart'; +import 'package:stackwallet/services/event_bus/global_event_bus.dart'; +import 'package:stackwallet/utilities/logger.dart'; +import 'package:tor_ffi_plugin/tor_ffi_plugin.dart'; + +final pTorService = Provider((_) => TorService.sharedInstance); + +class TorService { + Tor? _tor; + + /// Flag to indicate that a Tor circuit is thought to have been established. + bool _enabled = false; + + /// Getter for the enabled flag. + bool get enabled => _enabled; + + TorService._(); + + /// Singleton instance of the TorService. + /// + /// Use this to access the TorService and its properties. + static final sharedInstance = TorService._(); + + /// Getter for the proxyInfo. + ({ + InternetAddress host, + int port, + }) get proxyInfo => ( + host: InternetAddress.loopbackIPv4, + port: _tor!.port, + ); + + /// Initialize the tor ffi lib instance if it hasn't already been set. Nothing + /// changes if _tor is already been set. + void init({Tor? mockableOverride}) { + _tor ??= mockableOverride ?? Tor.instance; + } + + /// Start the Tor service. + /// + /// This will start the Tor service and establish a Tor circuit. + /// + /// Throws an exception if the Tor service fails to start. + /// + /// Returns a Future that completes when the Tor service has started. + Future start() async { + if (_tor == null) { + throw Exception("TorService.init has not been called!"); + } + + if (_enabled) { + // already started so just return + // could throw an exception here or something so the caller + // is explicitly made aware of this + // TODO restart tor after that's been added to the tor-ffi crate + // (probably better to have a restart function separately) + + // Fire a TorConnectionStatusChangedEvent on the event bus. + GlobalEventBus.instance.fire( + TorConnectionStatusChangedEvent( + TorConnectionStatus.connected, + "Tor connection status changed: connect ($_enabled)", + ), + ); + return; + } + + // Start the Tor service. + try { + GlobalEventBus.instance.fire( + TorConnectionStatusChangedEvent( + TorConnectionStatus.connecting, + "Tor connection status changed: connecting", + ), + ); + await _tor!.start(); + // no exception or error so we can (probably?) assume tor + // has started successfully + _enabled = true; + + // Fire a TorConnectionStatusChangedEvent on the event bus. + GlobalEventBus.instance.fire( + TorConnectionStatusChangedEvent( + TorConnectionStatus.connected, + "Tor connection status changed: connect ($_enabled)", + ), + ); + } catch (e, s) { + Logging.instance.log( + "TorService.start failed: $e\n$s", + level: LogLevel.Warning, + ); + // _enabled should already be false + + // Fire a TorConnectionStatusChangedEvent on the event bus. + GlobalEventBus.instance.fire( + TorConnectionStatusChangedEvent( + TorConnectionStatus.disconnected, + "Tor connection status changed: $_enabled (failed)", + ), + ); + rethrow; + } + } + + Future stop() async { + if (_tor == null) { + throw Exception("TorService.init has not been called!"); + } + + if (!_enabled) { + // already stopped so just return + // could throw an exception here or something so the caller + // is explicitly made aware of this + // TODO make sure to kill + return; + } + + // Stop the Tor service. + try { + _tor!.disable(); + // no exception or error so we can (probably?) assume tor + // has started successfully + _enabled = false; + GlobalEventBus.instance.fire( + TorConnectionStatusChangedEvent( + TorConnectionStatus.disconnected, + "Tor connection status changed: $_enabled (disabled)", + ), + ); + } catch (e, s) { + Logging.instance.log( + "TorService.stop failed: $e\n$s", + level: LogLevel.Warning, + ); + rethrow; + } + } +} diff --git a/lib/themes/color_theme.dart b/lib/themes/color_theme.dart index c78d35c11..abec28d4e 100644 --- a/lib/themes/color_theme.dart +++ b/lib/themes/color_theme.dart @@ -31,6 +31,7 @@ class CoinThemeColorDefault { Color get stellar => const Color(0xFF6600FF); Color get nano => const Color(0xFF209CE9); Color get banano => const Color(0xFFFBDD11); + Color get tezos => const Color(0xFF0F61FF); Color forCoin(Coin coin) { switch (coin) { @@ -70,6 +71,8 @@ class CoinThemeColorDefault { return nano; case Coin.banano: return banano; + case Coin.tezos: + return tezos; } } } diff --git a/lib/themes/stack_colors.dart b/lib/themes/stack_colors.dart index 5dbd55fe1..cbec0077a 100644 --- a/lib/themes/stack_colors.dart +++ b/lib/themes/stack_colors.dart @@ -1714,6 +1714,8 @@ class StackColors extends ThemeExtension { return _coin.nano; case Coin.banano: return _coin.banano; + case Coin.tezos: + return _coin.tezos; } } diff --git a/lib/themes/theme_service.dart b/lib/themes/theme_service.dart index baeac44f2..62165d646 100644 --- a/lib/themes/theme_service.dart +++ b/lib/themes/theme_service.dart @@ -15,11 +15,13 @@ import 'package:archive/archive_io.dart'; import 'package:crypto/crypto.dart'; import 'package:flutter/services.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:http/http.dart'; import 'package:isar/isar.dart'; import 'package:stackwallet/db/isar/main_db.dart'; import 'package:stackwallet/models/isar/stack_theme.dart'; +import 'package:stackwallet/networking/http.dart'; +import 'package:stackwallet/services/tor_service.dart'; import 'package:stackwallet/utilities/logger.dart'; +import 'package:stackwallet/utilities/prefs.dart'; import 'package:stackwallet/utilities/stack_file_system.dart'; final pThemeService = Provider((ref) { @@ -39,6 +41,8 @@ class ThemeService { void init(MainDB db) => _db ??= db; + HTTP client = HTTP(); + Future install({required Uint8List themeArchiveData}) async { final themesDir = StackFileSystem.themesDir!; @@ -207,7 +211,11 @@ class ThemeService { Future> fetchThemes() async { try { - final response = await get(Uri.parse("$baseServerUrl/themes")); + final response = await client.get( + url: Uri.parse("$baseServerUrl/themes"), + proxyInfo: + Prefs.instance.useTor ? TorService.sharedInstance.proxyInfo : null, + ); final jsonList = jsonDecode(response.body) as List; @@ -230,10 +238,13 @@ class ThemeService { required StackThemeMetaData themeMetaData, }) async { try { - final response = - await get(Uri.parse("$baseServerUrl/theme/${themeMetaData.id}")); + final response = await client.get( + url: Uri.parse("$baseServerUrl/theme/${themeMetaData.id}"), + proxyInfo: + Prefs.instance.useTor ? TorService.sharedInstance.proxyInfo : null, + ); - final bytes = response.bodyBytes; + final bytes = Uint8List.fromList(response.bodyBytes); // verify hash final digest = sha256.convert(bytes); diff --git a/lib/utilities/address_utils.dart b/lib/utilities/address_utils.dart index 8766d706a..3fa895282 100644 --- a/lib/utilities/address_utils.dart +++ b/lib/utilities/address_utils.dart @@ -111,6 +111,8 @@ class AddressUtils { return NanoAccounts.isValid(NanoAccountType.NANO, address); case Coin.banano: return NanoAccounts.isValid(NanoAccountType.BANANO, address); + case Coin.tezos: + return RegExp(r"^tz[1-9A-HJ-NP-Za-km-z]{34}$").hasMatch(address); case Coin.bitcoinTestNet: return Address.validateAddress(address, testnet); case Coin.litecoinTestNet: diff --git a/lib/utilities/amount/amount_unit.dart b/lib/utilities/amount/amount_unit.dart index ccdd4e095..6a646fd11 100644 --- a/lib/utilities/amount/amount_unit.dart +++ b/lib/utilities/amount/amount_unit.dart @@ -1,6 +1,6 @@ -/* +/* * 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. @@ -52,6 +52,7 @@ enum AmountUnit { case Coin.epicCash: case Coin.stellar: // TODO: check if this is correct case Coin.stellarTestnet: + case Coin.tezos: return AmountUnit.values.sublist(0, 4); case Coin.monero: diff --git a/lib/utilities/assets.dart b/lib/utilities/assets.dart index 2ef82a989..de9cec988 100644 --- a/lib/utilities/assets.dart +++ b/lib/utilities/assets.dart @@ -92,6 +92,11 @@ class _SVG { final coinControl = const _COIN_CONTROL(); + String get connectedButton => "assets/svg/connected-button.svg"; + String get connectingButton => "assets/svg/connecting-button.svg"; + String get disconnectedButton => "assets/svg/disconnected-button.svg"; + String get circleTor => "assets/svg/tor-circle.svg"; + String get tor => "assets/svg/tor.svg"; String get monkey => "assets/svg/monkey.svg"; String get circleSliders => "assets/svg/configuration.svg"; String get circlePlus => "assets/svg/plus-circle.svg"; diff --git a/lib/utilities/block_explorers.dart b/lib/utilities/block_explorers.dart index 831332320..bb4ac06fb 100644 --- a/lib/utilities/block_explorers.dart +++ b/lib/utilities/block_explorers.dart @@ -1,6 +1,6 @@ -/* +/* * 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. @@ -62,6 +62,8 @@ Uri getDefaultBlockExplorerUrlFor({ return Uri.parse("https://www.bananolooker.com/block/$txid"); case Coin.stellarTestnet: return Uri.parse("https://testnet.stellarchain.io/transactions/$txid"); + case Coin.tezos: + return Uri.parse("https://tzstats.com/$txid"); } } diff --git a/lib/utilities/constants.dart b/lib/utilities/constants.dart index ae357c5b3..1253e08f1 100644 --- a/lib/utilities/constants.dart +++ b/lib/utilities/constants.dart @@ -1,6 +1,6 @@ -/* +/* * 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. @@ -34,7 +34,6 @@ abstract class Constants { // just use enable exchange flag // static bool enableBuy = enableExchange; // // true; // true for development, - static final BigInt _satsPerCoinECash = BigInt.from(100); static final BigInt _satsPerCoinEthereum = BigInt.from(1000000000000000000); static final BigInt _satsPerCoinMonero = BigInt.from(1000000000000); @@ -43,8 +42,10 @@ abstract class Constants { BigInt.parse("1000000000000000000000000000000"); // 1*10^30 static final BigInt _satsPerCoinBanano = BigInt.parse("100000000000000000000000000000"); // 1*10^29 - static final BigInt _satsPerCoinStellar = BigInt.from(10000000); // https://developers.stellar.org/docs/fundamentals-and-concepts/stellar-data-structures/assets#amount-precision + static final BigInt _satsPerCoinStellar = BigInt.from( + 10000000); // https://developers.stellar.org/docs/fundamentals-and-concepts/stellar-data-structures/assets#amount-precision static final BigInt _satsPerCoin = BigInt.from(100000000); + static final BigInt _satsPerCoinTezos = BigInt.from(1000000); static const int _decimalPlaces = 8; static const int _decimalPlacesNano = 30; static const int _decimalPlacesBanano = 29; @@ -53,6 +54,7 @@ abstract class Constants { static const int _decimalPlacesEthereum = 18; static const int _decimalPlacesECash = 2; static const int _decimalPlacesStellar = 7; + static const int _decimalPlacesTezos = 6; static const int notificationsMax = 0xFFFFFFFF; static const Duration networkAliveTimerDuration = Duration(seconds: 10); @@ -102,6 +104,9 @@ abstract class Constants { case Coin.stellar: case Coin.stellarTestnet: return _satsPerCoinStellar; + + case Coin.tezos: + return _satsPerCoinTezos; } } @@ -143,6 +148,9 @@ abstract class Constants { case Coin.stellar: case Coin.stellarTestnet: return _decimalPlacesStellar; + + case Coin.tezos: + return _decimalPlacesTezos; } } @@ -172,6 +180,8 @@ abstract class Constants { case Coin.banano: values.addAll([24, 12]); break; + case Coin.tezos: + values.addAll([24, 12]); case Coin.monero: values.addAll([25]); @@ -230,6 +240,9 @@ abstract class Constants { case Coin.stellar: case Coin.stellarTestnet: return 5; + + case Coin.tezos: + return 60; } } @@ -259,6 +272,7 @@ abstract class Constants { case Coin.banano: case Coin.stellar: case Coin.stellarTestnet: + case Coin.tezos: return 24; case Coin.monero: diff --git a/lib/utilities/default_nodes.dart b/lib/utilities/default_nodes.dart index 9a6a0d914..210959f65 100644 --- a/lib/utilities/default_nodes.dart +++ b/lib/utilities/default_nodes.dart @@ -1,6 +1,6 @@ -/* +/* * 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. @@ -191,8 +191,19 @@ abstract class DefaultNodes { enabled: true, coinName: Coin.stellar.name, isFailover: true, - isDown: false - ); + isDown: false); + + static NodeModel get tezos => NodeModel( + // TODO: Change this to stack wallet one + host: "https://mainnet.api.tez.ie", + port: 443, + name: defaultName, + id: _nodeId(Coin.tezos), + useSSL: true, + enabled: true, + coinName: Coin.tezos.name, + isFailover: true, + isDown: false); static NodeModel get nano => NodeModel( host: "https://rainstorm.city/api", @@ -277,16 +288,16 @@ abstract class DefaultNodes { ); static NodeModel get stellarTestnet => NodeModel( - host: "https://horizon-testnet.stellar.org/", - port: 50022, - name: defaultName, - id: _nodeId(Coin.stellarTestnet), - useSSL: true, - enabled: true, - coinName: Coin.stellarTestnet.name, - isFailover: true, - isDown: false, - ); + host: "https://horizon-testnet.stellar.org/", + port: 50022, + name: defaultName, + id: _nodeId(Coin.stellarTestnet), + useSSL: true, + enabled: true, + coinName: Coin.stellarTestnet.name, + isFailover: true, + isDown: false, + ); static NodeModel getNodeFor(Coin coin) { switch (coin) { @@ -335,6 +346,9 @@ abstract class DefaultNodes { case Coin.banano: return banano; + case Coin.tezos: + return tezos; + case Coin.bitcoinTestNet: return bitcoinTestnet; diff --git a/lib/utilities/enums/coin_enum.dart b/lib/utilities/enums/coin_enum.dart index 677d474e7..77af4b4d1 100644 --- a/lib/utilities/enums/coin_enum.dart +++ b/lib/utilities/enums/coin_enum.dart @@ -1,6 +1,6 @@ -/* +/* * 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. @@ -28,6 +28,7 @@ import 'package:stackwallet/services/coins/nano/nano_wallet.dart' as nano; import 'package:stackwallet/services/coins/particl/particl_wallet.dart' as particl; import 'package:stackwallet/services/coins/stellar/stellar_wallet.dart' as xlm; +import 'package:stackwallet/services/coins/tezos/tezos_wallet.dart' as tezos; import 'package:stackwallet/services/coins/wownero/wownero_wallet.dart' as wow; import 'package:stackwallet/utilities/constants.dart'; @@ -46,6 +47,7 @@ enum Coin { nano, particl, stellar, + tezos, wownero, /// @@ -61,7 +63,7 @@ enum Coin { stellarTestnet, } -final int kTestNetCoinCount = 4; // Util.isDesktop ? 5 : 4; +final int kTestNetCoinCount = 5; // Util.isDesktop ? 5 : 4; // remove firotestnet for now extension CoinExt on Coin { @@ -89,6 +91,8 @@ extension CoinExt on Coin { return "Particl"; case Coin.stellar: return "Stellar"; + case Coin.tezos: + return "Tezos"; case Coin.wownero: return "Wownero"; case Coin.namecoin: @@ -136,6 +140,8 @@ extension CoinExt on Coin { return "PART"; case Coin.stellar: return "XLM"; + case Coin.tezos: + return "XTZ"; case Coin.wownero: return "WOW"; case Coin.namecoin: @@ -184,6 +190,8 @@ extension CoinExt on Coin { return "particl"; case Coin.stellar: return "stellar"; + case Coin.tezos: + return "tezos"; case Coin.wownero: return "wownero"; case Coin.namecoin: @@ -227,6 +235,7 @@ extension CoinExt on Coin { case Coin.epicCash: case Coin.ethereum: case Coin.monero: + case Coin.tezos: case Coin.wownero: case Coin.nano: case Coin.banano: @@ -236,6 +245,36 @@ extension CoinExt on Coin { } } + bool get hasMnemonicPassphraseSupport { + switch (this) { + case Coin.bitcoin: + case Coin.bitcoinTestNet: + case Coin.litecoin: + case Coin.litecoinTestNet: + case Coin.bitcoincash: + case Coin.bitcoincashTestnet: + case Coin.dogecoin: + case Coin.dogecoinTestNet: + case Coin.firo: + case Coin.firoTestNet: + case Coin.namecoin: + case Coin.particl: + case Coin.ethereum: + case Coin.eCash: + case Coin.stellar: + case Coin.stellarTestnet: + return true; + + case Coin.epicCash: + case Coin.monero: + case Coin.wownero: + case Coin.nano: + case Coin.banano: + case Coin.tezos: + return false; + } + } + bool get hasBuySupport { switch (this) { case Coin.bitcoin: @@ -251,6 +290,7 @@ extension CoinExt on Coin { case Coin.eCash: case Coin.epicCash: case Coin.monero: + case Coin.tezos: case Coin.wownero: case Coin.dogecoinTestNet: case Coin.bitcoinTestNet: @@ -277,6 +317,7 @@ extension CoinExt on Coin { case Coin.epicCash: case Coin.ethereum: case Coin.monero: + case Coin.tezos: case Coin.wownero: case Coin.nano: case Coin.banano: @@ -306,6 +347,7 @@ extension CoinExt on Coin { case Coin.epicCash: case Coin.ethereum: case Coin.monero: + case Coin.tezos: case Coin.wownero: case Coin.nano: case Coin.banano: @@ -374,6 +416,9 @@ extension CoinExt on Coin { case Coin.stellarTestnet: return xlm.MINIMUM_CONFIRMATIONS; + case Coin.tezos: + return tezos.MINIMUM_CONFIRMATIONS; + case Coin.wownero: return wow.MINIMUM_CONFIRMATIONS; @@ -437,6 +482,10 @@ Coin coinFromPrettyName(String name) { case "stellar": return Coin.stellar; + case "Tezos": + case "tezos": + return Coin.tezos; + case "Namecoin": case "namecoin": return Coin.namecoin; @@ -483,6 +532,7 @@ Coin coinFromPrettyName(String name) { case "Stellar Testnet": case "stellarTestnet": + case "stellarTestNet": case "tStellar": return Coin.stellarTestnet; @@ -521,6 +571,8 @@ Coin coinFromTickerCaseInsensitive(String ticker) { return Coin.particl; case "xlm": return Coin.stellar; + case "xtz": + return Coin.tezos; case "tltc": return Coin.litecoinTestNet; case "tbtc": diff --git a/lib/utilities/enums/derive_path_type_enum.dart b/lib/utilities/enums/derive_path_type_enum.dart index 07785a5ee..5b94f41f6 100644 --- a/lib/utilities/enums/derive_path_type_enum.dart +++ b/lib/utilities/enums/derive_path_type_enum.dart @@ -1,6 +1,6 @@ -/* +/* * 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. @@ -51,6 +51,7 @@ extension DerivePathTypeExt on DerivePathType { case Coin.banano: case Coin.stellar: case Coin.stellarTestnet: + case Coin.tezos: // TODO: Is this true? throw UnsupportedError( "$coin does not use bitcoin style derivation paths"); } diff --git a/lib/utilities/paynym_is_api.dart b/lib/utilities/paynym_is_api.dart index f69e751cd..860848cac 100644 --- a/lib/utilities/paynym_is_api.dart +++ b/lib/utilities/paynym_is_api.dart @@ -11,13 +11,15 @@ import 'dart:convert'; import 'package:flutter/cupertino.dart'; -import 'package:http/http.dart' as http; import 'package:stackwallet/models/paynym/created_paynym.dart'; import 'package:stackwallet/models/paynym/paynym_account.dart'; import 'package:stackwallet/models/paynym/paynym_claim.dart'; import 'package:stackwallet/models/paynym/paynym_follow.dart'; import 'package:stackwallet/models/paynym/paynym_response.dart'; import 'package:stackwallet/models/paynym/paynym_unfollow.dart'; +import 'package:stackwallet/networking/http.dart'; +import 'package:stackwallet/services/tor_service.dart'; +import 'package:stackwallet/utilities/prefs.dart'; import 'package:tuple/tuple.dart'; // todo: better error message parsing (from response itself?) @@ -26,6 +28,8 @@ class PaynymIsApi { static const String baseURL = "https://paynym.is/api"; static const String version = "/v1"; + HTTP client = HTTP(); + Future, int>> _post( String endpoint, Map body, [ @@ -35,24 +39,32 @@ class PaynymIsApi { version + (endpoint.startsWith("/") ? endpoint : "/$endpoint"); final uri = Uri.parse(url); + + // Calculate the body length. + int contentLength = utf8.encode(jsonEncode(body)).length; + final headers = { 'Content-Type': 'application/json; charset=UTF-8', + 'content-length': + contentLength.toString(), // Set the Content-Length header. }..addAll(additionalHeaders); - final response = await http.post( - uri, + final response = await client.post( + url: uri, headers: headers, body: jsonEncode(body), + proxyInfo: + Prefs.instance.useTor ? TorService.sharedInstance.proxyInfo : null, ); debugPrint("Paynym request uri: $uri"); debugPrint("Paynym request body: $body"); debugPrint("Paynym request headers: $headers"); - debugPrint("Paynym response code: ${response.statusCode}"); + debugPrint("Paynym response code: ${response.code}"); debugPrint("Paynym response body: ${response.body}"); return Tuple2( jsonDecode(response.body) as Map, - response.statusCode, + response.code, ); } diff --git a/lib/utilities/prefs.dart b/lib/utilities/prefs.dart index 7c306bfe5..583d9804b 100644 --- a/lib/utilities/prefs.dart +++ b/lib/utilities/prefs.dart @@ -10,6 +10,8 @@ import 'package:flutter/cupertino.dart'; import 'package:stackwallet/db/hive/db.dart'; +import 'package:stackwallet/services/event_bus/events/global/tor_status_changed_event.dart'; +import 'package:stackwallet/services/event_bus/global_event_bus.dart'; import 'package:stackwallet/utilities/amount/amount_unit.dart'; import 'package:stackwallet/utilities/constants.dart'; import 'package:stackwallet/utilities/enums/backup_frequency_type.dart'; @@ -42,6 +44,7 @@ class Prefs extends ChangeNotifier { _lastUnlocked = await _getLastUnlocked(); _lastUnlockedTimeout = await _getLastUnlockedTimeout(); _showTestNetCoins = await _getShowTestNetCoins(); + _torKillswitch = await _getTorKillswitch(); _isAutoBackupEnabled = await _getIsAutoBackupEnabled(); _autoBackupLocation = await _getAutoBackupLocation(); _backupFrequencyType = await _getBackupFrequencyType(); @@ -60,6 +63,7 @@ class Prefs extends ChangeNotifier { _systemBrightnessDarkThemeId = await _getSystemBrightnessDarkTheme(); await _setAmountUnits(); await _setMaxDecimals(); + _useTor = await _getUseTor(); _initialized = true; } @@ -393,6 +397,32 @@ class Prefs extends ChangeNotifier { 0; } + // tor + + bool _torKillswitch = true; + + bool get torKillSwitch => _torKillswitch; + + set torKillSwitch(bool torKillswitch) { + if (_torKillswitch != torKillswitch) { + DB.instance.put( + boxName: DB.boxNamePrefs, + key: "torKillswitch", + value: torKillswitch, + ); + _torKillswitch = torKillswitch; + notifyListeners(); + } + } + + Future _getTorKillswitch() async { + return await DB.instance.get( + boxName: DB.boxNamePrefs, + key: "torKillswitch", + ) as bool? ?? + true; + } + // show testnet coins bool _showTestNetCoins = false; @@ -869,4 +899,36 @@ class Prefs extends ChangeNotifier { _amountDecimals[coin] = decimals; } } + + // enabled tor + + bool _useTor = false; + + bool get useTor => _useTor; + + set useTor(bool useTor) { + if (_useTor != useTor) { + DB.instance.put( + boxName: DB.boxNamePrefs, + key: "useTor", + value: useTor, + ); + _useTor = useTor; + notifyListeners(); + GlobalEventBus.instance.fire( + TorPreferenceChangedEvent( + status: useTor ? TorStatus.enabled : TorStatus.disabled, + message: "useTor updated in prefs", + ), + ); + } + } + + Future _getUseTor() async { + return await DB.instance.get( + boxName: DB.boxNamePrefs, + key: "useTor", + ) as bool? ?? + false; + } } diff --git a/lib/utilities/stack_file_system.dart b/lib/utilities/stack_file_system.dart index f36fadf01..4fb3e4617 100644 --- a/lib/utilities/stack_file_system.dart +++ b/lib/utilities/stack_file_system.dart @@ -60,6 +60,19 @@ abstract class StackFileSystem { } } + static Future applicationTorDirectory() async { + final root = await applicationRootDirectory(); + if (Util.isDesktop) { + final dir = Directory("${root.path}/tor"); + if (!dir.existsSync()) { + await dir.create(); + } + return dir; + } else { + return root; + } + } + static Future applicationHiveDirectory() async { final root = await applicationRootDirectory(); if (Util.isDesktop) { diff --git a/lib/utilities/test_epic_box_connection.dart b/lib/utilities/test_epic_box_connection.dart index c65f85ac7..ed2fd4828 100644 --- a/lib/utilities/test_epic_box_connection.dart +++ b/lib/utilities/test_epic_box_connection.dart @@ -10,22 +10,29 @@ import 'dart:convert'; -import 'package:http/http.dart' as http; +import 'package:stackwallet/networking/http.dart'; import 'package:stackwallet/pages/settings_views/global_settings_view/manage_nodes_views/add_edit_node_view.dart'; +import 'package:stackwallet/services/tor_service.dart'; import 'package:stackwallet/utilities/logger.dart'; +import 'package:stackwallet/utilities/prefs.dart'; Future _testEpicBoxNodeConnection(Uri uri) async { + HTTP client = HTTP(); try { - final client = http.Client(); - final response = await client.get( - uri, - headers: {'Content-Type': 'application/json'}, - ).timeout(const Duration(milliseconds: 2000), - onTimeout: () async => http.Response('Error', 408)); + final response = await client + .get( + url: uri, + headers: {'Content-Type': 'application/json'}, + proxyInfo: Prefs.instance.useTor + ? TorService.sharedInstance.proxyInfo + : null, + ) + .timeout(const Duration(milliseconds: 2000), + onTimeout: () async => Response(utf8.encode('Error'), 408)); final json = jsonDecode(response.body); - if (response.statusCode == 200 && json["node_version"] != null) { + if (response.code == 200 && json["node_version"] != null) { return true; } else { return false; diff --git a/lib/utilities/test_stellar_node_connection.dart b/lib/utilities/test_stellar_node_connection.dart new file mode 100644 index 000000000..32f756025 --- /dev/null +++ b/lib/utilities/test_stellar_node_connection.dart @@ -0,0 +1,40 @@ +import 'dart:convert'; + +import 'package:stackwallet/networking/http.dart' as http; +import 'package:stackwallet/services/tor_service.dart'; +import 'package:stackwallet/utilities/prefs.dart'; +import 'package:stellar_flutter_sdk/stellar_flutter_sdk.dart'; + +Future testStellarNodeConnection(String host, int port) async { + http.HTTP client = http.HTTP(); + Uri uri = Uri.parse("$host:$port"); + + final response = await client + .get( + url: uri, + headers: {'Content-Type': 'application/json'}, + proxyInfo: + Prefs.instance.useTor ? TorService.sharedInstance.proxyInfo : null, + ) + .timeout(const Duration(milliseconds: 2000), + onTimeout: () async => http.Response(utf8.encode('Error'), 408)); + + if (response.code == 200) { + //Get chain height for sdk + StellarSDK stellarSdk = StellarSDK(host); + final height = await stellarSdk.ledgers + .order(RequestBuilderOrder.DESC) + .limit(1) + .execute() + .then((value) => value.records!.first.sequence) + .onError((error, stackTrace) => throw ("Error getting chain height")); + + if (height > 0) { + return true; + } else { + return false; + } + } else { + return false; + } +} diff --git a/lib/widgets/desktop/desktop_tor_status_button.dart b/lib/widgets/desktop/desktop_tor_status_button.dart new file mode 100644 index 000000000..42677aa0f --- /dev/null +++ b/lib/widgets/desktop/desktop_tor_status_button.dart @@ -0,0 +1,191 @@ +import 'dart:async'; + +import 'package:event_bus/event_bus.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_native_splash/cli_commands.dart'; +import 'package:flutter_riverpod/flutter_riverpod.dart'; +import 'package:flutter_svg/flutter_svg.dart'; +import 'package:stackwallet/pages_desktop_specific/desktop_menu_item.dart'; +import 'package:stackwallet/services/event_bus/events/global/tor_connection_status_changed_event.dart'; +import 'package:stackwallet/services/event_bus/global_event_bus.dart'; +import 'package:stackwallet/services/tor_service.dart'; +import 'package:stackwallet/themes/stack_colors.dart'; +import 'package:stackwallet/utilities/assets.dart'; +import 'package:stackwallet/utilities/text_styles.dart'; + +class DesktopTorStatusButton extends ConsumerStatefulWidget { + const DesktopTorStatusButton({ + super.key, + this.onPressed, + required this.transitionDuration, + this.controller, + this.labelLength = 125, + }); + + final VoidCallback? onPressed; + final Duration transitionDuration; + final DMIController? controller; + final double labelLength; + + @override + ConsumerState createState() => + _DesktopTorStatusButtonState(); +} + +class _DesktopTorStatusButtonState extends ConsumerState + with SingleTickerProviderStateMixin { + late final AnimationController animationController; + late final DMIController? controller; + late final double labelLength; + + /// The global event bus. + late final EventBus eventBus; + + /// The subscription to the TorConnectionStatusChangedEvent. + late final StreamSubscription + _torConnectionStatusSubscription; + + /// The current status of the Tor connection. + late TorConnectionStatus _torConnectionStatus; + + Color _color(TorConnectionStatus status) { + switch (status) { + case TorConnectionStatus.disconnected: + return Theme.of(context).extension()!.textSubtitle3; + case TorConnectionStatus.connecting: + return Theme.of(context).extension()!.accentColorYellow; + case TorConnectionStatus.connected: + return Theme.of(context).extension()!.accentColorGreen; + } + } + + bool _iconOnly = false; + + void toggle() { + setState(() { + _iconOnly = !_iconOnly; + }); + if (_iconOnly) { + animationController.reverse(); + } else { + animationController.forward(); + } + } + + @override + void initState() { + labelLength = widget.labelLength; + controller = widget.controller; + + // Initialize the global event bus. + eventBus = GlobalEventBus.instance; + + // Initialize the TorConnectionStatus. + _torConnectionStatus = ref.read(pTorService).enabled + ? TorConnectionStatus.connected + : TorConnectionStatus.disconnected; + + // Subscribe to the TorConnectionStatusChangedEvent. + _torConnectionStatusSubscription = + eventBus.on().listen( + (event) async { + // Rebuild the widget. + setState(() { + _torConnectionStatus = event.newStatus; + }); + + // TODO implement spinner or animations and control from here + // switch (event.newStatus) { + // case TorConnectionStatus.disconnected: + // // if (_spinController.hasLoadedAnimation) { + // // _spinController.stop?.call(); + // // } + // break; + // case TorConnectionStatus.connecting: + // // if (_spinController.hasLoadedAnimation) { + // // _spinController.repeat?.call(); + // // } + // break; + // case TorConnectionStatus.connected: + // // if (_spinController.hasLoadedAnimation) { + // // _spinController.stop?.call(); + // // } + // break; + // } + }, + ); + + controller?.toggle = toggle; + animationController = AnimationController( + vsync: this, + duration: widget.transitionDuration, + )..forward(); + + super.initState(); + } + + @override + void dispose() { + // Clean up the subscription to the TorConnectionStatusChangedEvent. + _torConnectionStatusSubscription.cancel(); + + controller?.dispose(); + animationController.dispose(); + super.dispose(); + } + + @override + Widget build(BuildContext context) { + return TextButton( + style: Theme.of(context) + .extension()! + .getDesktopMenuButtonStyle(context), + onPressed: widget.onPressed, + child: Padding( + padding: const EdgeInsets.symmetric( + vertical: 16, + ), + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + AnimatedContainer( + duration: widget.transitionDuration, + width: _iconOnly ? 0 : 16, + ), + SvgPicture.asset( + Assets.svg.tor, + color: _color(_torConnectionStatus), + width: 20, + height: 20, + ), + AnimatedOpacity( + duration: widget.transitionDuration, + opacity: _iconOnly ? 0 : 1.0, + child: SizeTransition( + sizeFactor: animationController, + axis: Axis.horizontal, + axisAlignment: -1, + child: SizedBox( + width: labelLength, + child: Row( + children: [ + const SizedBox( + width: 12, + ), + Text( + _torConnectionStatus.name.capitalize(), + style: STextStyles.smallMed12(context).copyWith( + color: _color(_torConnectionStatus), + ), + ), + ], + ), + ), + ), + ), + ], + ), + ), + ); + } +} diff --git a/lib/widgets/node_card.dart b/lib/widgets/node_card.dart index 57482119c..44b8a696a 100644 --- a/lib/widgets/node_card.dart +++ b/lib/widgets/node_card.dart @@ -29,6 +29,7 @@ import 'package:stackwallet/utilities/logger.dart'; import 'package:stackwallet/utilities/test_epic_box_connection.dart'; import 'package:stackwallet/utilities/test_eth_node_connection.dart'; import 'package:stackwallet/utilities/test_monero_node_connection.dart'; +import 'package:stackwallet/utilities/test_stellar_node_connection.dart'; import 'package:stackwallet/utilities/text_styles.dart'; import 'package:stackwallet/utilities/util.dart'; import 'package:stackwallet/widgets/conditional_parent.dart'; @@ -194,10 +195,17 @@ class _NodeCardState extends ConsumerState { case Coin.nano: case Coin.banano: + case Coin.tezos: + //TODO: check network/node + throw UnimplementedError(); case Coin.stellar: case Coin.stellarTestnet: - throw UnimplementedError(); - //TODO: check network/node + try { + testPassed = await testStellarNodeConnection(node.host, node.port); + } catch (_) { + testPassed = false; + } + break; } if (testPassed) { diff --git a/lib/widgets/node_options_sheet.dart b/lib/widgets/node_options_sheet.dart index b55f818a2..5dfa68d27 100644 --- a/lib/widgets/node_options_sheet.dart +++ b/lib/widgets/node_options_sheet.dart @@ -1,6 +1,6 @@ -/* +/* * 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. @@ -19,6 +19,7 @@ import 'package:stackwallet/notifications/show_flush_bar.dart'; import 'package:stackwallet/pages/settings_views/global_settings_view/manage_nodes_views/add_edit_node_view.dart'; import 'package:stackwallet/pages/settings_views/global_settings_view/manage_nodes_views/node_details_view.dart'; import 'package:stackwallet/providers/providers.dart'; +import 'package:stackwallet/services/tor_service.dart'; import 'package:stackwallet/themes/stack_colors.dart'; import 'package:stackwallet/utilities/assets.dart'; import 'package:stackwallet/utilities/constants.dart'; @@ -157,6 +158,7 @@ class NodeOptionsSheet extends ConsumerWidget { useSSL: node.useSSL, failovers: [], prefs: ref.read(prefsChangeNotifierProvider), + torService: ref.read(pTorService), ); try { @@ -177,10 +179,11 @@ class NodeOptionsSheet extends ConsumerWidget { case Coin.nano: case Coin.banano: + case Coin.tezos: case Coin.stellar: case Coin.stellarTestnet: throw UnimplementedError(); - //TODO: check network/node + //TODO: check network/node } if (testPassed) { diff --git a/lib/widgets/small_tor_icon.dart b/lib/widgets/small_tor_icon.dart new file mode 100644 index 000000000..c032fbdae --- /dev/null +++ b/lib/widgets/small_tor_icon.dart @@ -0,0 +1,76 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_riverpod/flutter_riverpod.dart'; +import 'package:flutter_svg/flutter_svg.dart'; +import 'package:stackwallet/pages/settings_views/global_settings_view/tor_settings/tor_settings_view.dart'; +import 'package:stackwallet/services/event_bus/events/global/tor_connection_status_changed_event.dart'; +import 'package:stackwallet/services/tor_service.dart'; +import 'package:stackwallet/themes/stack_colors.dart'; +import 'package:stackwallet/utilities/assets.dart'; +import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart'; +import 'package:stackwallet/widgets/tor_subscription.dart'; + +class SmallTorIcon extends ConsumerStatefulWidget { + const SmallTorIcon({super.key}); + + @override + ConsumerState createState() => _SmallTorIconState(); +} + +class _SmallTorIconState extends ConsumerState { + late TorConnectionStatus _status; + + Color _color( + TorConnectionStatus status, + StackColors colors, + ) { + switch (status) { + case TorConnectionStatus.disconnected: + return colors.textSubtitle3; + + case TorConnectionStatus.connected: + return colors.accentColorGreen; + + case TorConnectionStatus.connecting: + return colors.accentColorYellow; + } + } + + @override + void initState() { + _status = ref.read(pTorService).enabled + ? TorConnectionStatus.connected + : TorConnectionStatus.disconnected; + + super.initState(); + } + + @override + Widget build(BuildContext context) { + return TorSubscription( + onTorStatusChanged: (status) { + setState(() { + _status = status; + }); + }, + child: AppBarIconButton( + semanticsLabel: "Tor Settings Button. Takes To Tor Settings Page.", + key: const Key("walletsViewTorButton"), + size: 36, + shadows: const [], + color: Theme.of(context).extension()!.backgroundAppBar, + icon: SvgPicture.asset( + Assets.svg.tor, + color: _color( + _status, + Theme.of(context).extension()!, + ), + width: 20, + height: 20, + ), + onPressed: () { + Navigator.of(context).pushNamed(TorSettingsView.routeName); + }, + ), + ); + } +} diff --git a/lib/widgets/stack_dialog.dart b/lib/widgets/stack_dialog.dart index fead6a00a..be7f22ed9 100644 --- a/lib/widgets/stack_dialog.dart +++ b/lib/widgets/stack_dialog.dart @@ -18,15 +18,22 @@ class StackDialogBase extends StatelessWidget { Key? key, this.child, this.padding = const EdgeInsets.all(24), + this.keyboardPaddingAmount = 0, }) : super(key: key); final EdgeInsets padding; final Widget? child; + final double keyboardPaddingAmount; @override Widget build(BuildContext context) { return Padding( - padding: const EdgeInsets.all(16), + padding: EdgeInsets.only( + top: 16, + left: 16, + right: 16, + bottom: 16 + keyboardPaddingAmount, + ), child: Column( mainAxisAlignment: !Util.isDesktop ? MainAxisAlignment.end : MainAxisAlignment.center, diff --git a/lib/widgets/tor_subscription.dart b/lib/widgets/tor_subscription.dart new file mode 100644 index 000000000..30904e9f4 --- /dev/null +++ b/lib/widgets/tor_subscription.dart @@ -0,0 +1,61 @@ +import 'dart:async'; + +import 'package:event_bus/event_bus.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_riverpod/flutter_riverpod.dart'; +import 'package:stackwallet/services/event_bus/events/global/tor_connection_status_changed_event.dart'; +import 'package:stackwallet/services/event_bus/global_event_bus.dart'; + +class TorSubscription extends ConsumerStatefulWidget { + const TorSubscription({ + super.key, + required this.onTorStatusChanged, + this.eventBus, + required this.child, + }); + + final Widget child; + final void Function(TorConnectionStatus) onTorStatusChanged; + final EventBus? eventBus; + + @override + ConsumerState createState() => _TorSubscriptionBaseState(); +} + +class _TorSubscriptionBaseState extends ConsumerState { + /// The global event bus. + late final EventBus eventBus; + + /// Subscription to the TorConnectionStatusChangedEvent. + late StreamSubscription + _torConnectionStatusSubscription; + + @override + void initState() { + // Initialize the global event bus. + eventBus = widget.eventBus ?? GlobalEventBus.instance; + + // Subscribe to the TorConnectionStatusChangedEvent. + _torConnectionStatusSubscription = + eventBus.on().listen( + (event) async { + widget.onTorStatusChanged.call(event.newStatus); + }, + ); + + super.initState(); + } + + @override + void dispose() { + // Clean up the TorConnectionStatusChangedEvent subscription. + _torConnectionStatusSubscription.cancel(); + + super.dispose(); + } + + @override + Widget build(BuildContext context) { + return widget.child; + } +} diff --git a/linux/flutter/generated_plugins.cmake b/linux/flutter/generated_plugins.cmake index 38eed0699..f48fdcd94 100644 --- a/linux/flutter/generated_plugins.cmake +++ b/linux/flutter/generated_plugins.cmake @@ -15,6 +15,7 @@ list(APPEND FLUTTER_PLUGIN_LIST ) list(APPEND FLUTTER_FFI_PLUGIN_LIST + tor_ffi_plugin ) set(PLUGIN_BUNDLED_LIBRARIES) diff --git a/pubspec.lock b/pubspec.lock index 78444847c..5afff2752 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -25,6 +25,14 @@ packages: url: "https://pub.dev" source: hosted version: "1.12.30" + ansicolor: + dependency: transitive + description: + name: ansicolor + sha256: "607f8fa9786f392043f169898923e6c59b4518242b68b8862eb8a8b7d9c30b4a" + url: "https://pub.dev" + source: hosted + version: "2.0.1" archive: dependency: "direct main" description: @@ -306,10 +314,10 @@ packages: dependency: "direct main" description: name: crypto - sha256: ff625774173754681d66daaf4a448684fb04b78f902da9cb3d308c19cc5e8bab + sha256: aa274aa7774f8964e4f4f38cc994db7b6158dd36e9187aaceaddc994b35c6c67 url: "https://pub.dev" source: hosted - version: "3.0.3" + version: "3.0.2" cryptography: dependency: transitive description: @@ -462,10 +470,10 @@ packages: dependency: transitive description: name: dio - sha256: "3866d67f93523161b643187af65f5ac08bc991a5bcdaf41a2d587fe4ccb49993" + sha256: "7d328c4d898a61efc3cd93655a0955858e29a0aa647f0f9e02d59b3bb275e2e8" url: "https://pub.dev" source: hosted - version: "5.3.0" + version: "4.0.6" dropdown_button2: dependency: "direct main" description: @@ -542,10 +550,10 @@ packages: dependency: "direct main" description: name: ffi - sha256: ed5337a5660c506388a9f012be0288fb38b49020ce2b45fe1f8b8323fe429f99 + sha256: "7bf0adc28a23d395f19f3f1eb21dd7cfd1dd9f8e1c50051c069122e6853bc878" url: "https://pub.dev" source: hosted - version: "2.0.2" + version: "2.1.0" file: dependency: transitive description: @@ -557,11 +565,12 @@ packages: file_picker: dependency: "direct main" description: - name: file_picker - sha256: b1729fc96627dd44012d0a901558177418818d6bd428df59dcfeb594e5f66432 - url: "https://pub.dev" - source: hosted - version: "5.3.2" + path: "." + ref: f0930d9fa79d347b2a0e25a7de4f5a4a88a9a907 + resolved-ref: f0930d9fa79d347b2a0e25a7de4f5a4a88a9a907 + url: "https://github.com/muttsu-623/flutter_file_picker.git" + source: git + version: "5.3.3" fixnum: dependency: transitive description: @@ -742,10 +751,10 @@ packages: dependency: "direct main" description: name: flutter_svg - sha256: "6ff9fa12892ae074092de2fa6a9938fb21dbabfdaa2ff57dc697ff912fc8d4b2" + sha256: "8c5d68a82add3ca76d792f058b186a0599414f279f00ece4830b9b231b570338" url: "https://pub.dev" source: hosted - version: "1.1.6" + version: "2.0.7" flutter_test: dependency: "direct dev" description: flutter @@ -957,6 +966,14 @@ packages: url: "https://pub.dev" source: hosted version: "3.0.2" + json_serializable: + dependency: transitive + description: + name: json_serializable + sha256: aa1f5a8912615733e0fdc7a02af03308933c93235bdc8d50d0b0c8a8ccb0b969 + url: "https://pub.dev" + source: hosted + version: "6.7.1" keyboard_dismisser: dependency: "direct main" description: @@ -1020,6 +1037,14 @@ packages: url: "https://pub.dev" source: hosted version: "0.2.0" + memoize: + dependency: transitive + description: + name: memoize + sha256: "51481d328c86cbdc59711369179bac88551ca0556569249be5317e66fc796cac" + url: "https://pub.dev" + source: hosted + version: "3.0.0" meta: dependency: transitive description: @@ -1132,14 +1157,6 @@ packages: url: "https://pub.dev" source: hosted version: "1.8.3" - path_drawing: - dependency: transitive - description: - name: path_drawing - sha256: bbb1934c0cbb03091af082a6389ca2080345291ef07a5fa6d6e078ba8682f977 - url: "https://pub.dev" - source: hosted - version: "1.0.1" path_parsing: dependency: transitive description: @@ -1152,66 +1169,66 @@ packages: dependency: "direct main" description: name: path_provider - sha256: "3087813781ab814e4157b172f1a11c46be20179fcc9bea043e0fba36bc0acaa2" + sha256: a1aa8aaa2542a6bc57e381f132af822420216c80d4781f7aa085ca3229208aaa url: "https://pub.dev" source: hosted - version: "2.0.15" + version: "2.1.1" path_provider_android: dependency: transitive description: name: path_provider_android - sha256: "2cec049d282c7f13c594b4a73976b0b4f2d7a1838a6dd5aaf7bd9719196bee86" + sha256: "6b8b19bd80da4f11ce91b2d1fb931f3006911477cec227cce23d3253d80df3f1" url: "https://pub.dev" source: hosted - version: "2.0.27" + version: "2.2.0" path_provider_foundation: dependency: transitive description: name: path_provider_foundation - sha256: "916731ccbdce44d545414dd9961f26ba5fbaa74bcbb55237d8e65a623a8c7297" + sha256: "19314d595120f82aca0ba62787d58dde2cc6b5df7d2f0daf72489e38d1b57f2d" url: "https://pub.dev" source: hosted - version: "2.2.4" + version: "2.3.1" path_provider_linux: dependency: transitive description: name: path_provider_linux - sha256: ffbb8cc9ed2c9ec0e4b7a541e56fd79b138e8f47d2fb86815f15358a349b3b57 + sha256: f7a1fe3a634fe7734c8d3f2766ad746ae2a2884abe22e241a8b301bf5cac3279 url: "https://pub.dev" source: hosted - version: "2.1.11" + version: "2.2.1" path_provider_platform_interface: dependency: transitive description: name: path_provider_platform_interface - sha256: "57585299a729335f1298b43245842678cb9f43a6310351b18fb577d6e33165ec" + sha256: "94b1e0dd80970c1ce43d5d4e050a9918fce4f4a775e6142424c30a29a363265c" url: "https://pub.dev" source: hosted - version: "2.0.6" + version: "2.1.1" path_provider_windows: dependency: transitive description: name: path_provider_windows - sha256: "1cb68ba4cd3a795033de62ba1b7b4564dace301f952de6bfb3cd91b202b6ee96" + sha256: "8bc9f22eee8690981c22aa7fc602f5c85b497a6fb2ceb35ee5a5e5ed85ad8170" url: "https://pub.dev" source: hosted - version: "2.1.7" + version: "2.2.1" permission_handler: dependency: "direct main" description: name: permission_handler - sha256: "63e5216aae014a72fe9579ccd027323395ce7a98271d9defa9d57320d001af81" + sha256: ad65ba9af42a3d067203641de3fd9f547ded1410bad3b84400c2b4899faede70 url: "https://pub.dev" source: hosted - version: "10.4.3" + version: "11.0.0" permission_handler_android: dependency: transitive description: name: permission_handler_android - sha256: "2ffaf52a21f64ac9b35fe7369bb9533edbd4f698e5604db8645b1064ff4cf221" + sha256: "6901d50f4d4b9a27e1749dbd4adbf06aa00d90a21a2db563405d5ce27ee120ac" url: "https://pub.dev" source: hosted - version: "10.3.3" + version: "11.0.0" permission_handler_apple: dependency: transitive description: @@ -1224,10 +1241,10 @@ packages: dependency: transitive description: name: permission_handler_platform_interface - sha256: "7c6b1500385dd1d2ca61bb89e2488ca178e274a69144d26bbd65e33eae7c02a9" + sha256: f2343e9fa9c22ae4fd92d4732755bfe452214e7189afcc097380950cf567b4b2 url: "https://pub.dev" source: hosted - version: "3.11.3" + version: "3.11.5" permission_handler_windows: dependency: transitive description: @@ -1245,13 +1262,13 @@ packages: source: hosted version: "5.4.0" pinenacl: - dependency: transitive + dependency: "direct overridden" description: name: pinenacl - sha256: "3a5503637587d635647c93ea9a8fecf48a420cc7deebe6f1fc85c2a5637ab327" + sha256: e5fb0bce1717b7f136f35ee98b5c02b3e6383211f8a77ca882fa7812232a07b9 url: "https://pub.dev" source: hosted - version: "0.5.1" + version: "0.3.4" platform: dependency: transitive description: @@ -1284,6 +1301,14 @@ packages: url: "https://pub.dev" source: hosted version: "1.5.1" + pretty_dio_logger: + dependency: transitive + description: + name: pretty_dio_logger + sha256: "948f7eeb36e7aa0760b51c1a8e3331d4b21e36fabd39efca81f585ed93893544" + url: "https://pub.dev" + source: hosted + version: "1.2.0-beta-1" process: dependency: transitive description: @@ -1332,6 +1357,14 @@ packages: url: "https://pub.dev" source: hosted version: "4.1.0" + quiver: + dependency: transitive + description: + name: quiver + sha256: b1c1ac5ce6688d77f65f3375a9abb9319b3cb32486bdc7a1e0fdf004d7ba4e47 + url: "https://pub.dev" + source: hosted + version: "3.2.1" rational: dependency: transitive description: @@ -1340,6 +1373,14 @@ packages: url: "https://pub.dev" source: hosted version: "2.2.2" + retry: + dependency: transitive + description: + name: retry + sha256: "822e118d5b3aafed083109c72d5f484c6dc66707885e07c0fbcb8b986bba7efc" + url: "https://pub.dev" + source: hosted + version: "3.1.2" riverpod: dependency: transitive description: @@ -1417,6 +1458,14 @@ packages: description: flutter source: sdk version: "0.0.99" + socks5_proxy: + dependency: "direct main" + description: + name: socks5_proxy + sha256: e0cba6917cd374de6f6cb0ce081e50e6efc24c61644b8e9f20c8bf8b91bb0b75 + url: "https://pub.dev" + source: hosted + version: "1.0.3+dev.3" source_gen: dependency: transitive description: @@ -1486,10 +1535,10 @@ packages: dependency: "direct main" description: name: stellar_flutter_sdk - sha256: "7a9b7dc76018bbd0b9c828045cf0e26e07ec44208fb1a1733273de2390205475" + sha256: "4c55b1b6dfbde7f89bba59a422754280715fa3b5726cff5e7eeaed454d2c4b89" url: "https://pub.dev" source: hosted - version: "1.6.0" + version: "1.5.3" stream_channel: dependency: transitive description: @@ -1562,6 +1611,14 @@ packages: url: "https://pub.dev" source: hosted version: "0.5.1" + tezart: + dependency: "direct main" + description: + name: tezart + sha256: "35d526f2e6ca250c64461ebfb4fa9f64b6599fab8c4242c8e89ae27d4ac2e15a" + url: "https://pub.dev" + source: hosted + version: "2.0.5" time: dependency: transitive description: @@ -1602,6 +1659,13 @@ packages: url: "https://pub.dev" source: hosted version: "0.13.1" + tor_ffi_plugin: + dependency: "direct main" + description: + path: "crypto_plugins/tor" + relative: true + source: path + version: "0.0.1" tuple: dependency: "direct main" description: @@ -1706,6 +1770,30 @@ packages: url: "https://pub.dev" source: hosted version: "3.0.7" + vector_graphics: + dependency: transitive + description: + name: vector_graphics + sha256: "670f6e07aca990b4a2bcdc08a784193c4ccdd1932620244c3a86bb72a0eac67f" + url: "https://pub.dev" + source: hosted + version: "1.1.7" + vector_graphics_codec: + dependency: transitive + description: + name: vector_graphics_codec + sha256: "7451721781d967db9933b63f5733b1c4533022c0ba373a01bdd79d1a5457f69f" + url: "https://pub.dev" + source: hosted + version: "1.1.7" + vector_graphics_compiler: + dependency: transitive + description: + name: vector_graphics_compiler + sha256: "80a13c613c8bde758b1464a1755a7b3a8f2b6cec61fbf0f5a53c94c30f03ba2e" + url: "https://pub.dev" + source: hosted + version: "1.1.7" vector_math: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index 7a218d72e..352d6f09c 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.17+185 +version: 1.7.20+188 environment: sdk: ">=3.0.2 <4.0.0" @@ -57,10 +57,13 @@ dependencies: url: https://github.com/cypherstack/bip47.git ref: 081ca1863c2feba00c35bb5b297902f12f499941 + tor_ffi_plugin: + path: ./crypto_plugins/tor + # Utility plugins http: ^0.13.0 local_auth: ^1.1.10 - permission_handler: ^10.0.0 + permission_handler: ^11.0.0 flutter_local_notifications: ^9.4.0 rxdart: ^0.27.3 zxcvbn: ^1.0.0 @@ -101,7 +104,7 @@ dependencies: flutter_native_splash: ^2.2.4 google_fonts: ^4.0.4 url_launcher: ^6.0.5 - flutter_svg: ^1.0.1 + flutter_svg: ^2.0.7 flutter_feather_icons: ^2.0.0+1 decimal: ^2.1.0 event_bus: ^2.0.0 @@ -123,7 +126,7 @@ dependencies: pointycastle: ^3.6.0 package_info_plus: ^4.0.2 lottie: ^2.3.2 - file_picker: ^5.3.1 + file_picker: ^5.5.0 connectivity_plus: ^4.0.1 isar: 3.0.5 isar_flutter_libs: 3.0.5 # contains the binaries @@ -142,7 +145,8 @@ dependencies: fusiondart: path: ./fusiondart bip340: ^0.2.0 - + tezart: ^2.0.5 + socks5_proxy: ^1.0.3+dev.3 dev_dependencies: flutter_test: @@ -204,6 +208,14 @@ dependency_overrides: ref: 0cd6d54e2860bea68fc50c801cb9db2a760192fb + file_picker: + git: + url: https://github.com/muttsu-623/flutter_file_picker.git + ref: f0930d9fa79d347b2a0e25a7de4f5a4a88a9a907 + + crypto: 3.0.2 + analyzer: ^5.2.0 + pinenacl: ^0.3.3 # For information on the generic Dart part of this file, see the # following page: https://dart.dev/tools/pub/pubspec @@ -343,6 +355,11 @@ flutter: - assets/svg/send.svg - assets/svg/ordinal.svg - assets/svg/monkey.svg + - assets/svg/tor.svg + - assets/svg/tor-circle.svg + - assets/svg/connected-button.svg + - assets/svg/connecting-button.svg + - assets/svg/disconnected-button.svg # coin control icons - assets/svg/coin_control/ diff --git a/scripts/android/build_all.sh b/scripts/android/build_all.sh index a0050dc9e..111fea934 100755 --- a/scripts/android/build_all.sh +++ b/scripts/android/build_all.sh @@ -7,6 +7,7 @@ mkdir build (cd ../../crypto_plugins/flutter_liblelantus/scripts/android && ./build_all.sh ) & (cd ../../crypto_plugins/flutter_libepiccash/scripts/android && ./install_ndk.sh && ./build_all.sh ) & (cd ../../crypto_plugins/flutter_libmonero/scripts/android/ && ./build_all.sh ) & +(cd ../../crypto_plugins/tor/scripts/android && ./install_ndk.sh && ./build_all.sh ) & wait echo "Done building" diff --git a/scripts/linux/build_all.sh b/scripts/linux/build_all.sh index 31edfb872..9a119d0d6 100755 --- a/scripts/linux/build_all.sh +++ b/scripts/linux/build_all.sh @@ -9,6 +9,7 @@ mkdir -p build (cd ../../crypto_plugins/flutter_liblelantus/scripts/linux && ./build_all.sh ) & (cd ../../crypto_plugins/flutter_libepiccash/scripts/linux && ./build_all.sh ) & (cd ../../crypto_plugins/flutter_libmonero/scripts/linux && ./build_monero_all.sh && ./build_sharedfile.sh ) & +(cd ../../crypto_plugins/tor/scripts/linux && ./build_all.sh ) & wait echo "Done building" diff --git a/test/cached_electrumx_test.mocks.dart b/test/cached_electrumx_test.mocks.dart index cdda4902b..e44d745d9 100644 --- a/test/cached_electrumx_test.mocks.dart +++ b/test/cached_electrumx_test.mocks.dart @@ -582,6 +582,19 @@ class MockPrefs extends _i1.Mock implements _i5.Prefs { returnValueForMissingStub: null, ); @override + bool get torKillSwitch => (super.noSuchMethod( + Invocation.getter(#torKillSwitch), + returnValue: false, + ) as bool); + @override + set torKillSwitch(bool? torKillswitch) => super.noSuchMethod( + Invocation.setter( + #torKillSwitch, + torKillswitch, + ), + returnValueForMissingStub: null, + ); + @override bool get showTestNetCoins => (super.noSuchMethod( Invocation.getter(#showTestNetCoins), returnValue: false, @@ -754,6 +767,19 @@ class MockPrefs extends _i1.Mock implements _i5.Prefs { returnValueForMissingStub: null, ); @override + bool get useTor => (super.noSuchMethod( + Invocation.getter(#useTor), + returnValue: false, + ) as bool); + @override + set useTor(bool? useTor) => super.noSuchMethod( + Invocation.setter( + #useTor, + useTor, + ), + returnValueForMissingStub: null, + ); + @override bool get hasListeners => (super.noSuchMethod( Invocation.getter(#hasListeners), returnValue: false, diff --git a/test/electrumx_test.dart b/test/electrumx_test.dart index 93fc77ba5..0d8bb93d1 100644 --- a/test/electrumx_test.dart +++ b/test/electrumx_test.dart @@ -1,8 +1,11 @@ +import 'dart:io'; + import 'package:flutter_test/flutter_test.dart'; import 'package:mockito/annotations.dart'; import 'package:mockito/mockito.dart'; import 'package:stackwallet/electrumx_rpc/electrumx.dart'; import 'package:stackwallet/electrumx_rpc/rpc.dart'; +import 'package:stackwallet/services/tor_service.dart'; import 'package:stackwallet/utilities/prefs.dart'; import 'electrumx_test.mocks.dart'; @@ -10,7 +13,7 @@ import 'sample_data/get_anonymity_set_sample_data.dart'; import 'sample_data/get_used_serials_sample_data.dart'; import 'sample_data/transaction_data_samples.dart'; -@GenerateMocks([JsonRPC, Prefs]) +@GenerateMocks([JsonRPC, Prefs, TorService]) void main() { group("factory constructors and getters", () { test("electrumxnode .from factory", () { @@ -38,9 +41,15 @@ void main() { ); final mockPrefs = MockPrefs(); + when(mockPrefs.useTor).thenAnswer((realInvocation) => false); + final torService = MockTorService(); - final client = - ElectrumX.from(node: node, failovers: [], prefs: mockPrefs); + final client = ElectrumX.from( + node: node, + failovers: [], + prefs: mockPrefs, + torService: torService, + ); expect(client.useSSL, node.useSSL); expect(client.host, node.address); @@ -73,18 +82,23 @@ void main() { ); final mockPrefs = MockPrefs(); + when(mockPrefs.useTor).thenAnswer((realInvocation) => false); + final torService = MockTorService(); when(mockPrefs.wifiOnly).thenAnswer((_) => false); final client = ElectrumX( - host: "some server", - port: 0, - useSSL: true, - client: mockClient, - failovers: [], - prefs: mockPrefs); + host: "some server", + port: 0, + useSSL: true, + client: mockClient, + failovers: [], + prefs: mockPrefs, + torService: torService, + ); expect(() => client.getTransaction(requestID: "some requestId", txHash: ''), throwsA(isA())); + verify(mockPrefs.wifiOnly).called(1); verifyNoMoreInteractions(mockPrefs); }); @@ -109,6 +123,8 @@ void main() { ); final mockPrefs = MockPrefs(); + when(mockPrefs.useTor).thenAnswer((realInvocation) => false); + final torService = MockTorService(); when(mockPrefs.wifiOnly).thenAnswer((_) => false); final client = ElectrumX( host: "some server", @@ -116,13 +132,16 @@ void main() { useSSL: true, client: mockClient, prefs: mockPrefs, + torService: torService, failovers: []); final result = await (client.getBlockHeadTip(requestID: "some requestId")); expect(result["height"], 520481); + verify(mockPrefs.wifiOnly).called(1); + verify(mockPrefs.useTor).called(1); verifyNoMoreInteractions(mockPrefs); }); @@ -139,6 +158,8 @@ void main() { ).thenThrow(Exception()); final mockPrefs = MockPrefs(); + when(mockPrefs.useTor).thenAnswer((realInvocation) => false); + final torService = MockTorService(); when(mockPrefs.wifiOnly).thenAnswer((_) => false); final client = ElectrumX( host: "some server", @@ -146,10 +167,12 @@ void main() { useSSL: true, client: mockClient, prefs: mockPrefs, + torService: torService, failovers: []); expect(() => client.getBlockHeadTip(requestID: "some requestId"), throwsA(isA())); + verify(mockPrefs.wifiOnly).called(1); verifyNoMoreInteractions(mockPrefs); }); @@ -175,6 +198,8 @@ void main() { ); final mockPrefs = MockPrefs(); + when(mockPrefs.useTor).thenAnswer((realInvocation) => false); + final torService = MockTorService(); when(mockPrefs.wifiOnly).thenAnswer((_) => false); final client = ElectrumX( host: "some server", @@ -182,12 +207,15 @@ void main() { useSSL: true, client: mockClient, prefs: mockPrefs, + torService: torService, failovers: []); final result = await client.ping(requestID: "some requestId"); expect(result, true); + verify(mockPrefs.wifiOnly).called(1); + verify(mockPrefs.useTor).called(1); verifyNoMoreInteractions(mockPrefs); }); @@ -204,6 +232,8 @@ void main() { ).thenThrow(Exception()); final mockPrefs = MockPrefs(); + when(mockPrefs.useTor).thenAnswer((realInvocation) => false); + final torService = MockTorService(); when(mockPrefs.wifiOnly).thenAnswer((_) => false); final client = ElectrumX( host: "some server", @@ -211,10 +241,12 @@ void main() { useSSL: true, client: mockClient, prefs: mockPrefs, + torService: torService, failovers: []); expect(() => client.ping(requestID: "some requestId"), throwsA(isA())); + verify(mockPrefs.wifiOnly).called(1); verifyNoMoreInteractions(mockPrefs); }); @@ -251,6 +283,8 @@ void main() { ); final mockPrefs = MockPrefs(); + when(mockPrefs.useTor).thenAnswer((realInvocation) => false); + final torService = MockTorService(); when(mockPrefs.wifiOnly).thenAnswer((_) => false); final client = ElectrumX( host: "some server", @@ -258,6 +292,7 @@ void main() { useSSL: true, client: mockClient, prefs: mockPrefs, + torService: torService, failovers: []); final result = @@ -275,7 +310,9 @@ void main() { "server_version": "ElectrumX 1.0.17", "hash_function": "sha256", }); + verify(mockPrefs.wifiOnly).called(1); + verify(mockPrefs.useTor).called(1); verifyNoMoreInteractions(mockPrefs); }); @@ -292,6 +329,8 @@ void main() { ).thenThrow(Exception()); final mockPrefs = MockPrefs(); + when(mockPrefs.useTor).thenAnswer((realInvocation) => false); + final torService = MockTorService(); when(mockPrefs.wifiOnly).thenAnswer((_) => false); final client = ElectrumX( host: "some server", @@ -299,10 +338,12 @@ void main() { useSSL: true, client: mockClient, prefs: mockPrefs, + torService: torService, failovers: []); expect(() => client.getServerFeatures(requestID: "some requestId"), throwsA(isA())); + verify(mockPrefs.wifiOnly).called(1); verifyNoMoreInteractions(mockPrefs); }); @@ -328,6 +369,8 @@ void main() { ); final mockPrefs = MockPrefs(); + when(mockPrefs.useTor).thenAnswer((realInvocation) => false); + final torService = MockTorService(); when(mockPrefs.wifiOnly).thenAnswer((_) => false); final client = ElectrumX( host: "some server", @@ -335,13 +378,16 @@ void main() { useSSL: true, client: mockClient, prefs: mockPrefs, + torService: torService, failovers: []); final result = await client.broadcastTransaction( rawTx: "some raw transaction string", requestID: "some requestId"); expect(result, "the txid of the rawtx"); + verify(mockPrefs.wifiOnly).called(1); + verify(mockPrefs.useTor).called(1); verifyNoMoreInteractions(mockPrefs); }); @@ -358,6 +404,8 @@ void main() { ).thenThrow(Exception()); final mockPrefs = MockPrefs(); + when(mockPrefs.useTor).thenAnswer((realInvocation) => false); + final torService = MockTorService(); when(mockPrefs.wifiOnly).thenAnswer((_) => false); final client = ElectrumX( host: "some server", @@ -365,6 +413,7 @@ void main() { useSSL: true, client: mockClient, prefs: mockPrefs, + torService: torService, failovers: []); expect( @@ -372,6 +421,7 @@ void main() { rawTx: "some raw transaction string", requestID: "some requestId"), throwsA(isA())); + verify(mockPrefs.wifiOnly).called(1); verifyNoMoreInteractions(mockPrefs); }); @@ -400,6 +450,8 @@ void main() { ); final mockPrefs = MockPrefs(); + when(mockPrefs.useTor).thenAnswer((realInvocation) => false); + final torService = MockTorService(); when(mockPrefs.wifiOnly).thenAnswer((_) => false); final client = ElectrumX( host: "some server", @@ -407,13 +459,16 @@ void main() { useSSL: true, client: mockClient, prefs: mockPrefs, + torService: torService, failovers: []); final result = await client.getBalance( scripthash: "dummy hash", requestID: "some requestId"); expect(result, {"confirmed": 103873966, "unconfirmed": 23684400}); + verify(mockPrefs.wifiOnly).called(1); + verify(mockPrefs.useTor).called(1); verifyNoMoreInteractions(mockPrefs); }); @@ -430,6 +485,8 @@ void main() { ).thenThrow(Exception()); final mockPrefs = MockPrefs(); + when(mockPrefs.useTor).thenAnswer((realInvocation) => false); + final torService = MockTorService(); when(mockPrefs.wifiOnly).thenAnswer((_) => false); final client = ElectrumX( host: "some server", @@ -437,12 +494,14 @@ void main() { useSSL: true, client: mockClient, prefs: mockPrefs, + torService: torService, failovers: []); expect( () => client.getBalance( scripthash: "dummy hash", requestID: "some requestId"), throwsA(isA())); + verify(mockPrefs.wifiOnly).called(1); verifyNoMoreInteractions(mockPrefs); }); @@ -479,6 +538,8 @@ void main() { ); final mockPrefs = MockPrefs(); + when(mockPrefs.useTor).thenAnswer((realInvocation) => false); + final torService = MockTorService(); when(mockPrefs.wifiOnly).thenAnswer((_) => false); final client = ElectrumX( host: "some server", @@ -486,6 +547,7 @@ void main() { useSSL: true, client: mockClient, prefs: mockPrefs, + torService: torService, failovers: []); final result = await client.getHistory( @@ -503,7 +565,9 @@ void main() { "f3e1bf48975b8d6060a9de8884296abb80be618dc00ae3cb2f6cee3085e09403" } ]); + verify(mockPrefs.wifiOnly).called(1); + verify(mockPrefs.useTor).called(1); verifyNoMoreInteractions(mockPrefs); }); @@ -520,6 +584,8 @@ void main() { ).thenThrow(Exception()); final mockPrefs = MockPrefs(); + when(mockPrefs.useTor).thenAnswer((realInvocation) => false); + final torService = MockTorService(); when(mockPrefs.wifiOnly).thenAnswer((_) => false); final client = ElectrumX( host: "some server", @@ -527,12 +593,14 @@ void main() { useSSL: true, client: mockClient, prefs: mockPrefs, + torService: torService, failovers: []); expect( () => client.getHistory( scripthash: "dummy hash", requestID: "some requestId"), throwsA(isA())); + verify(mockPrefs.wifiOnly).called(1); verifyNoMoreInteractions(mockPrefs); }); @@ -573,6 +641,8 @@ void main() { ); final mockPrefs = MockPrefs(); + when(mockPrefs.useTor).thenAnswer((realInvocation) => false); + final torService = MockTorService(); when(mockPrefs.wifiOnly).thenAnswer((_) => false); final client = ElectrumX( host: "some server", @@ -580,6 +650,7 @@ void main() { useSSL: true, client: mockClient, prefs: mockPrefs, + torService: torService, failovers: []); final result = await client.getUTXOs( @@ -601,7 +672,9 @@ void main() { "height": 441696 } ]); + verify(mockPrefs.wifiOnly).called(1); + verify(mockPrefs.useTor).called(1); verifyNoMoreInteractions(mockPrefs); }); @@ -618,6 +691,8 @@ void main() { ).thenThrow(Exception()); final mockPrefs = MockPrefs(); + when(mockPrefs.useTor).thenAnswer((realInvocation) => false); + final torService = MockTorService(); when(mockPrefs.wifiOnly).thenAnswer((_) => false); final client = ElectrumX( host: "some server", @@ -625,12 +700,14 @@ void main() { useSSL: true, client: mockClient, prefs: mockPrefs, + torService: torService, failovers: []); expect( () => client.getUTXOs( scripthash: "dummy hash", requestID: "some requestId"), throwsA(isA())); + verify(mockPrefs.wifiOnly).called(1); verifyNoMoreInteractions(mockPrefs); }); @@ -656,6 +733,8 @@ void main() { ); final mockPrefs = MockPrefs(); + when(mockPrefs.useTor).thenAnswer((realInvocation) => false); + final torService = MockTorService(); when(mockPrefs.wifiOnly).thenAnswer((_) => false); final client = ElectrumX( host: "some server", @@ -663,6 +742,7 @@ void main() { useSSL: true, client: mockClient, prefs: mockPrefs, + torService: torService, failovers: []); final result = await client.getTransaction( @@ -671,7 +751,9 @@ void main() { requestID: "some requestId"); expect(result, SampleGetTransactionData.txData0); + verify(mockPrefs.wifiOnly).called(1); + verify(mockPrefs.useTor).called(1); verifyNoMoreInteractions(mockPrefs); }); @@ -688,6 +770,8 @@ void main() { ).thenThrow(Exception()); final mockPrefs = MockPrefs(); + when(mockPrefs.useTor).thenAnswer((realInvocation) => false); + final torService = MockTorService(); when(mockPrefs.wifiOnly).thenAnswer((_) => false); final client = ElectrumX( host: "some server", @@ -695,6 +779,7 @@ void main() { useSSL: true, client: mockClient, prefs: mockPrefs, + torService: torService, failovers: []); expect( @@ -702,6 +787,7 @@ void main() { txHash: SampleGetTransactionData.txHash0, requestID: "some requestId"), throwsA(isA())); + verify(mockPrefs.wifiOnly).called(1); verifyNoMoreInteractions(mockPrefs); }); @@ -727,6 +813,8 @@ void main() { ); final mockPrefs = MockPrefs(); + when(mockPrefs.useTor).thenAnswer((realInvocation) => false); + final torService = MockTorService(); when(mockPrefs.wifiOnly).thenAnswer((_) => false); final client = ElectrumX( host: "some server", @@ -734,13 +822,16 @@ void main() { useSSL: true, client: mockClient, prefs: mockPrefs, + torService: torService, failovers: []); final result = await client.getAnonymitySet( groupId: "1", blockhash: "", requestID: "some requestId"); expect(result, GetAnonymitySetSampleData.data); + verify(mockPrefs.wifiOnly).called(1); + verify(mockPrefs.useTor).called(1); verifyNoMoreInteractions(mockPrefs); }); @@ -757,6 +848,8 @@ void main() { ).thenThrow(Exception()); final mockPrefs = MockPrefs(); + when(mockPrefs.useTor).thenAnswer((realInvocation) => false); + final torService = MockTorService(); when(mockPrefs.wifiOnly).thenAnswer((_) => false); final client = ElectrumX( host: "some server", @@ -764,12 +857,14 @@ void main() { useSSL: true, client: mockClient, prefs: mockPrefs, + torService: torService, failovers: []); expect( () => client.getAnonymitySet(groupId: "1", requestID: "some requestId"), throwsA(isA())); + verify(mockPrefs.wifiOnly).called(1); verifyNoMoreInteractions(mockPrefs); }); @@ -795,6 +890,8 @@ void main() { ); final mockPrefs = MockPrefs(); + when(mockPrefs.useTor).thenAnswer((realInvocation) => false); + final torService = MockTorService(); when(mockPrefs.wifiOnly).thenAnswer((_) => false); final client = ElectrumX( host: "some server", @@ -802,13 +899,16 @@ void main() { useSSL: true, client: mockClient, prefs: mockPrefs, + torService: torService, failovers: []); final result = await client.getMintData( mints: "some mints", requestID: "some requestId"); expect(result, "mint meta data"); + verify(mockPrefs.wifiOnly).called(1); + verify(mockPrefs.useTor).called(1); verifyNoMoreInteractions(mockPrefs); }); @@ -825,6 +925,8 @@ void main() { ).thenThrow(Exception()); final mockPrefs = MockPrefs(); + when(mockPrefs.useTor).thenAnswer((realInvocation) => false); + final torService = MockTorService(); when(mockPrefs.wifiOnly).thenAnswer((_) => false); final client = ElectrumX( host: "some server", @@ -832,12 +934,14 @@ void main() { useSSL: true, client: mockClient, prefs: mockPrefs, + torService: torService, failovers: []); expect( () => client.getMintData( mints: "some mints", requestID: "some requestId"), throwsA(isA())); + verify(mockPrefs.wifiOnly).called(1); verifyNoMoreInteractions(mockPrefs); }); @@ -863,6 +967,8 @@ void main() { ); final mockPrefs = MockPrefs(); + when(mockPrefs.useTor).thenAnswer((realInvocation) => false); + final torService = MockTorService(); when(mockPrefs.wifiOnly).thenAnswer((_) => false); final client = ElectrumX( host: "some server", @@ -870,13 +976,16 @@ void main() { useSSL: true, client: mockClient, prefs: mockPrefs, + torService: torService, failovers: []); final result = await client.getUsedCoinSerials( requestID: "some requestId", startNumber: 0); expect(result, GetUsedSerialsSampleData.serials); + verify(mockPrefs.wifiOnly).called(1); + verify(mockPrefs.useTor).called(1); verifyNoMoreInteractions(mockPrefs); }); @@ -893,6 +1002,8 @@ void main() { ).thenThrow(Exception()); final mockPrefs = MockPrefs(); + when(mockPrefs.useTor).thenAnswer((realInvocation) => false); + final torService = MockTorService(); when(mockPrefs.wifiOnly).thenAnswer((_) => false); final client = ElectrumX( host: "some server", @@ -900,12 +1011,14 @@ void main() { useSSL: true, client: mockClient, prefs: mockPrefs, + torService: torService, failovers: []); expect( () => client.getUsedCoinSerials( requestID: "some requestId", startNumber: 0), throwsA(isA())); + verify(mockPrefs.wifiOnly).called(1); verifyNoMoreInteractions(mockPrefs); }); @@ -931,6 +1044,8 @@ void main() { ); final mockPrefs = MockPrefs(); + when(mockPrefs.useTor).thenAnswer((realInvocation) => false); + final torService = MockTorService(); when(mockPrefs.wifiOnly).thenAnswer((_) => false); final client = ElectrumX( host: "some server", @@ -938,12 +1053,15 @@ void main() { useSSL: true, client: mockClient, prefs: mockPrefs, + torService: torService, failovers: []); final result = await client.getLatestCoinId(requestID: "some requestId"); expect(result, 1); + verify(mockPrefs.wifiOnly).called(1); + verify(mockPrefs.useTor).called(1); verifyNoMoreInteractions(mockPrefs); }); @@ -960,6 +1078,8 @@ void main() { ).thenThrow(Exception()); final mockPrefs = MockPrefs(); + when(mockPrefs.useTor).thenAnswer((realInvocation) => false); + final torService = MockTorService(); when(mockPrefs.wifiOnly).thenAnswer((_) => false); final client = ElectrumX( host: "some server", @@ -967,6 +1087,7 @@ void main() { useSSL: true, client: mockClient, prefs: mockPrefs, + torService: torService, failovers: []); expect( @@ -974,6 +1095,7 @@ void main() { requestID: "some requestId", ), throwsA(isA())); + verify(mockPrefs.wifiOnly).called(1); verifyNoMoreInteractions(mockPrefs); }); @@ -999,6 +1121,8 @@ void main() { ); final mockPrefs = MockPrefs(); + when(mockPrefs.useTor).thenAnswer((realInvocation) => false); + final torService = MockTorService(); when(mockPrefs.wifiOnly).thenAnswer((_) => false); final client = ElectrumX( host: "some server", @@ -1006,13 +1130,16 @@ void main() { useSSL: true, client: mockClient, prefs: mockPrefs, + torService: torService, failovers: []); final result = await client.getAnonymitySet( groupId: "1", blockhash: "", requestID: "some requestId"); expect(result, GetAnonymitySetSampleData.data); + verify(mockPrefs.wifiOnly).called(1); + verify(mockPrefs.useTor).called(1); verifyNoMoreInteractions(mockPrefs); }); @@ -1029,6 +1156,8 @@ void main() { ).thenThrow(Exception()); final mockPrefs = MockPrefs(); + when(mockPrefs.useTor).thenAnswer((realInvocation) => false); + final torService = MockTorService(); when(mockPrefs.wifiOnly).thenAnswer((_) => false); final client = ElectrumX( host: "some server", @@ -1036,6 +1165,7 @@ void main() { useSSL: true, client: mockClient, prefs: mockPrefs, + torService: torService, failovers: []); expect( @@ -1044,6 +1174,7 @@ void main() { requestID: "some requestId", ), throwsA(isA())); + verify(mockPrefs.wifiOnly).called(1); verifyNoMoreInteractions(mockPrefs); }); @@ -1069,6 +1200,8 @@ void main() { ); final mockPrefs = MockPrefs(); + when(mockPrefs.useTor).thenAnswer((realInvocation) => false); + final torService = MockTorService(); when(mockPrefs.wifiOnly).thenAnswer((_) => false); final client = ElectrumX( host: "some server", @@ -1076,13 +1209,16 @@ void main() { useSSL: true, client: mockClient, prefs: mockPrefs, + torService: torService, failovers: []); final result = await client.getMintData( mints: "some mints", requestID: "some requestId"); expect(result, "mint meta data"); + verify(mockPrefs.wifiOnly).called(1); + verify(mockPrefs.useTor).called(1); verifyNoMoreInteractions(mockPrefs); }); @@ -1099,6 +1235,8 @@ void main() { ).thenThrow(Exception()); final mockPrefs = MockPrefs(); + when(mockPrefs.useTor).thenAnswer((realInvocation) => false); + final torService = MockTorService(); when(mockPrefs.wifiOnly).thenAnswer((_) => false); final client = ElectrumX( host: "some server", @@ -1106,6 +1244,7 @@ void main() { useSSL: true, client: mockClient, prefs: mockPrefs, + torService: torService, failovers: []); expect( @@ -1114,6 +1253,7 @@ void main() { requestID: "some requestId", ), throwsA(isA())); + verify(mockPrefs.wifiOnly).called(1); verifyNoMoreInteractions(mockPrefs); }); @@ -1139,6 +1279,8 @@ void main() { ); final mockPrefs = MockPrefs(); + when(mockPrefs.useTor).thenAnswer((realInvocation) => false); + final torService = MockTorService(); when(mockPrefs.wifiOnly).thenAnswer((_) => false); final client = ElectrumX( host: "some server", @@ -1146,13 +1288,16 @@ void main() { useSSL: true, client: mockClient, prefs: mockPrefs, + torService: torService, failovers: []); final result = await client.getUsedCoinSerials( requestID: "some requestId", startNumber: 0); expect(result, GetUsedSerialsSampleData.serials); + verify(mockPrefs.wifiOnly).called(1); + verify(mockPrefs.useTor).called(1); verifyNoMoreInteractions(mockPrefs); }); @@ -1169,6 +1314,8 @@ void main() { ).thenThrow(Exception()); final mockPrefs = MockPrefs(); + when(mockPrefs.useTor).thenAnswer((realInvocation) => false); + final torService = MockTorService(); when(mockPrefs.wifiOnly).thenAnswer((_) => false); final client = ElectrumX( host: "some server", @@ -1176,12 +1323,14 @@ void main() { useSSL: true, client: mockClient, prefs: mockPrefs, + torService: torService, failovers: []); expect( () => client.getUsedCoinSerials( requestID: "some requestId", startNumber: 0), throwsA(isA())); + verify(mockPrefs.wifiOnly).called(1); verifyNoMoreInteractions(mockPrefs); }); @@ -1207,6 +1356,8 @@ void main() { ); final mockPrefs = MockPrefs(); + when(mockPrefs.useTor).thenAnswer((realInvocation) => false); + final torService = MockTorService(); when(mockPrefs.wifiOnly).thenAnswer((_) => false); final client = ElectrumX( host: "some server", @@ -1214,12 +1365,15 @@ void main() { useSSL: true, client: mockClient, prefs: mockPrefs, + torService: torService, failovers: []); final result = await client.getLatestCoinId(requestID: "some requestId"); expect(result, 1); + verify(mockPrefs.wifiOnly).called(1); + verify(mockPrefs.useTor).called(1); verifyNoMoreInteractions(mockPrefs); }); @@ -1236,6 +1390,8 @@ void main() { ).thenThrow(Exception()); final mockPrefs = MockPrefs(); + when(mockPrefs.useTor).thenAnswer((realInvocation) => false); + final torService = MockTorService(); when(mockPrefs.wifiOnly).thenAnswer((_) => false); final client = ElectrumX( host: "some server", @@ -1243,10 +1399,12 @@ void main() { useSSL: true, client: mockClient, prefs: mockPrefs, + torService: torService, failovers: []); expect(() => client.getLatestCoinId(requestID: "some requestId"), throwsA(isA())); + verify(mockPrefs.wifiOnly).called(1); verifyNoMoreInteractions(mockPrefs); }); @@ -1274,6 +1432,8 @@ void main() { ); final mockPrefs = MockPrefs(); + when(mockPrefs.useTor).thenAnswer((realInvocation) => false); + final torService = MockTorService(); when(mockPrefs.wifiOnly).thenAnswer((_) => false); final client = ElectrumX( host: "some server", @@ -1281,12 +1441,15 @@ void main() { useSSL: true, client: mockClient, prefs: mockPrefs, + torService: torService, failovers: []); final result = await client.getFeeRate(requestID: "some requestId"); expect(result, {"rate": 1000}); + verify(mockPrefs.wifiOnly).called(1); + verify(mockPrefs.useTor).called(1); verifyNoMoreInteractions(mockPrefs); }); @@ -1303,6 +1466,8 @@ void main() { ).thenThrow(Exception()); final mockPrefs = MockPrefs(); + when(mockPrefs.useTor).thenAnswer((realInvocation) => false); + final torService = MockTorService(); when(mockPrefs.wifiOnly).thenAnswer((_) => false); final client = ElectrumX( host: "some server", @@ -1310,10 +1475,12 @@ void main() { useSSL: true, client: mockClient, prefs: mockPrefs, + torService: torService, failovers: []); expect(() => client.getFeeRate(requestID: "some requestId"), throwsA(isA())); + verify(mockPrefs.wifiOnly).called(1); verifyNoMoreInteractions(mockPrefs); }); @@ -1321,6 +1488,8 @@ void main() { test("rpcClient is null throws with bad server info", () { final mockPrefs = MockPrefs(); + when(mockPrefs.useTor).thenAnswer((realInvocation) => false); + final torService = MockTorService(); when(mockPrefs.wifiOnly).thenAnswer((_) => false); final client = ElectrumX( client: null, @@ -1328,11 +1497,274 @@ void main() { host: "_ :sa %", useSSL: false, prefs: mockPrefs, + torService: torService, failovers: [], ); expect(() => client.getFeeRate(), throwsA(isA())); + verify(mockPrefs.wifiOnly).called(1); verifyNoMoreInteractions(mockPrefs); }); + + group("Tor tests", () { + // useTor is false, so no TorService calls should be made. + test("Tor not in use", () async { + final mockClient = MockJsonRPC(); + const command = "blockchain.transaction.get"; + const jsonArgs = '["${SampleGetTransactionData.txHash0}",true]'; + when(mockClient.request( + '{"jsonrpc": "2.0", "id": "some requestId","method": "$command","params": $jsonArgs}', + const Duration(seconds: 60), + )).thenAnswer((_) async => JsonRPCResponse(data: { + "jsonrpc": "2.0", + "result": SampleGetTransactionData.txData0, + "id": "some requestId", + })); + + final mockPrefs = MockPrefs(); + when(mockPrefs.useTor).thenAnswer((_) => false); + when(mockPrefs.torKillSwitch) + .thenAnswer((_) => false); // Or true, shouldn't matter. + when(mockPrefs.wifiOnly).thenAnswer((_) => false); + final mockTorService = MockTorService(); + when(mockTorService.enabled).thenAnswer((_) => false); + + final client = ElectrumX( + host: "some server", + port: 0, + useSSL: true, + client: mockClient, + failovers: [], + prefs: mockPrefs, + torService: mockTorService, + ); + + final result = await client.getTransaction( + txHash: SampleGetTransactionData.txHash0, + verbose: true, + requestID: "some requestId"); + + expect(result, SampleGetTransactionData.txData0); + + verify(mockPrefs.wifiOnly).called(1); + verify(mockPrefs.useTor).called(1); + verifyNever(mockPrefs.torKillSwitch); + verifyNoMoreInteractions(mockPrefs); + verifyNever(mockTorService.enabled); + verifyNoMoreInteractions(mockTorService); + }); + + // useTor is true, but TorService is not enabled and the killswitch is off, so a clearnet call should be made. + test("Tor in use but Tor unavailable and killswitch off", () async { + final mockClient = MockJsonRPC(); + const command = "blockchain.transaction.get"; + const jsonArgs = '["${SampleGetTransactionData.txHash0}",true]'; + when(mockClient.request( + '{"jsonrpc": "2.0", "id": "some requestId","method": "$command","params": $jsonArgs}', + const Duration(seconds: 60), + )).thenAnswer((_) async => JsonRPCResponse(data: { + "jsonrpc": "2.0", + "result": SampleGetTransactionData.txData0, + "id": "some requestId", + })); + + final mockPrefs = MockPrefs(); + when(mockPrefs.useTor).thenAnswer((_) => true); + when(mockPrefs.torKillSwitch).thenAnswer((_) => false); + when(mockPrefs.wifiOnly).thenAnswer((_) => false); + + final mockTorService = MockTorService(); + when(mockTorService.enabled).thenAnswer((_) => false); + when(mockTorService.proxyInfo).thenAnswer((_) => ( + host: InternetAddress('1.2.3.4'), + port: -1 + )); // Port is set to -1 until Tor is enabled. + + final client = ElectrumX( + host: "some server", + port: 0, + useSSL: true, + client: mockClient, + prefs: mockPrefs, + torService: mockTorService, + failovers: []); + + final result = await client.getTransaction( + txHash: SampleGetTransactionData.txHash0, + verbose: true, + requestID: "some requestId"); + + expect(result, SampleGetTransactionData.txData0); + + verify(mockPrefs.wifiOnly).called(1); + verify(mockPrefs.useTor).called(1); + verify(mockPrefs.torKillSwitch).called(1); + verifyNoMoreInteractions(mockPrefs); + verify(mockTorService.enabled).called(1); + verifyNever(mockTorService.proxyInfo); + verifyNoMoreInteractions(mockTorService); + }); + + // useTor is true and TorService is enabled, so a TorService call should be made. + test("Tor in use and available", () async { + final mockClient = MockJsonRPC(); + const command = "blockchain.transaction.get"; + const jsonArgs = '["${SampleGetTransactionData.txHash0}",true]'; + when(mockClient.request( + '{"jsonrpc": "2.0", "id": "some requestId","method": "$command","params": $jsonArgs}', + const Duration(seconds: 60), + )).thenAnswer((_) async => JsonRPCResponse(data: { + "jsonrpc": "2.0", + "result": SampleGetTransactionData.txData0, + "id": "some requestId", + })); + when(mockClient.proxyInfo) + .thenAnswer((_) => (host: InternetAddress('1.2.3.4'), port: 42)); + + final mockPrefs = MockPrefs(); + when(mockPrefs.useTor).thenAnswer((_) => true); + when(mockPrefs.torKillSwitch).thenAnswer((_) => false); // Or true. + when(mockPrefs.wifiOnly).thenAnswer((_) => false); + + final mockTorService = MockTorService(); + when(mockTorService.enabled).thenAnswer((_) => true); + when(mockTorService.proxyInfo) + .thenAnswer((_) => (host: InternetAddress('1.2.3.4'), port: 42)); + + final client = ElectrumX( + host: "some server", + port: 0, + useSSL: true, + client: mockClient, + prefs: mockPrefs, + torService: mockTorService, + failovers: []); + + final result = await client.getTransaction( + txHash: SampleGetTransactionData.txHash0, + verbose: true, + requestID: "some requestId"); + + expect(result, SampleGetTransactionData.txData0); + + verify(mockClient.proxyInfo).called(1); + verify(mockPrefs.wifiOnly).called(1); + verify(mockPrefs.useTor).called(1); + verifyNever(mockPrefs.torKillSwitch); + verifyNoMoreInteractions(mockPrefs); + verify(mockTorService.enabled).called(1); + verify(mockTorService.proxyInfo).called(1); + verifyNoMoreInteractions(mockTorService); + }); + + // useTor is true, but TorService is not enabled and the killswitch is on, so no TorService calls should be made. + test("killswitch enabled", () async { + final mockClient = MockJsonRPC(); + const command = "blockchain.transaction.get"; + const jsonArgs = '["",true]'; + when( + mockClient.request( + '{"jsonrpc": "2.0", "id": "some requestId",' + '"method": "$command","params": $jsonArgs}', + const Duration(seconds: 60), + ), + ).thenAnswer( + (_) async => JsonRPCResponse(data: { + "jsonrpc": "2.0", + "error": { + "code": 1, + "message": "None should be a transaction hash", + }, + "id": "some requestId", + }), + ); + + final mockPrefs = MockPrefs(); + when(mockPrefs.useTor).thenAnswer((_) => true); + when(mockPrefs.torKillSwitch).thenAnswer((_) => true); + when(mockPrefs.wifiOnly).thenAnswer((_) => false); + final mockTorService = MockTorService(); + when(mockTorService.enabled).thenAnswer((_) => false); + + final client = ElectrumX( + host: "some server", + port: 0, + useSSL: true, + client: mockClient, + failovers: [], + prefs: mockPrefs, + torService: mockTorService, + ); + + try { + var result = await client.getTransaction( + requestID: "some requestId", txHash: ''); + } catch (e) { + expect(e, isA()); + expect( + e.toString(), + equals( + "Exception: Tor preference and killswitch set but Tor is not enabled, not connecting to ElectrumX")); + } + + verify(mockPrefs.wifiOnly).called(1); + verify(mockPrefs.useTor).called(1); + verify(mockPrefs.torKillSwitch).called(1); + verifyNoMoreInteractions(mockPrefs); + verify(mockTorService.enabled).called(1); + verifyNoMoreInteractions(mockTorService); + }); + + // useTor is true but Tor is not enabled, but because the killswitch is off, a clearnet call should be made. + test("killswitch disabled", () async { + final mockClient = MockJsonRPC(); + const command = "blockchain.transaction.get"; + const jsonArgs = '["${SampleGetTransactionData.txHash0}",true]'; + when( + mockClient.request( + '{"jsonrpc": "2.0", "id": "some requestId",' + '"method": "$command","params": $jsonArgs}', + const Duration(seconds: 60), + ), + ).thenAnswer( + (_) async => JsonRPCResponse(data: { + "jsonrpc": "2.0", + "result": SampleGetTransactionData.txData0, + "id": "some requestId" + }), + ); + + final mockPrefs = MockPrefs(); + when(mockPrefs.useTor).thenAnswer((_) => true); + when(mockPrefs.torKillSwitch).thenAnswer((_) => false); + when(mockPrefs.wifiOnly).thenAnswer((_) => false); + final mockTorService = MockTorService(); + when(mockTorService.enabled).thenAnswer((_) => false); + + final client = ElectrumX( + host: "some server", + port: 0, + useSSL: true, + client: mockClient, + failovers: [], + prefs: mockPrefs, + torService: mockTorService, + ); + + final result = await client.getTransaction( + txHash: SampleGetTransactionData.txHash0, + verbose: true, + requestID: "some requestId"); + + expect(result, SampleGetTransactionData.txData0); + + verify(mockPrefs.wifiOnly).called(1); + verify(mockPrefs.useTor).called(1); + verify(mockPrefs.torKillSwitch).called(1); + verifyNoMoreInteractions(mockPrefs); + verify(mockTorService.enabled).called(1); + verifyNoMoreInteractions(mockTorService); + }); + }); } diff --git a/test/electrumx_test.mocks.dart b/test/electrumx_test.mocks.dart index 578b1fe56..d77c3e76d 100644 --- a/test/electrumx_test.mocks.dart +++ b/test/electrumx_test.mocks.dart @@ -3,16 +3,19 @@ // Do not manually edit this file. // ignore_for_file: no_leading_underscores_for_library_prefixes -import 'dart:async' as _i3; -import 'dart:ui' as _i9; +import 'dart:async' as _i4; +import 'dart:io' as _i3; +import 'dart:ui' as _i10; import 'package:mockito/mockito.dart' as _i1; import 'package:stackwallet/electrumx_rpc/rpc.dart' as _i2; -import 'package:stackwallet/utilities/amount/amount_unit.dart' as _i7; -import 'package:stackwallet/utilities/enums/backup_frequency_type.dart' as _i6; -import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i8; -import 'package:stackwallet/utilities/enums/sync_type_enum.dart' as _i5; -import 'package:stackwallet/utilities/prefs.dart' as _i4; +import 'package:stackwallet/services/tor_service.dart' as _i11; +import 'package:stackwallet/utilities/amount/amount_unit.dart' as _i8; +import 'package:stackwallet/utilities/enums/backup_frequency_type.dart' as _i7; +import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i9; +import 'package:stackwallet/utilities/enums/sync_type_enum.dart' as _i6; +import 'package:stackwallet/utilities/prefs.dart' as _i5; +import 'package:tor_ffi_plugin/tor_ffi_plugin.dart' as _i12; // ignore_for_file: type=lint // ignore_for_file: avoid_redundant_argument_values @@ -46,6 +49,17 @@ class _FakeJsonRPCResponse_1 extends _i1.SmartFake ); } +class _FakeInternetAddress_2 extends _i1.SmartFake + implements _i3.InternetAddress { + _FakeInternetAddress_2( + Object parent, + Invocation parentInvocation, + ) : super( + parent, + parentInvocation, + ); +} + /// A class which mocks [JsonRPC]. /// /// See the documentation for Mockito's code generation for more information. @@ -78,7 +92,16 @@ class MockJsonRPC extends _i1.Mock implements _i2.JsonRPC { ), ) as Duration); @override - _i3.Future<_i2.JsonRPCResponse> request( + set proxyInfo(({_i3.InternetAddress host, int port})? _proxyInfo) => + super.noSuchMethod( + Invocation.setter( + #proxyInfo, + _proxyInfo, + ), + returnValueForMissingStub: null, + ); + @override + _i4.Future<_i2.JsonRPCResponse> request( String? jsonRpcRequest, Duration? requestTimeout, ) => @@ -91,7 +114,7 @@ class MockJsonRPC extends _i1.Mock implements _i2.JsonRPC { ], ), returnValue: - _i3.Future<_i2.JsonRPCResponse>.value(_FakeJsonRPCResponse_1( + _i4.Future<_i2.JsonRPCResponse>.value(_FakeJsonRPCResponse_1( this, Invocation.method( #request, @@ -101,32 +124,32 @@ class MockJsonRPC extends _i1.Mock implements _i2.JsonRPC { ], ), )), - ) as _i3.Future<_i2.JsonRPCResponse>); + ) as _i4.Future<_i2.JsonRPCResponse>); @override - _i3.Future disconnect({required String? reason}) => (super.noSuchMethod( + _i4.Future disconnect({required String? reason}) => (super.noSuchMethod( Invocation.method( #disconnect, [], {#reason: reason}, ), - returnValue: _i3.Future.value(), - returnValueForMissingStub: _i3.Future.value(), - ) as _i3.Future); + returnValue: _i4.Future.value(), + returnValueForMissingStub: _i4.Future.value(), + ) as _i4.Future); @override - _i3.Future connect() => (super.noSuchMethod( + _i4.Future connect() => (super.noSuchMethod( Invocation.method( #connect, [], ), - returnValue: _i3.Future.value(), - returnValueForMissingStub: _i3.Future.value(), - ) as _i3.Future); + returnValue: _i4.Future.value(), + returnValueForMissingStub: _i4.Future.value(), + ) as _i4.Future); } /// A class which mocks [Prefs]. /// /// See the documentation for Mockito's code generation for more information. -class MockPrefs extends _i1.Mock implements _i4.Prefs { +class MockPrefs extends _i1.Mock implements _i5.Prefs { MockPrefs() { _i1.throwOnMissingStub(this); } @@ -182,12 +205,12 @@ class MockPrefs extends _i1.Mock implements _i4.Prefs { returnValueForMissingStub: null, ); @override - _i5.SyncingType get syncType => (super.noSuchMethod( + _i6.SyncingType get syncType => (super.noSuchMethod( Invocation.getter(#syncType), - returnValue: _i5.SyncingType.currentWalletOnly, - ) as _i5.SyncingType); + returnValue: _i6.SyncingType.currentWalletOnly, + ) as _i6.SyncingType); @override - set syncType(_i5.SyncingType? syncType) => super.noSuchMethod( + set syncType(_i6.SyncingType? syncType) => super.noSuchMethod( Invocation.setter( #syncType, syncType, @@ -299,6 +322,19 @@ class MockPrefs extends _i1.Mock implements _i4.Prefs { returnValueForMissingStub: null, ); @override + bool get torKillSwitch => (super.noSuchMethod( + Invocation.getter(#torKillSwitch), + returnValue: false, + ) as bool); + @override + set torKillSwitch(bool? torKillswitch) => super.noSuchMethod( + Invocation.setter( + #torKillSwitch, + torKillswitch, + ), + returnValueForMissingStub: null, + ); + @override bool get showTestNetCoins => (super.noSuchMethod( Invocation.getter(#showTestNetCoins), returnValue: false, @@ -333,12 +369,12 @@ class MockPrefs extends _i1.Mock implements _i4.Prefs { returnValueForMissingStub: null, ); @override - _i6.BackupFrequencyType get backupFrequencyType => (super.noSuchMethod( + _i7.BackupFrequencyType get backupFrequencyType => (super.noSuchMethod( Invocation.getter(#backupFrequencyType), - returnValue: _i6.BackupFrequencyType.everyTenMinutes, - ) as _i6.BackupFrequencyType); + returnValue: _i7.BackupFrequencyType.everyTenMinutes, + ) as _i7.BackupFrequencyType); @override - set backupFrequencyType(_i6.BackupFrequencyType? backupFrequencyType) => + set backupFrequencyType(_i7.BackupFrequencyType? backupFrequencyType) => super.noSuchMethod( Invocation.setter( #backupFrequencyType, @@ -471,66 +507,79 @@ class MockPrefs extends _i1.Mock implements _i4.Prefs { returnValueForMissingStub: null, ); @override + bool get useTor => (super.noSuchMethod( + Invocation.getter(#useTor), + returnValue: false, + ) as bool); + @override + set useTor(bool? useTor) => super.noSuchMethod( + Invocation.setter( + #useTor, + useTor, + ), + returnValueForMissingStub: null, + ); + @override bool get hasListeners => (super.noSuchMethod( Invocation.getter(#hasListeners), returnValue: false, ) as bool); @override - _i3.Future init() => (super.noSuchMethod( + _i4.Future init() => (super.noSuchMethod( Invocation.method( #init, [], ), - returnValue: _i3.Future.value(), - returnValueForMissingStub: _i3.Future.value(), - ) as _i3.Future); + returnValue: _i4.Future.value(), + returnValueForMissingStub: _i4.Future.value(), + ) as _i4.Future); @override - _i3.Future incrementCurrentNotificationIndex() => (super.noSuchMethod( + _i4.Future incrementCurrentNotificationIndex() => (super.noSuchMethod( Invocation.method( #incrementCurrentNotificationIndex, [], ), - returnValue: _i3.Future.value(), - returnValueForMissingStub: _i3.Future.value(), - ) as _i3.Future); + returnValue: _i4.Future.value(), + returnValueForMissingStub: _i4.Future.value(), + ) as _i4.Future); @override - _i3.Future isExternalCallsSet() => (super.noSuchMethod( + _i4.Future isExternalCallsSet() => (super.noSuchMethod( Invocation.method( #isExternalCallsSet, [], ), - returnValue: _i3.Future.value(false), - ) as _i3.Future); + returnValue: _i4.Future.value(false), + ) as _i4.Future); @override - _i3.Future saveUserID(String? userId) => (super.noSuchMethod( + _i4.Future saveUserID(String? userId) => (super.noSuchMethod( Invocation.method( #saveUserID, [userId], ), - returnValue: _i3.Future.value(), - returnValueForMissingStub: _i3.Future.value(), - ) as _i3.Future); + returnValue: _i4.Future.value(), + returnValueForMissingStub: _i4.Future.value(), + ) as _i4.Future); @override - _i3.Future saveSignupEpoch(int? signupEpoch) => (super.noSuchMethod( + _i4.Future saveSignupEpoch(int? signupEpoch) => (super.noSuchMethod( Invocation.method( #saveSignupEpoch, [signupEpoch], ), - returnValue: _i3.Future.value(), - returnValueForMissingStub: _i3.Future.value(), - ) as _i3.Future); + returnValue: _i4.Future.value(), + returnValueForMissingStub: _i4.Future.value(), + ) as _i4.Future); @override - _i7.AmountUnit amountUnit(_i8.Coin? coin) => (super.noSuchMethod( + _i8.AmountUnit amountUnit(_i9.Coin? coin) => (super.noSuchMethod( Invocation.method( #amountUnit, [coin], ), - returnValue: _i7.AmountUnit.normal, - ) as _i7.AmountUnit); + returnValue: _i8.AmountUnit.normal, + ) as _i8.AmountUnit); @override void updateAmountUnit({ - required _i8.Coin? coin, - required _i7.AmountUnit? amountUnit, + required _i9.Coin? coin, + required _i8.AmountUnit? amountUnit, }) => super.noSuchMethod( Invocation.method( @@ -544,7 +593,7 @@ class MockPrefs extends _i1.Mock implements _i4.Prefs { returnValueForMissingStub: null, ); @override - int maxDecimals(_i8.Coin? coin) => (super.noSuchMethod( + int maxDecimals(_i9.Coin? coin) => (super.noSuchMethod( Invocation.method( #maxDecimals, [coin], @@ -553,7 +602,7 @@ class MockPrefs extends _i1.Mock implements _i4.Prefs { ) as int); @override void updateMaxDecimals({ - required _i8.Coin? coin, + required _i9.Coin? coin, required int? maxDecimals, }) => super.noSuchMethod( @@ -568,7 +617,7 @@ class MockPrefs extends _i1.Mock implements _i4.Prefs { returnValueForMissingStub: null, ); @override - void addListener(_i9.VoidCallback? listener) => super.noSuchMethod( + void addListener(_i10.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #addListener, [listener], @@ -576,7 +625,7 @@ class MockPrefs extends _i1.Mock implements _i4.Prefs { returnValueForMissingStub: null, ); @override - void removeListener(_i9.VoidCallback? listener) => super.noSuchMethod( + void removeListener(_i10.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #removeListener, [listener], @@ -600,3 +649,56 @@ class MockPrefs extends _i1.Mock implements _i4.Prefs { returnValueForMissingStub: null, ); } + +/// A class which mocks [TorService]. +/// +/// See the documentation for Mockito's code generation for more information. +class MockTorService extends _i1.Mock implements _i11.TorService { + MockTorService() { + _i1.throwOnMissingStub(this); + } + + @override + bool get enabled => (super.noSuchMethod( + Invocation.getter(#enabled), + returnValue: false, + ) as bool); + @override + ({_i3.InternetAddress host, int port}) get proxyInfo => (super.noSuchMethod( + Invocation.getter(#proxyInfo), + returnValue: ( + host: _FakeInternetAddress_2( + this, + Invocation.getter(#proxyInfo), + ), + port: 0 + ), + ) as ({_i3.InternetAddress host, int port})); + @override + void init({_i12.Tor? mockableOverride}) => super.noSuchMethod( + Invocation.method( + #init, + [], + {#mockableOverride: mockableOverride}, + ), + returnValueForMissingStub: null, + ); + @override + _i4.Future start() => (super.noSuchMethod( + Invocation.method( + #start, + [], + ), + returnValue: _i4.Future.value(), + returnValueForMissingStub: _i4.Future.value(), + ) as _i4.Future); + @override + _i4.Future stop() => (super.noSuchMethod( + Invocation.method( + #stop, + [], + ), + returnValue: _i4.Future.value(), + returnValueForMissingStub: _i4.Future.value(), + ) as _i4.Future); +} diff --git a/test/json_rpc_test.dart b/test/json_rpc_test.dart index 333c1bde6..b5df1d52f 100644 --- a/test/json_rpc_test.dart +++ b/test/json_rpc_test.dart @@ -11,6 +11,7 @@ void main() { port: DefaultNodes.bitcoin.port, useSSL: true, connectionTimeout: const Duration(seconds: 40), + proxyInfo: null, // TODO test for proxyInfo ); const jsonRequestString = @@ -27,7 +28,8 @@ void main() { final jsonRPC = JsonRPC( host: "some.bad.address.thingdsfsdfsdaf", port: 3000, - connectionTimeout: Duration(seconds: 10), + connectionTimeout: const Duration(seconds: 10), + proxyInfo: null, ); const jsonRequestString = @@ -47,6 +49,7 @@ void main() { port: 3000, useSSL: false, connectionTimeout: const Duration(seconds: 1), + proxyInfo: null, ); const jsonRequestString = diff --git a/test/notifications/notification_card_test.dart b/test/notifications/notification_card_test.dart index 55a9dcae5..d471064b6 100644 --- a/test/notifications/notification_card_test.dart +++ b/test/notifications/notification_card_test.dart @@ -1,3 +1,5 @@ +import 'dart:io'; + import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/svg.dart'; @@ -7,6 +9,7 @@ import 'package:mockito/mockito.dart'; import 'package:stackwallet/models/isar/stack_theme.dart'; import 'package:stackwallet/models/notification_model.dart'; import 'package:stackwallet/notifications/notification_card.dart'; +import 'package:stackwallet/themes/coin_icon_provider.dart'; import 'package:stackwallet/themes/stack_colors.dart'; import 'package:stackwallet/themes/theme_service.dart'; import 'package:stackwallet/utilities/assets.dart'; @@ -47,6 +50,10 @@ void main() { ProviderScope( overrides: [ pThemeService.overrideWithValue(mockThemeService), + coinIconProvider.overrideWithProvider( + (argument) => Provider((_) => + "${Directory.current.path}/test/sample_data/light/assets/dummy.svg"), + ), ], child: MaterialApp( theme: ThemeData( diff --git a/test/notifications/notification_card_test.mocks.dart b/test/notifications/notification_card_test.mocks.dart index 3f1f4b29c..e325b3056 100644 --- a/test/notifications/notification_card_test.mocks.dart +++ b/test/notifications/notification_card_test.mocks.dart @@ -3,13 +3,14 @@ // Do not manually edit this file. // ignore_for_file: no_leading_underscores_for_library_prefixes -import 'dart:async' as _i5; -import 'dart:typed_data' as _i6; +import 'dart:async' as _i6; +import 'dart:typed_data' as _i7; import 'package:mockito/mockito.dart' as _i1; -import 'package:stackwallet/db/isar/main_db.dart' as _i2; -import 'package:stackwallet/models/isar/stack_theme.dart' as _i4; -import 'package:stackwallet/themes/theme_service.dart' as _i3; +import 'package:stackwallet/db/isar/main_db.dart' as _i3; +import 'package:stackwallet/models/isar/stack_theme.dart' as _i5; +import 'package:stackwallet/networking/http.dart' as _i2; +import 'package:stackwallet/themes/theme_service.dart' as _i4; // ignore_for_file: type=lint // ignore_for_file: avoid_redundant_argument_values @@ -22,8 +23,18 @@ import 'package:stackwallet/themes/theme_service.dart' as _i3; // ignore_for_file: camel_case_types // ignore_for_file: subtype_of_sealed_class -class _FakeMainDB_0 extends _i1.SmartFake implements _i2.MainDB { - _FakeMainDB_0( +class _FakeHTTP_0 extends _i1.SmartFake implements _i2.HTTP { + _FakeHTTP_0( + Object parent, + Invocation parentInvocation, + ) : super( + parent, + parentInvocation, + ); +} + +class _FakeMainDB_1 extends _i1.SmartFake implements _i3.MainDB { + _FakeMainDB_1( Object parent, Invocation parentInvocation, ) : super( @@ -35,26 +46,42 @@ class _FakeMainDB_0 extends _i1.SmartFake implements _i2.MainDB { /// A class which mocks [ThemeService]. /// /// See the documentation for Mockito's code generation for more information. -class MockThemeService extends _i1.Mock implements _i3.ThemeService { +class MockThemeService extends _i1.Mock implements _i4.ThemeService { MockThemeService() { _i1.throwOnMissingStub(this); } @override - _i2.MainDB get db => (super.noSuchMethod( + _i2.HTTP get client => (super.noSuchMethod( + Invocation.getter(#client), + returnValue: _FakeHTTP_0( + this, + Invocation.getter(#client), + ), + ) as _i2.HTTP); + @override + set client(_i2.HTTP? _client) => super.noSuchMethod( + Invocation.setter( + #client, + _client, + ), + returnValueForMissingStub: null, + ); + @override + _i3.MainDB get db => (super.noSuchMethod( Invocation.getter(#db), - returnValue: _FakeMainDB_0( + returnValue: _FakeMainDB_1( this, Invocation.getter(#db), ), - ) as _i2.MainDB); + ) as _i3.MainDB); @override - List<_i4.StackTheme> get installedThemes => (super.noSuchMethod( + List<_i5.StackTheme> get installedThemes => (super.noSuchMethod( Invocation.getter(#installedThemes), - returnValue: <_i4.StackTheme>[], - ) as List<_i4.StackTheme>); + returnValue: <_i5.StackTheme>[], + ) as List<_i5.StackTheme>); @override - void init(_i2.MainDB? db) => super.noSuchMethod( + void init(_i3.MainDB? db) => super.noSuchMethod( Invocation.method( #init, [db], @@ -62,70 +89,70 @@ class MockThemeService extends _i1.Mock implements _i3.ThemeService { returnValueForMissingStub: null, ); @override - _i5.Future install({required _i6.Uint8List? themeArchiveData}) => + _i6.Future install({required _i7.Uint8List? themeArchiveData}) => (super.noSuchMethod( Invocation.method( #install, [], {#themeArchiveData: themeArchiveData}, ), - returnValue: _i5.Future.value(), - returnValueForMissingStub: _i5.Future.value(), - ) as _i5.Future); + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); @override - _i5.Future remove({required String? themeId}) => (super.noSuchMethod( + _i6.Future remove({required String? themeId}) => (super.noSuchMethod( Invocation.method( #remove, [], {#themeId: themeId}, ), - returnValue: _i5.Future.value(), - returnValueForMissingStub: _i5.Future.value(), - ) as _i5.Future); + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); @override - _i5.Future checkDefaultThemesOnStartup() => (super.noSuchMethod( + _i6.Future checkDefaultThemesOnStartup() => (super.noSuchMethod( Invocation.method( #checkDefaultThemesOnStartup, [], ), - returnValue: _i5.Future.value(), - returnValueForMissingStub: _i5.Future.value(), - ) as _i5.Future); + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); @override - _i5.Future verifyInstalled({required String? themeId}) => + _i6.Future verifyInstalled({required String? themeId}) => (super.noSuchMethod( Invocation.method( #verifyInstalled, [], {#themeId: themeId}, ), - returnValue: _i5.Future.value(false), - ) as _i5.Future); + returnValue: _i6.Future.value(false), + ) as _i6.Future); @override - _i5.Future> fetchThemes() => (super.noSuchMethod( + _i6.Future> fetchThemes() => (super.noSuchMethod( Invocation.method( #fetchThemes, [], ), - returnValue: _i5.Future>.value( - <_i3.StackThemeMetaData>[]), - ) as _i5.Future>); + returnValue: _i6.Future>.value( + <_i4.StackThemeMetaData>[]), + ) as _i6.Future>); @override - _i5.Future<_i6.Uint8List> fetchTheme( - {required _i3.StackThemeMetaData? themeMetaData}) => + _i6.Future<_i7.Uint8List> fetchTheme( + {required _i4.StackThemeMetaData? themeMetaData}) => (super.noSuchMethod( Invocation.method( #fetchTheme, [], {#themeMetaData: themeMetaData}, ), - returnValue: _i5.Future<_i6.Uint8List>.value(_i6.Uint8List(0)), - ) as _i5.Future<_i6.Uint8List>); + returnValue: _i6.Future<_i7.Uint8List>.value(_i7.Uint8List(0)), + ) as _i6.Future<_i7.Uint8List>); @override - _i4.StackTheme? getTheme({required String? themeId}) => + _i5.StackTheme? getTheme({required String? themeId}) => (super.noSuchMethod(Invocation.method( #getTheme, [], {#themeId: themeId}, - )) as _i4.StackTheme?); + )) as _i5.StackTheme?); } diff --git a/test/pages/send_view/send_view_test.dart b/test/pages/send_view/send_view_test.dart index 975554c8d..389ea1469 100644 --- a/test/pages/send_view/send_view_test.dart +++ b/test/pages/send_view/send_view_test.dart @@ -1,3 +1,5 @@ +import 'dart:io'; + import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_test/flutter_test.dart'; @@ -14,6 +16,7 @@ import 'package:stackwallet/services/locale_service.dart'; import 'package:stackwallet/services/node_service.dart'; import 'package:stackwallet/services/wallets.dart'; import 'package:stackwallet/services/wallets_service.dart'; +import 'package:stackwallet/themes/coin_icon_provider.dart'; import 'package:stackwallet/themes/stack_colors.dart'; import 'package:stackwallet/themes/theme_service.dart'; import 'package:stackwallet/utilities/amount/amount_unit.dart'; @@ -80,6 +83,10 @@ void main() { .overrideWithValue(mockLocaleService), prefsChangeNotifierProvider.overrideWithValue(mockPrefs), pThemeService.overrideWithValue(mockThemeService), + coinIconProvider.overrideWithProvider( + (argument) => Provider((_) => + "${Directory.current.path}/test/sample_data/light/assets/dummy.svg"), + ), // previewTxButtonStateProvider ], child: MaterialApp( @@ -157,7 +164,11 @@ void main() { localeServiceChangeNotifierProvider .overrideWithValue(mockLocaleService), prefsChangeNotifierProvider.overrideWithValue(mockPrefs), - pThemeService.overrideWithValue(mockThemeService) + pThemeService.overrideWithValue(mockThemeService), + coinIconProvider.overrideWithProvider( + (argument) => Provider((_) => + "${Directory.current.path}/test/sample_data/light/assets/dummy.svg"), + ), // previewTxButtonStateProvider ], child: MaterialApp( diff --git a/test/pages/send_view/send_view_test.mocks.dart b/test/pages/send_view/send_view_test.mocks.dart index c9414583d..d2d5de661 100644 --- a/test/pages/send_view/send_view_test.mocks.dart +++ b/test/pages/send_view/send_view_test.mocks.dart @@ -3,9 +3,9 @@ // Do not manually edit this file. // ignore_for_file: no_leading_underscores_for_library_prefixes -import 'dart:async' as _i23; -import 'dart:typed_data' as _i30; -import 'dart:ui' as _i25; +import 'dart:async' as _i24; +import 'dart:typed_data' as _i31; +import 'dart:ui' as _i26; import 'package:bip32/bip32.dart' as _i17; import 'package:bip47/bip47.dart' as _i19; @@ -18,29 +18,30 @@ import 'package:stackwallet/electrumx_rpc/cached_electrumx.dart' as _i11; import 'package:stackwallet/electrumx_rpc/electrumx.dart' as _i10; import 'package:stackwallet/models/balance.dart' as _i12; import 'package:stackwallet/models/isar/models/isar_models.dart' as _i18; -import 'package:stackwallet/models/isar/stack_theme.dart' as _i33; -import 'package:stackwallet/models/node_model.dart' as _i26; +import 'package:stackwallet/models/isar/stack_theme.dart' as _i34; +import 'package:stackwallet/models/node_model.dart' as _i27; import 'package:stackwallet/models/paymint/fee_object_model.dart' as _i9; -import 'package:stackwallet/models/signing_data.dart' as _i29; -import 'package:stackwallet/services/coins/bitcoin/bitcoin_wallet.dart' as _i27; -import 'package:stackwallet/services/coins/coin_service.dart' as _i20; +import 'package:stackwallet/models/signing_data.dart' as _i30; +import 'package:stackwallet/networking/http.dart' as _i20; +import 'package:stackwallet/services/coins/bitcoin/bitcoin_wallet.dart' as _i28; +import 'package:stackwallet/services/coins/coin_service.dart' as _i21; import 'package:stackwallet/services/coins/manager.dart' as _i6; -import 'package:stackwallet/services/locale_service.dart' as _i31; +import 'package:stackwallet/services/locale_service.dart' as _i32; import 'package:stackwallet/services/node_service.dart' as _i3; import 'package:stackwallet/services/transaction_notification_tracker.dart' as _i8; -import 'package:stackwallet/services/wallets.dart' as _i21; +import 'package:stackwallet/services/wallets.dart' as _i22; import 'package:stackwallet/services/wallets_service.dart' as _i2; -import 'package:stackwallet/themes/theme_service.dart' as _i32; +import 'package:stackwallet/themes/theme_service.dart' as _i33; import 'package:stackwallet/utilities/amount/amount.dart' as _i15; -import 'package:stackwallet/utilities/amount/amount_unit.dart' as _i36; -import 'package:stackwallet/utilities/enums/backup_frequency_type.dart' as _i35; -import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i22; -import 'package:stackwallet/utilities/enums/derive_path_type_enum.dart' as _i28; -import 'package:stackwallet/utilities/enums/sync_type_enum.dart' as _i34; +import 'package:stackwallet/utilities/amount/amount_unit.dart' as _i37; +import 'package:stackwallet/utilities/enums/backup_frequency_type.dart' as _i36; +import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i23; +import 'package:stackwallet/utilities/enums/derive_path_type_enum.dart' as _i29; +import 'package:stackwallet/utilities/enums/sync_type_enum.dart' as _i35; import 'package:stackwallet/utilities/flutter_secure_storage_interface.dart' as _i7; -import 'package:stackwallet/utilities/prefs.dart' as _i24; +import 'package:stackwallet/utilities/prefs.dart' as _i25; import 'package:tuple/tuple.dart' as _i16; // ignore_for_file: type=lint @@ -241,9 +242,19 @@ class _FakePaymentCode_17 extends _i1.SmartFake implements _i19.PaymentCode { ); } -class _FakeCoinServiceAPI_18 extends _i1.SmartFake - implements _i20.CoinServiceAPI { - _FakeCoinServiceAPI_18( +class _FakeHTTP_18 extends _i1.SmartFake implements _i20.HTTP { + _FakeHTTP_18( + Object parent, + Invocation parentInvocation, + ) : super( + parent, + parentInvocation, + ); +} + +class _FakeCoinServiceAPI_19 extends _i1.SmartFake + implements _i21.CoinServiceAPI { + _FakeCoinServiceAPI_19( Object parent, Invocation parentInvocation, ) : super( @@ -255,7 +266,7 @@ class _FakeCoinServiceAPI_18 extends _i1.SmartFake /// A class which mocks [Wallets]. /// /// See the documentation for Mockito's code generation for more information. -class MockWallets extends _i1.Mock implements _i21.Wallets { +class MockWallets extends _i1.Mock implements _i22.Wallets { MockWallets() { _i1.throwOnMissingStub(this); } @@ -322,7 +333,7 @@ class MockWallets extends _i1.Mock implements _i21.Wallets { returnValueForMissingStub: null, ); @override - List getWalletIdsFor({required _i22.Coin? coin}) => + List getWalletIdsFor({required _i23.Coin? coin}) => (super.noSuchMethod( Invocation.method( #getWalletIdsFor, @@ -332,20 +343,20 @@ class MockWallets extends _i1.Mock implements _i21.Wallets { returnValue: [], ) as List); @override - List<_i16.Tuple2<_i22.Coin, List<_i5.ChangeNotifierProvider<_i6.Manager>>>> + List<_i16.Tuple2<_i23.Coin, List<_i5.ChangeNotifierProvider<_i6.Manager>>>> getManagerProvidersByCoin() => (super.noSuchMethod( Invocation.method( #getManagerProvidersByCoin, [], ), - returnValue: <_i16.Tuple2<_i22.Coin, + returnValue: <_i16.Tuple2<_i23.Coin, List<_i5.ChangeNotifierProvider<_i6.Manager>>>>[], ) as List< - _i16.Tuple2<_i22.Coin, + _i16.Tuple2<_i23.Coin, List<_i5.ChangeNotifierProvider<_i6.Manager>>>>); @override List<_i5.ChangeNotifierProvider<_i6.Manager>> getManagerProvidersForCoin( - _i22.Coin? coin) => + _i23.Coin? coin) => (super.noSuchMethod( Invocation.method( #getManagerProvidersForCoin, @@ -409,17 +420,17 @@ class MockWallets extends _i1.Mock implements _i21.Wallets { returnValueForMissingStub: null, ); @override - _i23.Future load(_i24.Prefs? prefs) => (super.noSuchMethod( + _i24.Future load(_i25.Prefs? prefs) => (super.noSuchMethod( Invocation.method( #load, [prefs], ), - returnValue: _i23.Future.value(), - returnValueForMissingStub: _i23.Future.value(), - ) as _i23.Future); + returnValue: _i24.Future.value(), + returnValueForMissingStub: _i24.Future.value(), + ) as _i24.Future); @override - _i23.Future loadAfterStackRestore( - _i24.Prefs? prefs, + _i24.Future loadAfterStackRestore( + _i25.Prefs? prefs, List<_i6.Manager>? managers, ) => (super.noSuchMethod( @@ -430,11 +441,11 @@ class MockWallets extends _i1.Mock implements _i21.Wallets { managers, ], ), - returnValue: _i23.Future.value(), - returnValueForMissingStub: _i23.Future.value(), - ) as _i23.Future); + returnValue: _i24.Future.value(), + returnValueForMissingStub: _i24.Future.value(), + ) as _i24.Future); @override - void addListener(_i25.VoidCallback? listener) => super.noSuchMethod( + void addListener(_i26.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #addListener, [listener], @@ -442,7 +453,7 @@ class MockWallets extends _i1.Mock implements _i21.Wallets { returnValueForMissingStub: null, ); @override - void removeListener(_i25.VoidCallback? listener) => super.noSuchMethod( + void removeListener(_i26.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #removeListener, [listener], @@ -468,19 +479,19 @@ class MockWalletsService extends _i1.Mock implements _i2.WalletsService { } @override - _i23.Future> get walletNames => + _i24.Future> get walletNames => (super.noSuchMethod( Invocation.getter(#walletNames), - returnValue: _i23.Future>.value( + returnValue: _i24.Future>.value( {}), - ) as _i23.Future>); + ) as _i24.Future>); @override bool get hasListeners => (super.noSuchMethod( Invocation.getter(#hasListeners), returnValue: false, ) as bool); @override - _i23.Future renameWallet({ + _i24.Future renameWallet({ required String? from, required String? to, required bool? shouldNotifyListeners, @@ -495,8 +506,8 @@ class MockWalletsService extends _i1.Mock implements _i2.WalletsService { #shouldNotifyListeners: shouldNotifyListeners, }, ), - returnValue: _i23.Future.value(false), - ) as _i23.Future); + returnValue: _i24.Future.value(false), + ) as _i24.Future); @override Map fetchWalletsData() => (super.noSuchMethod( Invocation.method( @@ -506,10 +517,10 @@ class MockWalletsService extends _i1.Mock implements _i2.WalletsService { returnValue: {}, ) as Map); @override - _i23.Future addExistingStackWallet({ + _i24.Future addExistingStackWallet({ required String? name, required String? walletId, - required _i22.Coin? coin, + required _i23.Coin? coin, required bool? shouldNotifyListeners, }) => (super.noSuchMethod( @@ -523,13 +534,13 @@ class MockWalletsService extends _i1.Mock implements _i2.WalletsService { #shouldNotifyListeners: shouldNotifyListeners, }, ), - returnValue: _i23.Future.value(), - returnValueForMissingStub: _i23.Future.value(), - ) as _i23.Future); + returnValue: _i24.Future.value(), + returnValueForMissingStub: _i24.Future.value(), + ) as _i24.Future); @override - _i23.Future addNewWallet({ + _i24.Future addNewWallet({ required String? name, - required _i22.Coin? coin, + required _i23.Coin? coin, required bool? shouldNotifyListeners, }) => (super.noSuchMethod( @@ -542,46 +553,46 @@ class MockWalletsService extends _i1.Mock implements _i2.WalletsService { #shouldNotifyListeners: shouldNotifyListeners, }, ), - returnValue: _i23.Future.value(), - ) as _i23.Future); + returnValue: _i24.Future.value(), + ) as _i24.Future); @override - _i23.Future> getFavoriteWalletIds() => (super.noSuchMethod( + _i24.Future> getFavoriteWalletIds() => (super.noSuchMethod( Invocation.method( #getFavoriteWalletIds, [], ), - returnValue: _i23.Future>.value([]), - ) as _i23.Future>); + returnValue: _i24.Future>.value([]), + ) as _i24.Future>); @override - _i23.Future saveFavoriteWalletIds(List? walletIds) => + _i24.Future saveFavoriteWalletIds(List? walletIds) => (super.noSuchMethod( Invocation.method( #saveFavoriteWalletIds, [walletIds], ), - returnValue: _i23.Future.value(), - returnValueForMissingStub: _i23.Future.value(), - ) as _i23.Future); + returnValue: _i24.Future.value(), + returnValueForMissingStub: _i24.Future.value(), + ) as _i24.Future); @override - _i23.Future addFavorite(String? walletId) => (super.noSuchMethod( + _i24.Future addFavorite(String? walletId) => (super.noSuchMethod( Invocation.method( #addFavorite, [walletId], ), - returnValue: _i23.Future.value(), - returnValueForMissingStub: _i23.Future.value(), - ) as _i23.Future); + returnValue: _i24.Future.value(), + returnValueForMissingStub: _i24.Future.value(), + ) as _i24.Future); @override - _i23.Future removeFavorite(String? walletId) => (super.noSuchMethod( + _i24.Future removeFavorite(String? walletId) => (super.noSuchMethod( Invocation.method( #removeFavorite, [walletId], ), - returnValue: _i23.Future.value(), - returnValueForMissingStub: _i23.Future.value(), - ) as _i23.Future); + returnValue: _i24.Future.value(), + returnValueForMissingStub: _i24.Future.value(), + ) as _i24.Future); @override - _i23.Future moveFavorite({ + _i24.Future moveFavorite({ required int? fromIndex, required int? toIndex, }) => @@ -594,48 +605,48 @@ class MockWalletsService extends _i1.Mock implements _i2.WalletsService { #toIndex: toIndex, }, ), - returnValue: _i23.Future.value(), - returnValueForMissingStub: _i23.Future.value(), - ) as _i23.Future); + returnValue: _i24.Future.value(), + returnValueForMissingStub: _i24.Future.value(), + ) as _i24.Future); @override - _i23.Future checkForDuplicate(String? name) => (super.noSuchMethod( + _i24.Future checkForDuplicate(String? name) => (super.noSuchMethod( Invocation.method( #checkForDuplicate, [name], ), - returnValue: _i23.Future.value(false), - ) as _i23.Future); + returnValue: _i24.Future.value(false), + ) as _i24.Future); @override - _i23.Future getWalletId(String? walletName) => (super.noSuchMethod( + _i24.Future getWalletId(String? walletName) => (super.noSuchMethod( Invocation.method( #getWalletId, [walletName], ), - returnValue: _i23.Future.value(), - ) as _i23.Future); + returnValue: _i24.Future.value(), + ) as _i24.Future); @override - _i23.Future isMnemonicVerified({required String? walletId}) => + _i24.Future isMnemonicVerified({required String? walletId}) => (super.noSuchMethod( Invocation.method( #isMnemonicVerified, [], {#walletId: walletId}, ), - returnValue: _i23.Future.value(false), - ) as _i23.Future); + returnValue: _i24.Future.value(false), + ) as _i24.Future); @override - _i23.Future setMnemonicVerified({required String? walletId}) => + _i24.Future setMnemonicVerified({required String? walletId}) => (super.noSuchMethod( Invocation.method( #setMnemonicVerified, [], {#walletId: walletId}, ), - returnValue: _i23.Future.value(), - returnValueForMissingStub: _i23.Future.value(), - ) as _i23.Future); + returnValue: _i24.Future.value(), + returnValueForMissingStub: _i24.Future.value(), + ) as _i24.Future); @override - _i23.Future deleteWallet( + _i24.Future deleteWallet( String? name, bool? shouldNotifyListeners, ) => @@ -647,20 +658,20 @@ class MockWalletsService extends _i1.Mock implements _i2.WalletsService { shouldNotifyListeners, ], ), - returnValue: _i23.Future.value(0), - ) as _i23.Future); + returnValue: _i24.Future.value(0), + ) as _i24.Future); @override - _i23.Future refreshWallets(bool? shouldNotifyListeners) => + _i24.Future refreshWallets(bool? shouldNotifyListeners) => (super.noSuchMethod( Invocation.method( #refreshWallets, [shouldNotifyListeners], ), - returnValue: _i23.Future.value(), - returnValueForMissingStub: _i23.Future.value(), - ) as _i23.Future); + returnValue: _i24.Future.value(), + returnValueForMissingStub: _i24.Future.value(), + ) as _i24.Future); @override - void addListener(_i25.VoidCallback? listener) => super.noSuchMethod( + void addListener(_i26.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #addListener, [listener], @@ -668,7 +679,7 @@ class MockWalletsService extends _i1.Mock implements _i2.WalletsService { returnValueForMissingStub: null, ); @override - void removeListener(_i25.VoidCallback? listener) => super.noSuchMethod( + void removeListener(_i26.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #removeListener, [listener], @@ -710,33 +721,33 @@ class MockNodeService extends _i1.Mock implements _i3.NodeService { ), ) as _i7.SecureStorageInterface); @override - List<_i26.NodeModel> get primaryNodes => (super.noSuchMethod( + List<_i27.NodeModel> get primaryNodes => (super.noSuchMethod( Invocation.getter(#primaryNodes), - returnValue: <_i26.NodeModel>[], - ) as List<_i26.NodeModel>); + returnValue: <_i27.NodeModel>[], + ) as List<_i27.NodeModel>); @override - List<_i26.NodeModel> get nodes => (super.noSuchMethod( + List<_i27.NodeModel> get nodes => (super.noSuchMethod( Invocation.getter(#nodes), - returnValue: <_i26.NodeModel>[], - ) as List<_i26.NodeModel>); + returnValue: <_i27.NodeModel>[], + ) as List<_i27.NodeModel>); @override bool get hasListeners => (super.noSuchMethod( Invocation.getter(#hasListeners), returnValue: false, ) as bool); @override - _i23.Future updateDefaults() => (super.noSuchMethod( + _i24.Future updateDefaults() => (super.noSuchMethod( Invocation.method( #updateDefaults, [], ), - returnValue: _i23.Future.value(), - returnValueForMissingStub: _i23.Future.value(), - ) as _i23.Future); + returnValue: _i24.Future.value(), + returnValueForMissingStub: _i24.Future.value(), + ) as _i24.Future); @override - _i23.Future setPrimaryNodeFor({ - required _i22.Coin? coin, - required _i26.NodeModel? node, + _i24.Future setPrimaryNodeFor({ + required _i23.Coin? coin, + required _i27.NodeModel? node, bool? shouldNotifyListeners = false, }) => (super.noSuchMethod( @@ -749,44 +760,44 @@ class MockNodeService extends _i1.Mock implements _i3.NodeService { #shouldNotifyListeners: shouldNotifyListeners, }, ), - returnValue: _i23.Future.value(), - returnValueForMissingStub: _i23.Future.value(), - ) as _i23.Future); + returnValue: _i24.Future.value(), + returnValueForMissingStub: _i24.Future.value(), + ) as _i24.Future); @override - _i26.NodeModel? getPrimaryNodeFor({required _i22.Coin? coin}) => + _i27.NodeModel? getPrimaryNodeFor({required _i23.Coin? coin}) => (super.noSuchMethod(Invocation.method( #getPrimaryNodeFor, [], {#coin: coin}, - )) as _i26.NodeModel?); + )) as _i27.NodeModel?); @override - List<_i26.NodeModel> getNodesFor(_i22.Coin? coin) => (super.noSuchMethod( + List<_i27.NodeModel> getNodesFor(_i23.Coin? coin) => (super.noSuchMethod( Invocation.method( #getNodesFor, [coin], ), - returnValue: <_i26.NodeModel>[], - ) as List<_i26.NodeModel>); + returnValue: <_i27.NodeModel>[], + ) as List<_i27.NodeModel>); @override - _i26.NodeModel? getNodeById({required String? id}) => + _i27.NodeModel? getNodeById({required String? id}) => (super.noSuchMethod(Invocation.method( #getNodeById, [], {#id: id}, - )) as _i26.NodeModel?); + )) as _i27.NodeModel?); @override - List<_i26.NodeModel> failoverNodesFor({required _i22.Coin? coin}) => + List<_i27.NodeModel> failoverNodesFor({required _i23.Coin? coin}) => (super.noSuchMethod( Invocation.method( #failoverNodesFor, [], {#coin: coin}, ), - returnValue: <_i26.NodeModel>[], - ) as List<_i26.NodeModel>); + returnValue: <_i27.NodeModel>[], + ) as List<_i27.NodeModel>); @override - _i23.Future add( - _i26.NodeModel? node, + _i24.Future add( + _i27.NodeModel? node, String? password, bool? shouldNotifyListeners, ) => @@ -799,11 +810,11 @@ class MockNodeService extends _i1.Mock implements _i3.NodeService { shouldNotifyListeners, ], ), - returnValue: _i23.Future.value(), - returnValueForMissingStub: _i23.Future.value(), - ) as _i23.Future); + returnValue: _i24.Future.value(), + returnValueForMissingStub: _i24.Future.value(), + ) as _i24.Future); @override - _i23.Future delete( + _i24.Future delete( String? id, bool? shouldNotifyListeners, ) => @@ -815,11 +826,11 @@ class MockNodeService extends _i1.Mock implements _i3.NodeService { shouldNotifyListeners, ], ), - returnValue: _i23.Future.value(), - returnValueForMissingStub: _i23.Future.value(), - ) as _i23.Future); + returnValue: _i24.Future.value(), + returnValueForMissingStub: _i24.Future.value(), + ) as _i24.Future); @override - _i23.Future setEnabledState( + _i24.Future setEnabledState( String? id, bool? enabled, bool? shouldNotifyListeners, @@ -833,12 +844,12 @@ class MockNodeService extends _i1.Mock implements _i3.NodeService { shouldNotifyListeners, ], ), - returnValue: _i23.Future.value(), - returnValueForMissingStub: _i23.Future.value(), - ) as _i23.Future); + returnValue: _i24.Future.value(), + returnValueForMissingStub: _i24.Future.value(), + ) as _i24.Future); @override - _i23.Future edit( - _i26.NodeModel? editedNode, + _i24.Future edit( + _i27.NodeModel? editedNode, String? password, bool? shouldNotifyListeners, ) => @@ -851,20 +862,20 @@ class MockNodeService extends _i1.Mock implements _i3.NodeService { shouldNotifyListeners, ], ), - returnValue: _i23.Future.value(), - returnValueForMissingStub: _i23.Future.value(), - ) as _i23.Future); + returnValue: _i24.Future.value(), + returnValueForMissingStub: _i24.Future.value(), + ) as _i24.Future); @override - _i23.Future updateCommunityNodes() => (super.noSuchMethod( + _i24.Future updateCommunityNodes() => (super.noSuchMethod( Invocation.method( #updateCommunityNodes, [], ), - returnValue: _i23.Future.value(), - returnValueForMissingStub: _i23.Future.value(), - ) as _i23.Future); + returnValue: _i24.Future.value(), + returnValueForMissingStub: _i24.Future.value(), + ) as _i24.Future); @override - void addListener(_i25.VoidCallback? listener) => super.noSuchMethod( + void addListener(_i26.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #addListener, [listener], @@ -872,7 +883,7 @@ class MockNodeService extends _i1.Mock implements _i3.NodeService { returnValueForMissingStub: null, ); @override - void removeListener(_i25.VoidCallback? listener) => super.noSuchMethod( + void removeListener(_i26.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #removeListener, [listener], @@ -900,13 +911,13 @@ class MockNodeService extends _i1.Mock implements _i3.NodeService { /// A class which mocks [BitcoinWallet]. /// /// See the documentation for Mockito's code generation for more information. -class MockBitcoinWallet extends _i1.Mock implements _i27.BitcoinWallet { +class MockBitcoinWallet extends _i1.Mock implements _i28.BitcoinWallet { MockBitcoinWallet() { _i1.throwOnMissingStub(this); } @override - set timer(_i23.Timer? _timer) => super.noSuchMethod( + set timer(_i24.Timer? _timer) => super.noSuchMethod( Invocation.setter( #timer, _timer, @@ -983,74 +994,74 @@ class MockBitcoinWallet extends _i1.Mock implements _i27.BitcoinWallet { returnValue: false, ) as bool); @override - _i22.Coin get coin => (super.noSuchMethod( + _i23.Coin get coin => (super.noSuchMethod( Invocation.getter(#coin), - returnValue: _i22.Coin.bitcoin, - ) as _i22.Coin); + returnValue: _i23.Coin.bitcoin, + ) as _i23.Coin); @override - _i23.Future> get utxos => (super.noSuchMethod( + _i24.Future> get utxos => (super.noSuchMethod( Invocation.getter(#utxos), - returnValue: _i23.Future>.value(<_i18.UTXO>[]), - ) as _i23.Future>); + returnValue: _i24.Future>.value(<_i18.UTXO>[]), + ) as _i24.Future>); @override - _i23.Future> get transactions => (super.noSuchMethod( + _i24.Future> get transactions => (super.noSuchMethod( Invocation.getter(#transactions), returnValue: - _i23.Future>.value(<_i18.Transaction>[]), - ) as _i23.Future>); + _i24.Future>.value(<_i18.Transaction>[]), + ) as _i24.Future>); @override - _i23.Future get currentReceivingAddress => (super.noSuchMethod( + _i24.Future get currentReceivingAddress => (super.noSuchMethod( Invocation.getter(#currentReceivingAddress), - returnValue: _i23.Future.value(''), - ) as _i23.Future); + returnValue: _i24.Future.value(''), + ) as _i24.Future); @override - _i23.Future get currentChangeAddress => (super.noSuchMethod( + _i24.Future get currentChangeAddress => (super.noSuchMethod( Invocation.getter(#currentChangeAddress), - returnValue: _i23.Future.value(''), - ) as _i23.Future); + returnValue: _i24.Future.value(''), + ) as _i24.Future); @override - _i23.Future get currentChangeAddressP2PKH => (super.noSuchMethod( + _i24.Future get currentChangeAddressP2PKH => (super.noSuchMethod( Invocation.getter(#currentChangeAddressP2PKH), - returnValue: _i23.Future.value(''), - ) as _i23.Future); + returnValue: _i24.Future.value(''), + ) as _i24.Future); @override bool get hasCalledExit => (super.noSuchMethod( Invocation.getter(#hasCalledExit), returnValue: false, ) as bool); @override - _i23.Future<_i9.FeeObject> get fees => (super.noSuchMethod( + _i24.Future<_i9.FeeObject> get fees => (super.noSuchMethod( Invocation.getter(#fees), - returnValue: _i23.Future<_i9.FeeObject>.value(_FakeFeeObject_6( + returnValue: _i24.Future<_i9.FeeObject>.value(_FakeFeeObject_6( this, Invocation.getter(#fees), )), - ) as _i23.Future<_i9.FeeObject>); + ) as _i24.Future<_i9.FeeObject>); @override - _i23.Future get maxFee => (super.noSuchMethod( + _i24.Future get maxFee => (super.noSuchMethod( Invocation.getter(#maxFee), - returnValue: _i23.Future.value(0), - ) as _i23.Future); + returnValue: _i24.Future.value(0), + ) as _i24.Future); @override - _i23.Future> get mnemonic => (super.noSuchMethod( + _i24.Future> get mnemonic => (super.noSuchMethod( Invocation.getter(#mnemonic), - returnValue: _i23.Future>.value([]), - ) as _i23.Future>); + returnValue: _i24.Future>.value([]), + ) as _i24.Future>); @override - _i23.Future get mnemonicString => (super.noSuchMethod( + _i24.Future get mnemonicString => (super.noSuchMethod( Invocation.getter(#mnemonicString), - returnValue: _i23.Future.value(), - ) as _i23.Future); + returnValue: _i24.Future.value(), + ) as _i24.Future); @override - _i23.Future get mnemonicPassphrase => (super.noSuchMethod( + _i24.Future get mnemonicPassphrase => (super.noSuchMethod( Invocation.getter(#mnemonicPassphrase), - returnValue: _i23.Future.value(), - ) as _i23.Future); + returnValue: _i24.Future.value(), + ) as _i24.Future); @override - _i23.Future get chainHeight => (super.noSuchMethod( + _i24.Future get chainHeight => (super.noSuchMethod( Invocation.getter(#chainHeight), - returnValue: _i23.Future.value(0), - ) as _i23.Future); + returnValue: _i24.Future.value(0), + ) as _i24.Future); @override int get storedChainHeight => (super.noSuchMethod( Invocation.getter(#storedChainHeight), @@ -1122,10 +1133,10 @@ class MockBitcoinWallet extends _i1.Mock implements _i27.BitcoinWallet { ), ) as _i12.Balance); @override - _i23.Future get xpub => (super.noSuchMethod( + _i24.Future get xpub => (super.noSuchMethod( Invocation.getter(#xpub), - returnValue: _i23.Future.value(''), - ) as _i23.Future); + returnValue: _i24.Future.value(''), + ) as _i24.Future); @override set onIsActiveWalletChanged(void Function(bool)? _onIsActiveWalletChanged) => super.noSuchMethod( @@ -1152,26 +1163,26 @@ class MockBitcoinWallet extends _i1.Mock implements _i27.BitcoinWallet { ), ) as _i14.NetworkType); @override - _i23.Future exit() => (super.noSuchMethod( + _i24.Future exit() => (super.noSuchMethod( Invocation.method( #exit, [], ), - returnValue: _i23.Future.value(), - returnValueForMissingStub: _i23.Future.value(), - ) as _i23.Future); + returnValue: _i24.Future.value(), + returnValueForMissingStub: _i24.Future.value(), + ) as _i24.Future); @override - _i28.DerivePathType addressType({required String? address}) => + _i29.DerivePathType addressType({required String? address}) => (super.noSuchMethod( Invocation.method( #addressType, [], {#address: address}, ), - returnValue: _i28.DerivePathType.bip44, - ) as _i28.DerivePathType); + returnValue: _i29.DerivePathType.bip44, + ) as _i29.DerivePathType); @override - _i23.Future recoverFromMnemonic({ + _i24.Future recoverFromMnemonic({ required String? mnemonic, String? mnemonicPassphrase, required int? maxUnusedAddressGap, @@ -1190,47 +1201,47 @@ class MockBitcoinWallet extends _i1.Mock implements _i27.BitcoinWallet { #height: height, }, ), - returnValue: _i23.Future.value(), - returnValueForMissingStub: _i23.Future.value(), - ) as _i23.Future); + returnValue: _i24.Future.value(), + returnValueForMissingStub: _i24.Future.value(), + ) as _i24.Future); @override - _i23.Future getTransactionCacheEarly(List? allAddresses) => + _i24.Future getTransactionCacheEarly(List? allAddresses) => (super.noSuchMethod( Invocation.method( #getTransactionCacheEarly, [allAddresses], ), - returnValue: _i23.Future.value(), - returnValueForMissingStub: _i23.Future.value(), - ) as _i23.Future); + returnValue: _i24.Future.value(), + returnValueForMissingStub: _i24.Future.value(), + ) as _i24.Future); @override - _i23.Future refreshIfThereIsNewData() => (super.noSuchMethod( + _i24.Future refreshIfThereIsNewData() => (super.noSuchMethod( Invocation.method( #refreshIfThereIsNewData, [], ), - returnValue: _i23.Future.value(false), - ) as _i23.Future); + returnValue: _i24.Future.value(false), + ) as _i24.Future); @override - _i23.Future getAllTxsToWatch() => (super.noSuchMethod( + _i24.Future getAllTxsToWatch() => (super.noSuchMethod( Invocation.method( #getAllTxsToWatch, [], ), - returnValue: _i23.Future.value(), - returnValueForMissingStub: _i23.Future.value(), - ) as _i23.Future); + returnValue: _i24.Future.value(), + returnValueForMissingStub: _i24.Future.value(), + ) as _i24.Future); @override - _i23.Future refresh() => (super.noSuchMethod( + _i24.Future refresh() => (super.noSuchMethod( Invocation.method( #refresh, [], ), - returnValue: _i23.Future.value(), - returnValueForMissingStub: _i23.Future.value(), - ) as _i23.Future); + returnValue: _i24.Future.value(), + returnValueForMissingStub: _i24.Future.value(), + ) as _i24.Future); @override - _i23.Future> prepareSend({ + _i24.Future> prepareSend({ required String? address, required _i15.Amount? amount, Map? args, @@ -1246,26 +1257,26 @@ class MockBitcoinWallet extends _i1.Mock implements _i27.BitcoinWallet { }, ), returnValue: - _i23.Future>.value({}), - ) as _i23.Future>); + _i24.Future>.value({}), + ) as _i24.Future>); @override - _i23.Future confirmSend({required Map? txData}) => + _i24.Future confirmSend({required Map? txData}) => (super.noSuchMethod( Invocation.method( #confirmSend, [], {#txData: txData}, ), - returnValue: _i23.Future.value(''), - ) as _i23.Future); + returnValue: _i24.Future.value(''), + ) as _i24.Future); @override - _i23.Future testNetworkConnection() => (super.noSuchMethod( + _i24.Future testNetworkConnection() => (super.noSuchMethod( Invocation.method( #testNetworkConnection, [], ), - returnValue: _i23.Future.value(false), - ) as _i23.Future); + returnValue: _i24.Future.value(false), + ) as _i24.Future); @override void startNetworkAlivePinging() => super.noSuchMethod( Invocation.method( @@ -1283,33 +1294,35 @@ class MockBitcoinWallet extends _i1.Mock implements _i27.BitcoinWallet { returnValueForMissingStub: null, ); @override - _i23.Future initializeNew() => (super.noSuchMethod( + _i24.Future initializeNew( + ({String mnemonicPassphrase, int wordCount})? data) => + (super.noSuchMethod( Invocation.method( #initializeNew, - [], + [data], ), - returnValue: _i23.Future.value(), - returnValueForMissingStub: _i23.Future.value(), - ) as _i23.Future); + returnValue: _i24.Future.value(), + returnValueForMissingStub: _i24.Future.value(), + ) as _i24.Future); @override - _i23.Future initializeExisting() => (super.noSuchMethod( + _i24.Future initializeExisting() => (super.noSuchMethod( Invocation.method( #initializeExisting, [], ), - returnValue: _i23.Future.value(), - returnValueForMissingStub: _i23.Future.value(), - ) as _i23.Future); + returnValue: _i24.Future.value(), + returnValueForMissingStub: _i24.Future.value(), + ) as _i24.Future); @override - _i23.Future updateSentCachedTxData(Map? txData) => + _i24.Future updateSentCachedTxData(Map? txData) => (super.noSuchMethod( Invocation.method( #updateSentCachedTxData, [txData], ), - returnValue: _i23.Future.value(), - returnValueForMissingStub: _i23.Future.value(), - ) as _i23.Future); + returnValue: _i24.Future.value(), + returnValueForMissingStub: _i24.Future.value(), + ) as _i24.Future); @override bool validateAddress(String? address) => (super.noSuchMethod( Invocation.method( @@ -1319,70 +1332,70 @@ class MockBitcoinWallet extends _i1.Mock implements _i27.BitcoinWallet { returnValue: false, ) as bool); @override - _i23.Future updateNode(bool? shouldRefresh) => (super.noSuchMethod( + _i24.Future updateNode(bool? shouldRefresh) => (super.noSuchMethod( Invocation.method( #updateNode, [shouldRefresh], ), - returnValue: _i23.Future.value(), - returnValueForMissingStub: _i23.Future.value(), - ) as _i23.Future); + returnValue: _i24.Future.value(), + returnValueForMissingStub: _i24.Future.value(), + ) as _i24.Future); @override - _i23.Future<_i10.ElectrumXNode> getCurrentNode() => (super.noSuchMethod( + _i24.Future<_i10.ElectrumXNode> getCurrentNode() => (super.noSuchMethod( Invocation.method( #getCurrentNode, [], ), returnValue: - _i23.Future<_i10.ElectrumXNode>.value(_FakeElectrumXNode_12( + _i24.Future<_i10.ElectrumXNode>.value(_FakeElectrumXNode_12( this, Invocation.method( #getCurrentNode, [], ), )), - ) as _i23.Future<_i10.ElectrumXNode>); + ) as _i24.Future<_i10.ElectrumXNode>); @override - _i23.Future>> fastFetch( + _i24.Future>> fastFetch( List? allTxHashes) => (super.noSuchMethod( Invocation.method( #fastFetch, [allTxHashes], ), - returnValue: _i23.Future>>.value( + returnValue: _i24.Future>>.value( >[]), - ) as _i23.Future>>); + ) as _i24.Future>>); @override - _i23.Future getTxCount({required String? address}) => + _i24.Future getTxCount({required String? address}) => (super.noSuchMethod( Invocation.method( #getTxCount, [], {#address: address}, ), - returnValue: _i23.Future.value(0), - ) as _i23.Future); + returnValue: _i24.Future.value(0), + ) as _i24.Future); @override - _i23.Future checkCurrentReceivingAddressesForTransactions() => + _i24.Future checkCurrentReceivingAddressesForTransactions() => (super.noSuchMethod( Invocation.method( #checkCurrentReceivingAddressesForTransactions, [], ), - returnValue: _i23.Future.value(), - returnValueForMissingStub: _i23.Future.value(), - ) as _i23.Future); + returnValue: _i24.Future.value(), + returnValueForMissingStub: _i24.Future.value(), + ) as _i24.Future); @override - _i23.Future checkCurrentChangeAddressesForTransactions() => + _i24.Future checkCurrentChangeAddressesForTransactions() => (super.noSuchMethod( Invocation.method( #checkCurrentChangeAddressesForTransactions, [], ), - returnValue: _i23.Future.value(), - returnValueForMissingStub: _i23.Future.value(), - ) as _i23.Future); + returnValue: _i24.Future.value(), + returnValueForMissingStub: _i24.Future.value(), + ) as _i24.Future); @override int estimateTxFee({ required int? vSize, @@ -1425,7 +1438,7 @@ class MockBitcoinWallet extends _i1.Mock implements _i27.BitcoinWallet { }, )); @override - _i23.Future> fetchBuildTxData( + _i24.Future> fetchBuildTxData( List<_i18.UTXO>? utxosToUse) => (super.noSuchMethod( Invocation.method( @@ -1433,11 +1446,11 @@ class MockBitcoinWallet extends _i1.Mock implements _i27.BitcoinWallet { [utxosToUse], ), returnValue: - _i23.Future>.value(<_i29.SigningData>[]), - ) as _i23.Future>); + _i24.Future>.value(<_i30.SigningData>[]), + ) as _i24.Future>); @override - _i23.Future> buildTransaction({ - required List<_i29.SigningData>? utxoSigningData, + _i24.Future> buildTransaction({ + required List<_i30.SigningData>? utxoSigningData, required List? recipients, required List? satoshiAmounts, }) => @@ -1452,10 +1465,10 @@ class MockBitcoinWallet extends _i1.Mock implements _i27.BitcoinWallet { }, ), returnValue: - _i23.Future>.value({}), - ) as _i23.Future>); + _i24.Future>.value({}), + ) as _i24.Future>); @override - _i23.Future fullRescan( + _i24.Future fullRescan( int? maxUnusedAddressGap, int? maxNumberOfIndexesToCheck, ) => @@ -1467,11 +1480,11 @@ class MockBitcoinWallet extends _i1.Mock implements _i27.BitcoinWallet { maxNumberOfIndexesToCheck, ], ), - returnValue: _i23.Future.value(), - returnValueForMissingStub: _i23.Future.value(), - ) as _i23.Future); + returnValue: _i24.Future.value(), + returnValueForMissingStub: _i24.Future.value(), + ) as _i24.Future); @override - _i23.Future<_i15.Amount> estimateFeeFor( + _i24.Future<_i15.Amount> estimateFeeFor( _i15.Amount? amount, int? feeRate, ) => @@ -1483,7 +1496,7 @@ class MockBitcoinWallet extends _i1.Mock implements _i27.BitcoinWallet { feeRate, ], ), - returnValue: _i23.Future<_i15.Amount>.value(_FakeAmount_13( + returnValue: _i24.Future<_i15.Amount>.value(_FakeAmount_13( this, Invocation.method( #estimateFeeFor, @@ -1493,7 +1506,7 @@ class MockBitcoinWallet extends _i1.Mock implements _i27.BitcoinWallet { ], ), )), - ) as _i23.Future<_i15.Amount>); + ) as _i24.Future<_i15.Amount>); @override _i15.Amount roughFeeEstimate( int? inputCount, @@ -1522,32 +1535,32 @@ class MockBitcoinWallet extends _i1.Mock implements _i27.BitcoinWallet { ), ) as _i15.Amount); @override - _i23.Future<_i15.Amount> sweepAllEstimate(int? feeRate) => + _i24.Future<_i15.Amount> sweepAllEstimate(int? feeRate) => (super.noSuchMethod( Invocation.method( #sweepAllEstimate, [feeRate], ), - returnValue: _i23.Future<_i15.Amount>.value(_FakeAmount_13( + returnValue: _i24.Future<_i15.Amount>.value(_FakeAmount_13( this, Invocation.method( #sweepAllEstimate, [feeRate], ), )), - ) as _i23.Future<_i15.Amount>); + ) as _i24.Future<_i15.Amount>); @override - _i23.Future generateNewAddress() => (super.noSuchMethod( + _i24.Future generateNewAddress() => (super.noSuchMethod( Invocation.method( #generateNewAddress, [], ), - returnValue: _i23.Future.value(false), - ) as _i23.Future); + returnValue: _i24.Future.value(false), + ) as _i24.Future); @override void initCache( String? walletId, - _i22.Coin? coin, + _i23.Coin? coin, ) => super.noSuchMethod( Invocation.method( @@ -1560,14 +1573,14 @@ class MockBitcoinWallet extends _i1.Mock implements _i27.BitcoinWallet { returnValueForMissingStub: null, ); @override - _i23.Future updateCachedId(String? id) => (super.noSuchMethod( + _i24.Future updateCachedId(String? id) => (super.noSuchMethod( Invocation.method( #updateCachedId, [id], ), - returnValue: _i23.Future.value(), - returnValueForMissingStub: _i23.Future.value(), - ) as _i23.Future); + returnValue: _i24.Future.value(), + returnValueForMissingStub: _i24.Future.value(), + ) as _i24.Future); @override int getCachedChainHeight() => (super.noSuchMethod( Invocation.method( @@ -1577,14 +1590,14 @@ class MockBitcoinWallet extends _i1.Mock implements _i27.BitcoinWallet { returnValue: 0, ) as int); @override - _i23.Future updateCachedChainHeight(int? height) => (super.noSuchMethod( + _i24.Future updateCachedChainHeight(int? height) => (super.noSuchMethod( Invocation.method( #updateCachedChainHeight, [height], ), - returnValue: _i23.Future.value(), - returnValueForMissingStub: _i23.Future.value(), - ) as _i23.Future); + returnValue: _i24.Future.value(), + returnValueForMissingStub: _i24.Future.value(), + ) as _i24.Future); @override bool getCachedIsFavorite() => (super.noSuchMethod( Invocation.method( @@ -1594,15 +1607,15 @@ class MockBitcoinWallet extends _i1.Mock implements _i27.BitcoinWallet { returnValue: false, ) as bool); @override - _i23.Future updateCachedIsFavorite(bool? isFavorite) => + _i24.Future updateCachedIsFavorite(bool? isFavorite) => (super.noSuchMethod( Invocation.method( #updateCachedIsFavorite, [isFavorite], ), - returnValue: _i23.Future.value(), - returnValueForMissingStub: _i23.Future.value(), - ) as _i23.Future); + returnValue: _i24.Future.value(), + returnValueForMissingStub: _i24.Future.value(), + ) as _i24.Future); @override _i12.Balance getCachedBalance() => (super.noSuchMethod( Invocation.method( @@ -1618,15 +1631,15 @@ class MockBitcoinWallet extends _i1.Mock implements _i27.BitcoinWallet { ), ) as _i12.Balance); @override - _i23.Future updateCachedBalance(_i12.Balance? balance) => + _i24.Future updateCachedBalance(_i12.Balance? balance) => (super.noSuchMethod( Invocation.method( #updateCachedBalance, [balance], ), - returnValue: _i23.Future.value(), - returnValueForMissingStub: _i23.Future.value(), - ) as _i23.Future); + returnValue: _i24.Future.value(), + returnValueForMissingStub: _i24.Future.value(), + ) as _i24.Future); @override _i12.Balance getCachedBalanceSecondary() => (super.noSuchMethod( Invocation.method( @@ -1642,15 +1655,15 @@ class MockBitcoinWallet extends _i1.Mock implements _i27.BitcoinWallet { ), ) as _i12.Balance); @override - _i23.Future updateCachedBalanceSecondary(_i12.Balance? balance) => + _i24.Future updateCachedBalanceSecondary(_i12.Balance? balance) => (super.noSuchMethod( Invocation.method( #updateCachedBalanceSecondary, [balance], ), - returnValue: _i23.Future.value(), - returnValueForMissingStub: _i23.Future.value(), - ) as _i23.Future); + returnValue: _i24.Future.value(), + returnValueForMissingStub: _i24.Future.value(), + ) as _i24.Future); @override List getWalletTokenContractAddresses() => (super.noSuchMethod( Invocation.method( @@ -1660,16 +1673,16 @@ class MockBitcoinWallet extends _i1.Mock implements _i27.BitcoinWallet { returnValue: [], ) as List); @override - _i23.Future updateWalletTokenContractAddresses( + _i24.Future updateWalletTokenContractAddresses( List? contractAddresses) => (super.noSuchMethod( Invocation.method( #updateWalletTokenContractAddresses, [contractAddresses], ), - returnValue: _i23.Future.value(), - returnValueForMissingStub: _i23.Future.value(), - ) as _i23.Future); + returnValue: _i24.Future.value(), + returnValueForMissingStub: _i24.Future.value(), + ) as _i24.Future); @override void initWalletDB({_i13.MainDB? mockableOverride}) => super.noSuchMethod( Invocation.method( @@ -1680,11 +1693,11 @@ class MockBitcoinWallet extends _i1.Mock implements _i27.BitcoinWallet { returnValueForMissingStub: null, ); @override - _i23.Future<_i16.Tuple2<_i18.Transaction, _i18.Address>> parseTransaction( + _i24.Future<_i16.Tuple2<_i18.Transaction, _i18.Address>> parseTransaction( Map? txData, dynamic electrumxClient, List<_i18.Address>? myAddresses, - _i22.Coin? coin, + _i23.Coin? coin, int? minConfirms, String? walletId, ) => @@ -1701,7 +1714,7 @@ class MockBitcoinWallet extends _i1.Mock implements _i27.BitcoinWallet { ], ), returnValue: - _i23.Future<_i16.Tuple2<_i18.Transaction, _i18.Address>>.value( + _i24.Future<_i16.Tuple2<_i18.Transaction, _i18.Address>>.value( _FakeTuple2_14<_i18.Transaction, _i18.Address>( this, Invocation.method( @@ -1716,37 +1729,37 @@ class MockBitcoinWallet extends _i1.Mock implements _i27.BitcoinWallet { ], ), )), - ) as _i23.Future<_i16.Tuple2<_i18.Transaction, _i18.Address>>); + ) as _i24.Future<_i16.Tuple2<_i18.Transaction, _i18.Address>>); @override void initPaynymWalletInterface({ required String? walletId, required String? walletName, required _i14.NetworkType? network, - required _i22.Coin? coin, + required _i23.Coin? coin, required _i13.MainDB? db, required _i10.ElectrumX? electrumXClient, required _i7.SecureStorageInterface? secureStorage, required int? dustLimit, required int? dustLimitP2PKH, required int? minConfirms, - required _i23.Future Function()? getMnemonicString, - required _i23.Future Function()? getMnemonicPassphrase, - required _i23.Future Function()? getChainHeight, - required _i23.Future Function()? getCurrentChangeAddress, + required _i24.Future Function()? getMnemonicString, + required _i24.Future Function()? getMnemonicPassphrase, + required _i24.Future Function()? getChainHeight, + required _i24.Future Function()? getCurrentChangeAddress, required int Function({ required int feeRatePerKB, required int vSize, })? estimateTxFee, - required _i23.Future> Function({ + required _i24.Future> Function({ required String address, required _i15.Amount amount, Map? args, })? prepareSend, - required _i23.Future Function({required String address})? getTxCount, - required _i23.Future> Function(List<_i18.UTXO>)? + required _i24.Future Function({required String address})? getTxCount, + required _i24.Future> Function(List<_i18.UTXO>)? fetchBuildTxData, - required _i23.Future Function()? refresh, - required _i23.Future Function()? checkChangeAddressForTransactions, + required _i24.Future Function()? refresh, + required _i24.Future Function()? checkChangeAddressForTransactions, }) => super.noSuchMethod( Invocation.method( @@ -1779,21 +1792,21 @@ class MockBitcoinWallet extends _i1.Mock implements _i27.BitcoinWallet { returnValueForMissingStub: null, ); @override - _i23.Future<_i17.BIP32> getBip47BaseNode() => (super.noSuchMethod( + _i24.Future<_i17.BIP32> getBip47BaseNode() => (super.noSuchMethod( Invocation.method( #getBip47BaseNode, [], ), - returnValue: _i23.Future<_i17.BIP32>.value(_FakeBIP32_15( + returnValue: _i24.Future<_i17.BIP32>.value(_FakeBIP32_15( this, Invocation.method( #getBip47BaseNode, [], ), )), - ) as _i23.Future<_i17.BIP32>); + ) as _i24.Future<_i17.BIP32>); @override - _i23.Future<_i30.Uint8List> getPrivateKeyForPaynymReceivingAddress({ + _i24.Future<_i31.Uint8List> getPrivateKeyForPaynymReceivingAddress({ required String? paymentCodeString, required int? index, }) => @@ -1806,10 +1819,10 @@ class MockBitcoinWallet extends _i1.Mock implements _i27.BitcoinWallet { #index: index, }, ), - returnValue: _i23.Future<_i30.Uint8List>.value(_i30.Uint8List(0)), - ) as _i23.Future<_i30.Uint8List>); + returnValue: _i24.Future<_i31.Uint8List>.value(_i31.Uint8List(0)), + ) as _i24.Future<_i31.Uint8List>); @override - _i23.Future<_i18.Address> currentReceivingPaynymAddress({ + _i24.Future<_i18.Address> currentReceivingPaynymAddress({ required _i19.PaymentCode? sender, required bool? isSegwit, }) => @@ -1822,7 +1835,7 @@ class MockBitcoinWallet extends _i1.Mock implements _i27.BitcoinWallet { #isSegwit: isSegwit, }, ), - returnValue: _i23.Future<_i18.Address>.value(_FakeAddress_16( + returnValue: _i24.Future<_i18.Address>.value(_FakeAddress_16( this, Invocation.method( #currentReceivingPaynymAddress, @@ -1833,9 +1846,9 @@ class MockBitcoinWallet extends _i1.Mock implements _i27.BitcoinWallet { }, ), )), - ) as _i23.Future<_i18.Address>); + ) as _i24.Future<_i18.Address>); @override - _i23.Future checkCurrentPaynymReceivingAddressForTransactions({ + _i24.Future checkCurrentPaynymReceivingAddressForTransactions({ required _i19.PaymentCode? sender, required bool? isSegwit, }) => @@ -1848,42 +1861,42 @@ class MockBitcoinWallet extends _i1.Mock implements _i27.BitcoinWallet { #isSegwit: isSegwit, }, ), - returnValue: _i23.Future.value(), - returnValueForMissingStub: _i23.Future.value(), - ) as _i23.Future); + returnValue: _i24.Future.value(), + returnValueForMissingStub: _i24.Future.value(), + ) as _i24.Future); @override - _i23.Future checkAllCurrentReceivingPaynymAddressesForTransactions() => + _i24.Future checkAllCurrentReceivingPaynymAddressesForTransactions() => (super.noSuchMethod( Invocation.method( #checkAllCurrentReceivingPaynymAddressesForTransactions, [], ), - returnValue: _i23.Future.value(), - returnValueForMissingStub: _i23.Future.value(), - ) as _i23.Future); + returnValue: _i24.Future.value(), + returnValueForMissingStub: _i24.Future.value(), + ) as _i24.Future); @override - _i23.Future<_i17.BIP32> deriveNotificationBip32Node() => (super.noSuchMethod( + _i24.Future<_i17.BIP32> deriveNotificationBip32Node() => (super.noSuchMethod( Invocation.method( #deriveNotificationBip32Node, [], ), - returnValue: _i23.Future<_i17.BIP32>.value(_FakeBIP32_15( + returnValue: _i24.Future<_i17.BIP32>.value(_FakeBIP32_15( this, Invocation.method( #deriveNotificationBip32Node, [], ), )), - ) as _i23.Future<_i17.BIP32>); + ) as _i24.Future<_i17.BIP32>); @override - _i23.Future<_i19.PaymentCode> getPaymentCode({required bool? isSegwit}) => + _i24.Future<_i19.PaymentCode> getPaymentCode({required bool? isSegwit}) => (super.noSuchMethod( Invocation.method( #getPaymentCode, [], {#isSegwit: isSegwit}, ), - returnValue: _i23.Future<_i19.PaymentCode>.value(_FakePaymentCode_17( + returnValue: _i24.Future<_i19.PaymentCode>.value(_FakePaymentCode_17( this, Invocation.method( #getPaymentCode, @@ -1891,27 +1904,27 @@ class MockBitcoinWallet extends _i1.Mock implements _i27.BitcoinWallet { {#isSegwit: isSegwit}, ), )), - ) as _i23.Future<_i19.PaymentCode>); + ) as _i24.Future<_i19.PaymentCode>); @override - _i23.Future<_i30.Uint8List> signWithNotificationKey(_i30.Uint8List? data) => + _i24.Future<_i31.Uint8List> signWithNotificationKey(_i31.Uint8List? data) => (super.noSuchMethod( Invocation.method( #signWithNotificationKey, [data], ), - returnValue: _i23.Future<_i30.Uint8List>.value(_i30.Uint8List(0)), - ) as _i23.Future<_i30.Uint8List>); + returnValue: _i24.Future<_i31.Uint8List>.value(_i31.Uint8List(0)), + ) as _i24.Future<_i31.Uint8List>); @override - _i23.Future signStringWithNotificationKey(String? data) => + _i24.Future signStringWithNotificationKey(String? data) => (super.noSuchMethod( Invocation.method( #signStringWithNotificationKey, [data], ), - returnValue: _i23.Future.value(''), - ) as _i23.Future); + returnValue: _i24.Future.value(''), + ) as _i24.Future); @override - _i23.Future> preparePaymentCodeSend({ + _i24.Future> preparePaymentCodeSend({ required _i19.PaymentCode? paymentCode, required bool? isSegwit, required _i15.Amount? amount, @@ -1929,10 +1942,10 @@ class MockBitcoinWallet extends _i1.Mock implements _i27.BitcoinWallet { }, ), returnValue: - _i23.Future>.value({}), - ) as _i23.Future>); + _i24.Future>.value({}), + ) as _i24.Future>); @override - _i23.Future<_i18.Address> nextUnusedSendAddressFrom({ + _i24.Future<_i18.Address> nextUnusedSendAddressFrom({ required _i19.PaymentCode? pCode, required bool? isSegwit, required _i17.BIP32? privateKeyNode, @@ -1949,7 +1962,7 @@ class MockBitcoinWallet extends _i1.Mock implements _i27.BitcoinWallet { #startIndex: startIndex, }, ), - returnValue: _i23.Future<_i18.Address>.value(_FakeAddress_16( + returnValue: _i24.Future<_i18.Address>.value(_FakeAddress_16( this, Invocation.method( #nextUnusedSendAddressFrom, @@ -1962,9 +1975,9 @@ class MockBitcoinWallet extends _i1.Mock implements _i27.BitcoinWallet { }, ), )), - ) as _i23.Future<_i18.Address>); + ) as _i24.Future<_i18.Address>); @override - _i23.Future> prepareNotificationTx({ + _i24.Future> prepareNotificationTx({ required int? selectedTxFeeRate, required String? targetPaymentCodeString, int? additionalOutputs = 0, @@ -1982,10 +1995,10 @@ class MockBitcoinWallet extends _i1.Mock implements _i27.BitcoinWallet { }, ), returnValue: - _i23.Future>.value({}), - ) as _i23.Future>); + _i24.Future>.value({}), + ) as _i24.Future>); @override - _i23.Future broadcastNotificationTx( + _i24.Future broadcastNotificationTx( {required Map? preparedTx}) => (super.noSuchMethod( Invocation.method( @@ -1993,19 +2006,19 @@ class MockBitcoinWallet extends _i1.Mock implements _i27.BitcoinWallet { [], {#preparedTx: preparedTx}, ), - returnValue: _i23.Future.value(''), - ) as _i23.Future); + returnValue: _i24.Future.value(''), + ) as _i24.Future); @override - _i23.Future hasConnected(String? paymentCodeString) => + _i24.Future hasConnected(String? paymentCodeString) => (super.noSuchMethod( Invocation.method( #hasConnected, [paymentCodeString], ), - returnValue: _i23.Future.value(false), - ) as _i23.Future); + returnValue: _i24.Future.value(false), + ) as _i24.Future); @override - _i23.Future<_i19.PaymentCode?> unBlindedPaymentCodeFromTransaction( + _i24.Future<_i19.PaymentCode?> unBlindedPaymentCodeFromTransaction( {required _i18.Transaction? transaction}) => (super.noSuchMethod( Invocation.method( @@ -2013,10 +2026,10 @@ class MockBitcoinWallet extends _i1.Mock implements _i27.BitcoinWallet { [], {#transaction: transaction}, ), - returnValue: _i23.Future<_i19.PaymentCode?>.value(), - ) as _i23.Future<_i19.PaymentCode?>); + returnValue: _i24.Future<_i19.PaymentCode?>.value(), + ) as _i24.Future<_i19.PaymentCode?>); @override - _i23.Future<_i19.PaymentCode?> unBlindedPaymentCodeFromTransactionBad( + _i24.Future<_i19.PaymentCode?> unBlindedPaymentCodeFromTransactionBad( {required _i18.Transaction? transaction}) => (super.noSuchMethod( Invocation.method( @@ -2024,31 +2037,31 @@ class MockBitcoinWallet extends _i1.Mock implements _i27.BitcoinWallet { [], {#transaction: transaction}, ), - returnValue: _i23.Future<_i19.PaymentCode?>.value(), - ) as _i23.Future<_i19.PaymentCode?>); + returnValue: _i24.Future<_i19.PaymentCode?>.value(), + ) as _i24.Future<_i19.PaymentCode?>); @override - _i23.Future> + _i24.Future> getAllPaymentCodesFromNotificationTransactions() => (super.noSuchMethod( Invocation.method( #getAllPaymentCodesFromNotificationTransactions, [], ), returnValue: - _i23.Future>.value(<_i19.PaymentCode>[]), - ) as _i23.Future>); + _i24.Future>.value(<_i19.PaymentCode>[]), + ) as _i24.Future>); @override - _i23.Future checkForNotificationTransactionsTo( + _i24.Future checkForNotificationTransactionsTo( Set? otherCodeStrings) => (super.noSuchMethod( Invocation.method( #checkForNotificationTransactionsTo, [otherCodeStrings], ), - returnValue: _i23.Future.value(), - returnValueForMissingStub: _i23.Future.value(), - ) as _i23.Future); + returnValue: _i24.Future.value(), + returnValueForMissingStub: _i24.Future.value(), + ) as _i24.Future); @override - _i23.Future restoreAllHistory({ + _i24.Future restoreAllHistory({ required int? maxUnusedAddressGap, required int? maxNumberOfIndexesToCheck, required Set? paymentCodeStrings, @@ -2063,11 +2076,11 @@ class MockBitcoinWallet extends _i1.Mock implements _i27.BitcoinWallet { #paymentCodeStrings: paymentCodeStrings, }, ), - returnValue: _i23.Future.value(), - returnValueForMissingStub: _i23.Future.value(), - ) as _i23.Future); + returnValue: _i24.Future.value(), + returnValueForMissingStub: _i24.Future.value(), + ) as _i24.Future); @override - _i23.Future restoreHistoryWith({ + _i24.Future restoreHistoryWith({ required _i19.PaymentCode? other, required bool? checkSegwitAsWell, required int? maxUnusedAddressGap, @@ -2084,58 +2097,58 @@ class MockBitcoinWallet extends _i1.Mock implements _i27.BitcoinWallet { #maxNumberOfIndexesToCheck: maxNumberOfIndexesToCheck, }, ), - returnValue: _i23.Future.value(), - returnValueForMissingStub: _i23.Future.value(), - ) as _i23.Future); + returnValue: _i24.Future.value(), + returnValueForMissingStub: _i24.Future.value(), + ) as _i24.Future); @override - _i23.Future<_i18.Address> getMyNotificationAddress() => (super.noSuchMethod( + _i24.Future<_i18.Address> getMyNotificationAddress() => (super.noSuchMethod( Invocation.method( #getMyNotificationAddress, [], ), - returnValue: _i23.Future<_i18.Address>.value(_FakeAddress_16( + returnValue: _i24.Future<_i18.Address>.value(_FakeAddress_16( this, Invocation.method( #getMyNotificationAddress, [], ), )), - ) as _i23.Future<_i18.Address>); + ) as _i24.Future<_i18.Address>); @override - _i23.Future> lookupKey(String? paymentCodeString) => + _i24.Future> lookupKey(String? paymentCodeString) => (super.noSuchMethod( Invocation.method( #lookupKey, [paymentCodeString], ), - returnValue: _i23.Future>.value([]), - ) as _i23.Future>); + returnValue: _i24.Future>.value([]), + ) as _i24.Future>); @override - _i23.Future paymentCodeStringByKey(String? key) => + _i24.Future paymentCodeStringByKey(String? key) => (super.noSuchMethod( Invocation.method( #paymentCodeStringByKey, [key], ), - returnValue: _i23.Future.value(), - ) as _i23.Future); + returnValue: _i24.Future.value(), + ) as _i24.Future); @override - _i23.Future storeCode(String? paymentCodeString) => + _i24.Future storeCode(String? paymentCodeString) => (super.noSuchMethod( Invocation.method( #storeCode, [paymentCodeString], ), - returnValue: _i23.Future.value(''), - ) as _i23.Future); + returnValue: _i24.Future.value(''), + ) as _i24.Future); @override void initCoinControlInterface({ required String? walletId, required String? walletName, - required _i22.Coin? coin, + required _i23.Coin? coin, required _i13.MainDB? db, - required _i23.Future Function()? getChainHeight, - required _i23.Future Function(_i12.Balance)? refreshedBalanceCallback, + required _i24.Future Function()? getChainHeight, + required _i24.Future Function(_i12.Balance)? refreshedBalanceCallback, }) => super.noSuchMethod( Invocation.method( @@ -2153,22 +2166,22 @@ class MockBitcoinWallet extends _i1.Mock implements _i27.BitcoinWallet { returnValueForMissingStub: null, ); @override - _i23.Future refreshBalance({bool? notify = false}) => + _i24.Future refreshBalance({bool? notify = false}) => (super.noSuchMethod( Invocation.method( #refreshBalance, [], {#notify: notify}, ), - returnValue: _i23.Future.value(), - returnValueForMissingStub: _i23.Future.value(), - ) as _i23.Future); + returnValue: _i24.Future.value(), + returnValueForMissingStub: _i24.Future.value(), + ) as _i24.Future); } /// A class which mocks [LocaleService]. /// /// See the documentation for Mockito's code generation for more information. -class MockLocaleService extends _i1.Mock implements _i31.LocaleService { +class MockLocaleService extends _i1.Mock implements _i32.LocaleService { MockLocaleService() { _i1.throwOnMissingStub(this); } @@ -2184,17 +2197,17 @@ class MockLocaleService extends _i1.Mock implements _i31.LocaleService { returnValue: false, ) as bool); @override - _i23.Future loadLocale({bool? notify = true}) => (super.noSuchMethod( + _i24.Future loadLocale({bool? notify = true}) => (super.noSuchMethod( Invocation.method( #loadLocale, [], {#notify: notify}, ), - returnValue: _i23.Future.value(), - returnValueForMissingStub: _i23.Future.value(), - ) as _i23.Future); + returnValue: _i24.Future.value(), + returnValueForMissingStub: _i24.Future.value(), + ) as _i24.Future); @override - void addListener(_i25.VoidCallback? listener) => super.noSuchMethod( + void addListener(_i26.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #addListener, [listener], @@ -2202,7 +2215,7 @@ class MockLocaleService extends _i1.Mock implements _i31.LocaleService { returnValueForMissingStub: null, ); @override - void removeListener(_i25.VoidCallback? listener) => super.noSuchMethod( + void removeListener(_i26.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #removeListener, [listener], @@ -2230,11 +2243,27 @@ class MockLocaleService extends _i1.Mock implements _i31.LocaleService { /// A class which mocks [ThemeService]. /// /// See the documentation for Mockito's code generation for more information. -class MockThemeService extends _i1.Mock implements _i32.ThemeService { +class MockThemeService extends _i1.Mock implements _i33.ThemeService { MockThemeService() { _i1.throwOnMissingStub(this); } + @override + _i20.HTTP get client => (super.noSuchMethod( + Invocation.getter(#client), + returnValue: _FakeHTTP_18( + this, + Invocation.getter(#client), + ), + ) as _i20.HTTP); + @override + set client(_i20.HTTP? _client) => super.noSuchMethod( + Invocation.setter( + #client, + _client, + ), + returnValueForMissingStub: null, + ); @override _i13.MainDB get db => (super.noSuchMethod( Invocation.getter(#db), @@ -2244,10 +2273,10 @@ class MockThemeService extends _i1.Mock implements _i32.ThemeService { ), ) as _i13.MainDB); @override - List<_i33.StackTheme> get installedThemes => (super.noSuchMethod( + List<_i34.StackTheme> get installedThemes => (super.noSuchMethod( Invocation.getter(#installedThemes), - returnValue: <_i33.StackTheme>[], - ) as List<_i33.StackTheme>); + returnValue: <_i34.StackTheme>[], + ) as List<_i34.StackTheme>); @override void init(_i13.MainDB? db) => super.noSuchMethod( Invocation.method( @@ -2257,79 +2286,79 @@ class MockThemeService extends _i1.Mock implements _i32.ThemeService { returnValueForMissingStub: null, ); @override - _i23.Future install({required _i30.Uint8List? themeArchiveData}) => + _i24.Future install({required _i31.Uint8List? themeArchiveData}) => (super.noSuchMethod( Invocation.method( #install, [], {#themeArchiveData: themeArchiveData}, ), - returnValue: _i23.Future.value(), - returnValueForMissingStub: _i23.Future.value(), - ) as _i23.Future); + returnValue: _i24.Future.value(), + returnValueForMissingStub: _i24.Future.value(), + ) as _i24.Future); @override - _i23.Future remove({required String? themeId}) => (super.noSuchMethod( + _i24.Future remove({required String? themeId}) => (super.noSuchMethod( Invocation.method( #remove, [], {#themeId: themeId}, ), - returnValue: _i23.Future.value(), - returnValueForMissingStub: _i23.Future.value(), - ) as _i23.Future); + returnValue: _i24.Future.value(), + returnValueForMissingStub: _i24.Future.value(), + ) as _i24.Future); @override - _i23.Future checkDefaultThemesOnStartup() => (super.noSuchMethod( + _i24.Future checkDefaultThemesOnStartup() => (super.noSuchMethod( Invocation.method( #checkDefaultThemesOnStartup, [], ), - returnValue: _i23.Future.value(), - returnValueForMissingStub: _i23.Future.value(), - ) as _i23.Future); + returnValue: _i24.Future.value(), + returnValueForMissingStub: _i24.Future.value(), + ) as _i24.Future); @override - _i23.Future verifyInstalled({required String? themeId}) => + _i24.Future verifyInstalled({required String? themeId}) => (super.noSuchMethod( Invocation.method( #verifyInstalled, [], {#themeId: themeId}, ), - returnValue: _i23.Future.value(false), - ) as _i23.Future); + returnValue: _i24.Future.value(false), + ) as _i24.Future); @override - _i23.Future> fetchThemes() => + _i24.Future> fetchThemes() => (super.noSuchMethod( Invocation.method( #fetchThemes, [], ), - returnValue: _i23.Future>.value( - <_i32.StackThemeMetaData>[]), - ) as _i23.Future>); + returnValue: _i24.Future>.value( + <_i33.StackThemeMetaData>[]), + ) as _i24.Future>); @override - _i23.Future<_i30.Uint8List> fetchTheme( - {required _i32.StackThemeMetaData? themeMetaData}) => + _i24.Future<_i31.Uint8List> fetchTheme( + {required _i33.StackThemeMetaData? themeMetaData}) => (super.noSuchMethod( Invocation.method( #fetchTheme, [], {#themeMetaData: themeMetaData}, ), - returnValue: _i23.Future<_i30.Uint8List>.value(_i30.Uint8List(0)), - ) as _i23.Future<_i30.Uint8List>); + returnValue: _i24.Future<_i31.Uint8List>.value(_i31.Uint8List(0)), + ) as _i24.Future<_i31.Uint8List>); @override - _i33.StackTheme? getTheme({required String? themeId}) => + _i34.StackTheme? getTheme({required String? themeId}) => (super.noSuchMethod(Invocation.method( #getTheme, [], {#themeId: themeId}, - )) as _i33.StackTheme?); + )) as _i34.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 { +class MockPrefs extends _i1.Mock implements _i25.Prefs { MockPrefs() { _i1.throwOnMissingStub(this); } @@ -2385,12 +2414,12 @@ class MockPrefs extends _i1.Mock implements _i24.Prefs { returnValueForMissingStub: null, ); @override - _i34.SyncingType get syncType => (super.noSuchMethod( + _i35.SyncingType get syncType => (super.noSuchMethod( Invocation.getter(#syncType), - returnValue: _i34.SyncingType.currentWalletOnly, - ) as _i34.SyncingType); + returnValue: _i35.SyncingType.currentWalletOnly, + ) as _i35.SyncingType); @override - set syncType(_i34.SyncingType? syncType) => super.noSuchMethod( + set syncType(_i35.SyncingType? syncType) => super.noSuchMethod( Invocation.setter( #syncType, syncType, @@ -2502,6 +2531,19 @@ class MockPrefs extends _i1.Mock implements _i24.Prefs { returnValueForMissingStub: null, ); @override + bool get torKillSwitch => (super.noSuchMethod( + Invocation.getter(#torKillSwitch), + returnValue: false, + ) as bool); + @override + set torKillSwitch(bool? torKillswitch) => super.noSuchMethod( + Invocation.setter( + #torKillSwitch, + torKillswitch, + ), + returnValueForMissingStub: null, + ); + @override bool get showTestNetCoins => (super.noSuchMethod( Invocation.getter(#showTestNetCoins), returnValue: false, @@ -2536,12 +2578,12 @@ class MockPrefs extends _i1.Mock implements _i24.Prefs { returnValueForMissingStub: null, ); @override - _i35.BackupFrequencyType get backupFrequencyType => (super.noSuchMethod( + _i36.BackupFrequencyType get backupFrequencyType => (super.noSuchMethod( Invocation.getter(#backupFrequencyType), - returnValue: _i35.BackupFrequencyType.everyTenMinutes, - ) as _i35.BackupFrequencyType); + returnValue: _i36.BackupFrequencyType.everyTenMinutes, + ) as _i36.BackupFrequencyType); @override - set backupFrequencyType(_i35.BackupFrequencyType? backupFrequencyType) => + set backupFrequencyType(_i36.BackupFrequencyType? backupFrequencyType) => super.noSuchMethod( Invocation.setter( #backupFrequencyType, @@ -2674,66 +2716,79 @@ class MockPrefs extends _i1.Mock implements _i24.Prefs { returnValueForMissingStub: null, ); @override + bool get useTor => (super.noSuchMethod( + Invocation.getter(#useTor), + returnValue: false, + ) as bool); + @override + set useTor(bool? useTor) => super.noSuchMethod( + Invocation.setter( + #useTor, + useTor, + ), + returnValueForMissingStub: null, + ); + @override bool get hasListeners => (super.noSuchMethod( Invocation.getter(#hasListeners), returnValue: false, ) as bool); @override - _i23.Future init() => (super.noSuchMethod( + _i24.Future init() => (super.noSuchMethod( Invocation.method( #init, [], ), - returnValue: _i23.Future.value(), - returnValueForMissingStub: _i23.Future.value(), - ) as _i23.Future); + returnValue: _i24.Future.value(), + returnValueForMissingStub: _i24.Future.value(), + ) as _i24.Future); @override - _i23.Future incrementCurrentNotificationIndex() => (super.noSuchMethod( + _i24.Future incrementCurrentNotificationIndex() => (super.noSuchMethod( Invocation.method( #incrementCurrentNotificationIndex, [], ), - returnValue: _i23.Future.value(), - returnValueForMissingStub: _i23.Future.value(), - ) as _i23.Future); + returnValue: _i24.Future.value(), + returnValueForMissingStub: _i24.Future.value(), + ) as _i24.Future); @override - _i23.Future isExternalCallsSet() => (super.noSuchMethod( + _i24.Future isExternalCallsSet() => (super.noSuchMethod( Invocation.method( #isExternalCallsSet, [], ), - returnValue: _i23.Future.value(false), - ) as _i23.Future); + returnValue: _i24.Future.value(false), + ) as _i24.Future); @override - _i23.Future saveUserID(String? userId) => (super.noSuchMethod( + _i24.Future saveUserID(String? userId) => (super.noSuchMethod( Invocation.method( #saveUserID, [userId], ), - returnValue: _i23.Future.value(), - returnValueForMissingStub: _i23.Future.value(), - ) as _i23.Future); + returnValue: _i24.Future.value(), + returnValueForMissingStub: _i24.Future.value(), + ) as _i24.Future); @override - _i23.Future saveSignupEpoch(int? signupEpoch) => (super.noSuchMethod( + _i24.Future saveSignupEpoch(int? signupEpoch) => (super.noSuchMethod( Invocation.method( #saveSignupEpoch, [signupEpoch], ), - returnValue: _i23.Future.value(), - returnValueForMissingStub: _i23.Future.value(), - ) as _i23.Future); + returnValue: _i24.Future.value(), + returnValueForMissingStub: _i24.Future.value(), + ) as _i24.Future); @override - _i36.AmountUnit amountUnit(_i22.Coin? coin) => (super.noSuchMethod( + _i37.AmountUnit amountUnit(_i23.Coin? coin) => (super.noSuchMethod( Invocation.method( #amountUnit, [coin], ), - returnValue: _i36.AmountUnit.normal, - ) as _i36.AmountUnit); + returnValue: _i37.AmountUnit.normal, + ) as _i37.AmountUnit); @override void updateAmountUnit({ - required _i22.Coin? coin, - required _i36.AmountUnit? amountUnit, + required _i23.Coin? coin, + required _i37.AmountUnit? amountUnit, }) => super.noSuchMethod( Invocation.method( @@ -2747,7 +2802,7 @@ class MockPrefs extends _i1.Mock implements _i24.Prefs { returnValueForMissingStub: null, ); @override - int maxDecimals(_i22.Coin? coin) => (super.noSuchMethod( + int maxDecimals(_i23.Coin? coin) => (super.noSuchMethod( Invocation.method( #maxDecimals, [coin], @@ -2756,7 +2811,7 @@ class MockPrefs extends _i1.Mock implements _i24.Prefs { ) as int); @override void updateMaxDecimals({ - required _i22.Coin? coin, + required _i23.Coin? coin, required int? maxDecimals, }) => super.noSuchMethod( @@ -2771,7 +2826,7 @@ class MockPrefs extends _i1.Mock implements _i24.Prefs { returnValueForMissingStub: null, ); @override - void addListener(_i25.VoidCallback? listener) => super.noSuchMethod( + void addListener(_i26.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #addListener, [listener], @@ -2779,7 +2834,7 @@ class MockPrefs extends _i1.Mock implements _i24.Prefs { returnValueForMissingStub: null, ); @override - void removeListener(_i25.VoidCallback? listener) => super.noSuchMethod( + void removeListener(_i26.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #removeListener, [listener], @@ -2822,23 +2877,23 @@ class MockManager extends _i1.Mock implements _i6.Manager { returnValueForMissingStub: null, ); @override - _i20.CoinServiceAPI get wallet => (super.noSuchMethod( + _i21.CoinServiceAPI get wallet => (super.noSuchMethod( Invocation.getter(#wallet), - returnValue: _FakeCoinServiceAPI_18( + returnValue: _FakeCoinServiceAPI_19( this, Invocation.getter(#wallet), ), - ) as _i20.CoinServiceAPI); + ) as _i21.CoinServiceAPI); @override bool get hasBackgroundRefreshListener => (super.noSuchMethod( Invocation.getter(#hasBackgroundRefreshListener), returnValue: false, ) as bool); @override - _i22.Coin get coin => (super.noSuchMethod( + _i23.Coin get coin => (super.noSuchMethod( Invocation.getter(#coin), - returnValue: _i22.Coin.bitcoin, - ) as _i22.Coin); + returnValue: _i23.Coin.bitcoin, + ) as _i23.Coin); @override bool get isRefreshing => (super.noSuchMethod( Invocation.getter(#isRefreshing), @@ -2871,23 +2926,23 @@ class MockManager extends _i1.Mock implements _i6.Manager { returnValueForMissingStub: null, ); @override - _i23.Future<_i9.FeeObject> get fees => (super.noSuchMethod( + _i24.Future<_i9.FeeObject> get fees => (super.noSuchMethod( Invocation.getter(#fees), - returnValue: _i23.Future<_i9.FeeObject>.value(_FakeFeeObject_6( + returnValue: _i24.Future<_i9.FeeObject>.value(_FakeFeeObject_6( this, Invocation.getter(#fees), )), - ) as _i23.Future<_i9.FeeObject>); + ) as _i24.Future<_i9.FeeObject>); @override - _i23.Future get maxFee => (super.noSuchMethod( + _i24.Future get maxFee => (super.noSuchMethod( Invocation.getter(#maxFee), - returnValue: _i23.Future.value(0), - ) as _i23.Future); + returnValue: _i24.Future.value(0), + ) as _i24.Future); @override - _i23.Future get currentReceivingAddress => (super.noSuchMethod( + _i24.Future get currentReceivingAddress => (super.noSuchMethod( Invocation.getter(#currentReceivingAddress), - returnValue: _i23.Future.value(''), - ) as _i23.Future); + returnValue: _i24.Future.value(''), + ) as _i24.Future); @override _i12.Balance get balance => (super.noSuchMethod( Invocation.getter(#balance), @@ -2897,16 +2952,16 @@ class MockManager extends _i1.Mock implements _i6.Manager { ), ) as _i12.Balance); @override - _i23.Future> get transactions => (super.noSuchMethod( + _i24.Future> get transactions => (super.noSuchMethod( Invocation.getter(#transactions), returnValue: - _i23.Future>.value(<_i18.Transaction>[]), - ) as _i23.Future>); + _i24.Future>.value(<_i18.Transaction>[]), + ) as _i24.Future>); @override - _i23.Future> get utxos => (super.noSuchMethod( + _i24.Future> get utxos => (super.noSuchMethod( Invocation.getter(#utxos), - returnValue: _i23.Future>.value(<_i18.UTXO>[]), - ) as _i23.Future>); + returnValue: _i24.Future>.value(<_i18.UTXO>[]), + ) as _i24.Future>); @override set walletName(String? newName) => super.noSuchMethod( Invocation.setter( @@ -2926,15 +2981,15 @@ class MockManager extends _i1.Mock implements _i6.Manager { returnValue: '', ) as String); @override - _i23.Future> get mnemonic => (super.noSuchMethod( + _i24.Future> get mnemonic => (super.noSuchMethod( Invocation.getter(#mnemonic), - returnValue: _i23.Future>.value([]), - ) as _i23.Future>); + returnValue: _i24.Future>.value([]), + ) as _i24.Future>); @override - _i23.Future get mnemonicPassphrase => (super.noSuchMethod( + _i24.Future get mnemonicPassphrase => (super.noSuchMethod( Invocation.getter(#mnemonicPassphrase), - returnValue: _i23.Future.value(), - ) as _i23.Future); + returnValue: _i24.Future.value(), + ) as _i24.Future); @override bool get isConnected => (super.noSuchMethod( Invocation.getter(#isConnected), @@ -2981,24 +3036,24 @@ class MockManager extends _i1.Mock implements _i6.Manager { returnValue: false, ) as bool); @override - _i23.Future get xpub => (super.noSuchMethod( + _i24.Future get xpub => (super.noSuchMethod( Invocation.getter(#xpub), - returnValue: _i23.Future.value(''), - ) as _i23.Future); + returnValue: _i24.Future.value(''), + ) as _i24.Future); @override bool get hasListeners => (super.noSuchMethod( Invocation.getter(#hasListeners), returnValue: false, ) as bool); @override - _i23.Future updateNode(bool? shouldRefresh) => (super.noSuchMethod( + _i24.Future updateNode(bool? shouldRefresh) => (super.noSuchMethod( Invocation.method( #updateNode, [shouldRefresh], ), - returnValue: _i23.Future.value(), - returnValueForMissingStub: _i23.Future.value(), - ) as _i23.Future); + returnValue: _i24.Future.value(), + returnValueForMissingStub: _i24.Future.value(), + ) as _i24.Future); @override void dispose() => super.noSuchMethod( Invocation.method( @@ -3008,7 +3063,7 @@ class MockManager extends _i1.Mock implements _i6.Manager { returnValueForMissingStub: null, ); @override - _i23.Future> prepareSend({ + _i24.Future> prepareSend({ required String? address, required _i15.Amount? amount, Map? args, @@ -3024,27 +3079,27 @@ class MockManager extends _i1.Mock implements _i6.Manager { }, ), returnValue: - _i23.Future>.value({}), - ) as _i23.Future>); + _i24.Future>.value({}), + ) as _i24.Future>); @override - _i23.Future confirmSend({required Map? txData}) => + _i24.Future confirmSend({required Map? txData}) => (super.noSuchMethod( Invocation.method( #confirmSend, [], {#txData: txData}, ), - returnValue: _i23.Future.value(''), - ) as _i23.Future); + returnValue: _i24.Future.value(''), + ) as _i24.Future); @override - _i23.Future refresh() => (super.noSuchMethod( + _i24.Future refresh() => (super.noSuchMethod( Invocation.method( #refresh, [], ), - returnValue: _i23.Future.value(), - returnValueForMissingStub: _i23.Future.value(), - ) as _i23.Future); + returnValue: _i24.Future.value(), + returnValueForMissingStub: _i24.Future.value(), + ) as _i24.Future); @override bool validateAddress(String? address) => (super.noSuchMethod( Invocation.method( @@ -3054,33 +3109,35 @@ class MockManager extends _i1.Mock implements _i6.Manager { returnValue: false, ) as bool); @override - _i23.Future testNetworkConnection() => (super.noSuchMethod( + _i24.Future testNetworkConnection() => (super.noSuchMethod( Invocation.method( #testNetworkConnection, [], ), - returnValue: _i23.Future.value(false), - ) as _i23.Future); + returnValue: _i24.Future.value(false), + ) as _i24.Future); @override - _i23.Future initializeNew() => (super.noSuchMethod( + _i24.Future initializeNew( + ({String mnemonicPassphrase, int wordCount})? data) => + (super.noSuchMethod( Invocation.method( #initializeNew, - [], + [data], ), - returnValue: _i23.Future.value(), - returnValueForMissingStub: _i23.Future.value(), - ) as _i23.Future); + returnValue: _i24.Future.value(), + returnValueForMissingStub: _i24.Future.value(), + ) as _i24.Future); @override - _i23.Future initializeExisting() => (super.noSuchMethod( + _i24.Future initializeExisting() => (super.noSuchMethod( Invocation.method( #initializeExisting, [], ), - returnValue: _i23.Future.value(), - returnValueForMissingStub: _i23.Future.value(), - ) as _i23.Future); + returnValue: _i24.Future.value(), + returnValueForMissingStub: _i24.Future.value(), + ) as _i24.Future); @override - _i23.Future recoverFromMnemonic({ + _i24.Future recoverFromMnemonic({ required String? mnemonic, String? mnemonicPassphrase, required int? maxUnusedAddressGap, @@ -3099,20 +3156,20 @@ class MockManager extends _i1.Mock implements _i6.Manager { #height: height, }, ), - returnValue: _i23.Future.value(), - returnValueForMissingStub: _i23.Future.value(), - ) as _i23.Future); + returnValue: _i24.Future.value(), + returnValueForMissingStub: _i24.Future.value(), + ) as _i24.Future); @override - _i23.Future exitCurrentWallet() => (super.noSuchMethod( + _i24.Future exitCurrentWallet() => (super.noSuchMethod( Invocation.method( #exitCurrentWallet, [], ), - returnValue: _i23.Future.value(), - returnValueForMissingStub: _i23.Future.value(), - ) as _i23.Future); + returnValue: _i24.Future.value(), + returnValueForMissingStub: _i24.Future.value(), + ) as _i24.Future); @override - _i23.Future fullRescan( + _i24.Future fullRescan( int? maxUnusedAddressGap, int? maxNumberOfIndexesToCheck, ) => @@ -3124,11 +3181,11 @@ class MockManager extends _i1.Mock implements _i6.Manager { maxNumberOfIndexesToCheck, ], ), - returnValue: _i23.Future.value(), - returnValueForMissingStub: _i23.Future.value(), - ) as _i23.Future); + returnValue: _i24.Future.value(), + returnValueForMissingStub: _i24.Future.value(), + ) as _i24.Future); @override - _i23.Future<_i15.Amount> estimateFeeFor( + _i24.Future<_i15.Amount> estimateFeeFor( _i15.Amount? amount, int? feeRate, ) => @@ -3140,7 +3197,7 @@ class MockManager extends _i1.Mock implements _i6.Manager { feeRate, ], ), - returnValue: _i23.Future<_i15.Amount>.value(_FakeAmount_13( + returnValue: _i24.Future<_i15.Amount>.value(_FakeAmount_13( this, Invocation.method( #estimateFeeFor, @@ -3150,26 +3207,26 @@ class MockManager extends _i1.Mock implements _i6.Manager { ], ), )), - ) as _i23.Future<_i15.Amount>); + ) as _i24.Future<_i15.Amount>); @override - _i23.Future generateNewAddress() => (super.noSuchMethod( + _i24.Future generateNewAddress() => (super.noSuchMethod( Invocation.method( #generateNewAddress, [], ), - returnValue: _i23.Future.value(false), - ) as _i23.Future); + returnValue: _i24.Future.value(false), + ) as _i24.Future); @override - _i23.Future resetRescanOnOpen() => (super.noSuchMethod( + _i24.Future resetRescanOnOpen() => (super.noSuchMethod( Invocation.method( #resetRescanOnOpen, [], ), - returnValue: _i23.Future.value(), - returnValueForMissingStub: _i23.Future.value(), - ) as _i23.Future); + returnValue: _i24.Future.value(), + returnValueForMissingStub: _i24.Future.value(), + ) as _i24.Future); @override - void addListener(_i25.VoidCallback? listener) => super.noSuchMethod( + void addListener(_i26.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #addListener, [listener], @@ -3177,7 +3234,7 @@ class MockManager extends _i1.Mock implements _i6.Manager { returnValueForMissingStub: null, ); @override - void removeListener(_i25.VoidCallback? listener) => super.noSuchMethod( + void removeListener(_i26.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #removeListener, [listener], @@ -3197,7 +3254,7 @@ class MockManager extends _i1.Mock implements _i6.Manager { /// A class which mocks [CoinServiceAPI]. /// /// See the documentation for Mockito's code generation for more information. -class MockCoinServiceAPI extends _i1.Mock implements _i20.CoinServiceAPI { +class MockCoinServiceAPI extends _i1.Mock implements _i21.CoinServiceAPI { @override set onIsActiveWalletChanged(void Function(bool)? _onIsActiveWalletChanged) => super.noSuchMethod( @@ -3208,10 +3265,10 @@ class MockCoinServiceAPI extends _i1.Mock implements _i20.CoinServiceAPI { returnValueForMissingStub: null, ); @override - _i22.Coin get coin => (super.noSuchMethod( + _i23.Coin get coin => (super.noSuchMethod( Invocation.getter(#coin), - returnValue: _i22.Coin.bitcoin, - ) as _i22.Coin); + returnValue: _i23.Coin.bitcoin, + ) as _i23.Coin); @override bool get isRefreshing => (super.noSuchMethod( Invocation.getter(#isRefreshing), @@ -3244,23 +3301,23 @@ class MockCoinServiceAPI extends _i1.Mock implements _i20.CoinServiceAPI { returnValueForMissingStub: null, ); @override - _i23.Future<_i9.FeeObject> get fees => (super.noSuchMethod( + _i24.Future<_i9.FeeObject> get fees => (super.noSuchMethod( Invocation.getter(#fees), - returnValue: _i23.Future<_i9.FeeObject>.value(_FakeFeeObject_6( + returnValue: _i24.Future<_i9.FeeObject>.value(_FakeFeeObject_6( this, Invocation.getter(#fees), )), - ) as _i23.Future<_i9.FeeObject>); + ) as _i24.Future<_i9.FeeObject>); @override - _i23.Future get maxFee => (super.noSuchMethod( + _i24.Future get maxFee => (super.noSuchMethod( Invocation.getter(#maxFee), - returnValue: _i23.Future.value(0), - ) as _i23.Future); + returnValue: _i24.Future.value(0), + ) as _i24.Future); @override - _i23.Future get currentReceivingAddress => (super.noSuchMethod( + _i24.Future get currentReceivingAddress => (super.noSuchMethod( Invocation.getter(#currentReceivingAddress), - returnValue: _i23.Future.value(''), - ) as _i23.Future); + returnValue: _i24.Future.value(''), + ) as _i24.Future); @override _i12.Balance get balance => (super.noSuchMethod( Invocation.getter(#balance), @@ -3270,16 +3327,16 @@ class MockCoinServiceAPI extends _i1.Mock implements _i20.CoinServiceAPI { ), ) as _i12.Balance); @override - _i23.Future> get transactions => (super.noSuchMethod( + _i24.Future> get transactions => (super.noSuchMethod( Invocation.getter(#transactions), returnValue: - _i23.Future>.value(<_i18.Transaction>[]), - ) as _i23.Future>); + _i24.Future>.value(<_i18.Transaction>[]), + ) as _i24.Future>); @override - _i23.Future> get utxos => (super.noSuchMethod( + _i24.Future> get utxos => (super.noSuchMethod( Invocation.getter(#utxos), - returnValue: _i23.Future>.value(<_i18.UTXO>[]), - ) as _i23.Future>); + returnValue: _i24.Future>.value(<_i18.UTXO>[]), + ) as _i24.Future>); @override set walletName(String? newName) => super.noSuchMethod( Invocation.setter( @@ -3299,20 +3356,20 @@ class MockCoinServiceAPI extends _i1.Mock implements _i20.CoinServiceAPI { returnValue: '', ) as String); @override - _i23.Future> get mnemonic => (super.noSuchMethod( + _i24.Future> get mnemonic => (super.noSuchMethod( Invocation.getter(#mnemonic), - returnValue: _i23.Future>.value([]), - ) as _i23.Future>); + returnValue: _i24.Future>.value([]), + ) as _i24.Future>); @override - _i23.Future get mnemonicString => (super.noSuchMethod( + _i24.Future get mnemonicString => (super.noSuchMethod( Invocation.getter(#mnemonicString), - returnValue: _i23.Future.value(), - ) as _i23.Future); + returnValue: _i24.Future.value(), + ) as _i24.Future); @override - _i23.Future get mnemonicPassphrase => (super.noSuchMethod( + _i24.Future get mnemonicPassphrase => (super.noSuchMethod( Invocation.getter(#mnemonicPassphrase), - returnValue: _i23.Future.value(), - ) as _i23.Future); + returnValue: _i24.Future.value(), + ) as _i24.Future); @override bool get hasCalledExit => (super.noSuchMethod( Invocation.getter(#hasCalledExit), @@ -3329,7 +3386,7 @@ class MockCoinServiceAPI extends _i1.Mock implements _i20.CoinServiceAPI { returnValue: 0, ) as int); @override - _i23.Future> prepareSend({ + _i24.Future> prepareSend({ required String? address, required _i15.Amount? amount, Map? args, @@ -3345,36 +3402,36 @@ class MockCoinServiceAPI extends _i1.Mock implements _i20.CoinServiceAPI { }, ), returnValue: - _i23.Future>.value({}), - ) as _i23.Future>); + _i24.Future>.value({}), + ) as _i24.Future>); @override - _i23.Future confirmSend({required Map? txData}) => + _i24.Future confirmSend({required Map? txData}) => (super.noSuchMethod( Invocation.method( #confirmSend, [], {#txData: txData}, ), - returnValue: _i23.Future.value(''), - ) as _i23.Future); + returnValue: _i24.Future.value(''), + ) as _i24.Future); @override - _i23.Future refresh() => (super.noSuchMethod( + _i24.Future refresh() => (super.noSuchMethod( Invocation.method( #refresh, [], ), - returnValue: _i23.Future.value(), - returnValueForMissingStub: _i23.Future.value(), - ) as _i23.Future); + returnValue: _i24.Future.value(), + returnValueForMissingStub: _i24.Future.value(), + ) as _i24.Future); @override - _i23.Future updateNode(bool? shouldRefresh) => (super.noSuchMethod( + _i24.Future updateNode(bool? shouldRefresh) => (super.noSuchMethod( Invocation.method( #updateNode, [shouldRefresh], ), - returnValue: _i23.Future.value(), - returnValueForMissingStub: _i23.Future.value(), - ) as _i23.Future); + returnValue: _i24.Future.value(), + returnValueForMissingStub: _i24.Future.value(), + ) as _i24.Future); @override bool validateAddress(String? address) => (super.noSuchMethod( Invocation.method( @@ -3384,15 +3441,15 @@ class MockCoinServiceAPI extends _i1.Mock implements _i20.CoinServiceAPI { returnValue: false, ) as bool); @override - _i23.Future testNetworkConnection() => (super.noSuchMethod( + _i24.Future testNetworkConnection() => (super.noSuchMethod( Invocation.method( #testNetworkConnection, [], ), - returnValue: _i23.Future.value(false), - ) as _i23.Future); + returnValue: _i24.Future.value(false), + ) as _i24.Future); @override - _i23.Future recoverFromMnemonic({ + _i24.Future recoverFromMnemonic({ required String? mnemonic, String? mnemonicPassphrase, required int? maxUnusedAddressGap, @@ -3411,38 +3468,40 @@ class MockCoinServiceAPI extends _i1.Mock implements _i20.CoinServiceAPI { #height: height, }, ), - returnValue: _i23.Future.value(), - returnValueForMissingStub: _i23.Future.value(), - ) as _i23.Future); + returnValue: _i24.Future.value(), + returnValueForMissingStub: _i24.Future.value(), + ) as _i24.Future); @override - _i23.Future initializeNew() => (super.noSuchMethod( + _i24.Future initializeNew( + ({String mnemonicPassphrase, int wordCount})? data) => + (super.noSuchMethod( Invocation.method( #initializeNew, - [], + [data], ), - returnValue: _i23.Future.value(), - returnValueForMissingStub: _i23.Future.value(), - ) as _i23.Future); + returnValue: _i24.Future.value(), + returnValueForMissingStub: _i24.Future.value(), + ) as _i24.Future); @override - _i23.Future initializeExisting() => (super.noSuchMethod( + _i24.Future initializeExisting() => (super.noSuchMethod( Invocation.method( #initializeExisting, [], ), - returnValue: _i23.Future.value(), - returnValueForMissingStub: _i23.Future.value(), - ) as _i23.Future); + returnValue: _i24.Future.value(), + returnValueForMissingStub: _i24.Future.value(), + ) as _i24.Future); @override - _i23.Future exit() => (super.noSuchMethod( + _i24.Future exit() => (super.noSuchMethod( Invocation.method( #exit, [], ), - returnValue: _i23.Future.value(), - returnValueForMissingStub: _i23.Future.value(), - ) as _i23.Future); + returnValue: _i24.Future.value(), + returnValueForMissingStub: _i24.Future.value(), + ) as _i24.Future); @override - _i23.Future fullRescan( + _i24.Future fullRescan( int? maxUnusedAddressGap, int? maxNumberOfIndexesToCheck, ) => @@ -3454,11 +3513,11 @@ class MockCoinServiceAPI extends _i1.Mock implements _i20.CoinServiceAPI { maxNumberOfIndexesToCheck, ], ), - returnValue: _i23.Future.value(), - returnValueForMissingStub: _i23.Future.value(), - ) as _i23.Future); + returnValue: _i24.Future.value(), + returnValueForMissingStub: _i24.Future.value(), + ) as _i24.Future); @override - _i23.Future<_i15.Amount> estimateFeeFor( + _i24.Future<_i15.Amount> estimateFeeFor( _i15.Amount? amount, int? feeRate, ) => @@ -3470,7 +3529,7 @@ class MockCoinServiceAPI extends _i1.Mock implements _i20.CoinServiceAPI { feeRate, ], ), - returnValue: _i23.Future<_i15.Amount>.value(_FakeAmount_13( + returnValue: _i24.Future<_i15.Amount>.value(_FakeAmount_13( this, Invocation.method( #estimateFeeFor, @@ -3480,23 +3539,23 @@ class MockCoinServiceAPI extends _i1.Mock implements _i20.CoinServiceAPI { ], ), )), - ) as _i23.Future<_i15.Amount>); + ) as _i24.Future<_i15.Amount>); @override - _i23.Future generateNewAddress() => (super.noSuchMethod( + _i24.Future generateNewAddress() => (super.noSuchMethod( Invocation.method( #generateNewAddress, [], ), - returnValue: _i23.Future.value(false), - ) as _i23.Future); + returnValue: _i24.Future.value(false), + ) as _i24.Future); @override - _i23.Future updateSentCachedTxData(Map? txData) => + _i24.Future updateSentCachedTxData(Map? txData) => (super.noSuchMethod( Invocation.method( #updateSentCachedTxData, [txData], ), - returnValue: _i23.Future.value(), - returnValueForMissingStub: _i23.Future.value(), - ) as _i23.Future); + returnValue: _i24.Future.value(), + returnValueForMissingStub: _i24.Future.value(), + ) as _i24.Future); } diff --git a/test/price_test.dart b/test/price_test.dart index 6741d5445..dc7aaeb9e 100644 --- a/test/price_test.dart +++ b/test/price_test.dart @@ -1,17 +1,18 @@ +import 'dart:convert'; import 'dart:io'; import 'package:flutter_test/flutter_test.dart'; import 'package:hive/hive.dart'; import 'package:hive_test/hive_test.dart'; -import 'package:http/http.dart'; import 'package:mockito/annotations.dart'; import 'package:mockito/mockito.dart'; import 'package:stackwallet/db/hive/db.dart'; +import 'package:stackwallet/networking/http.dart'; import 'package:stackwallet/services/price.dart'; import 'price_test.mocks.dart'; -@GenerateMocks([Client]) +@GenerateMocks([HTTP]) void main() { setUp(() async { await setUpTestHive(); @@ -22,74 +23,77 @@ void main() { }); test("getPricesAnd24hChange fetch", () async { - final client = MockClient(); + final client = MockHTTP(); when(client.get( - Uri.parse( + proxyInfo: null, + url: 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,banano,stellar&order=market_cap_desc&per_page=50" + ",namecoin,wownero,ethereum,particl,nano,banano,stellar,tezos" + "&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"}]', + utf8.encode( + '[{"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); @@ -114,6 +118,7 @@ void main() { 'Coin.nano: [0, 0.0], ' 'Coin.particl: [0, 0.0], ' 'Coin.stellar: [0, 0.0], ' + 'Coin.tezos: [0, 0.0], ' 'Coin.wownero: [0, 0.0], ' 'Coin.bitcoinTestNet: [0, 0.0], ' 'Coin.bitcoincashTestnet: [0, 0.0], ' @@ -124,10 +129,12 @@ void main() { '}', ); verify(client.get( - Uri.parse( + proxyInfo: null, + url: 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,banano,stellar" + ",tezos" "&order=market_cap_desc&per_page=50&page=1&sparkline=false", ), headers: {'Content-Type': 'application/json'})).called(1); @@ -136,74 +143,77 @@ void main() { }); test("cached price fetch", () async { - final client = MockClient(); + final client = MockHTTP(); when(client.get( - Uri.parse( + proxyInfo: null, + url: 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,banano,stellar" + ",tezos" "&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"}]', + utf8.encode( + '[{"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); @@ -228,7 +238,10 @@ void main() { 'Coin.firo: [0.0001096, -0.89304], ' 'Coin.litecoin: [0, 0.0], ' 'Coin.namecoin: [0, 0.0], ' - 'Coin.nano: [0, 0.0], Coin.particl: [0, 0.0], Coin.stellar: [0, 0.0], ' + 'Coin.nano: [0, 0.0], ' + 'Coin.particl: [0, 0.0], ' + 'Coin.stellar: [0, 0.0], ' + 'Coin.tezos: [0, 0.0], ' 'Coin.wownero: [0, 0.0], ' 'Coin.bitcoinTestNet: [0, 0.0], ' 'Coin.bitcoincashTestnet: [0, 0.0], Coin.dogecoinTestNet: [0, 0.0], ' @@ -240,10 +253,12 @@ void main() { // verify only called once during filling of cache verify(client.get( - Uri.parse( + proxyInfo: null, + url: 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,banano,stellar" + ",tezos" "&order=market_cap_desc&per_page=50&page=1&sparkline=false"), headers: {'Content-Type': 'application/json'})).called(1); @@ -251,75 +266,78 @@ void main() { }); test("response parse failure", () async { - final client = MockClient(); + final client = MockHTTP(); when(client.get( - Uri.parse( + proxyInfo: null, + url: 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,banano,stellar" + ",tezos" "&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"}]', + utf8.encode( + '[{"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); @@ -343,6 +361,7 @@ void main() { 'Coin.nano: [0, 0.0], ' 'Coin.particl: [0, 0.0], ' 'Coin.stellar: [0, 0.0], ' + 'Coin.tezos: [0, 0.0], ' 'Coin.wownero: [0, 0.0], ' 'Coin.bitcoinTestNet: [0, 0.0], ' 'Coin.bitcoincashTestnet: [0, 0.0], ' @@ -355,13 +374,15 @@ void main() { }); test("no internet available", () async { - final client = MockClient(); + final client = MockHTTP(); when(client.get( - Uri.parse( + proxyInfo: null, + url: 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,banano,stellar" + ",tezos" "&order=market_cap_desc&per_page=50&page=1&sparkline=false"), headers: { 'Content-Type': 'application/json' @@ -390,6 +411,7 @@ void main() { 'Coin.nano: [0, 0.0], ' 'Coin.particl: [0, 0.0], ' 'Coin.stellar: [0, 0.0], ' + 'Coin.tezos: [0, 0.0], ' 'Coin.wownero: [0, 0.0], ' 'Coin.bitcoinTestNet: [0, 0.0], ' 'Coin.bitcoincashTestnet: [0, 0.0], ' diff --git a/test/price_test.mocks.dart b/test/price_test.mocks.dart index 8c38f59f9..59b90851e 100644 --- a/test/price_test.mocks.dart +++ b/test/price_test.mocks.dart @@ -4,11 +4,11 @@ // ignore_for_file: no_leading_underscores_for_library_prefixes import 'dart:async' as _i3; -import 'dart:convert' as _i4; -import 'dart:typed_data' as _i5; +import 'dart:convert' as _i5; +import 'dart:io' as _i4; -import 'package:http/http.dart' as _i2; import 'package:mockito/mockito.dart' as _i1; +import 'package:stackwallet/networking/http.dart' as _i2; // ignore_for_file: type=lint // ignore_for_file: avoid_redundant_argument_values @@ -31,233 +31,76 @@ class _FakeResponse_0 extends _i1.SmartFake implements _i2.Response { ); } -class _FakeStreamedResponse_1 extends _i1.SmartFake - implements _i2.StreamedResponse { - _FakeStreamedResponse_1( - Object parent, - Invocation parentInvocation, - ) : super( - parent, - parentInvocation, - ); -} - -/// A class which mocks [Client]. +/// A class which mocks [HTTP]. /// /// See the documentation for Mockito's code generation for more information. -class MockClient extends _i1.Mock implements _i2.Client { - MockClient() { +class MockHTTP extends _i1.Mock implements _i2.HTTP { + MockHTTP() { _i1.throwOnMissingStub(this); } @override - _i3.Future<_i2.Response> head( - Uri? url, { - Map? headers, - }) => - (super.noSuchMethod( - Invocation.method( - #head, - [url], - {#headers: headers}, - ), - returnValue: _i3.Future<_i2.Response>.value(_FakeResponse_0( - this, - Invocation.method( - #head, - [url], - {#headers: headers}, - ), - )), - ) as _i3.Future<_i2.Response>); - @override - _i3.Future<_i2.Response> get( - Uri? url, { + _i3.Future<_i2.Response> get({ + required Uri? url, Map? headers, + required ({_i4.InternetAddress host, int port})? proxyInfo, }) => (super.noSuchMethod( Invocation.method( #get, - [url], - {#headers: headers}, + [], + { + #url: url, + #headers: headers, + #proxyInfo: proxyInfo, + }, ), returnValue: _i3.Future<_i2.Response>.value(_FakeResponse_0( this, Invocation.method( #get, - [url], - {#headers: headers}, + [], + { + #url: url, + #headers: headers, + #proxyInfo: proxyInfo, + }, ), )), ) as _i3.Future<_i2.Response>); @override - _i3.Future<_i2.Response> post( - Uri? url, { + _i3.Future<_i2.Response> post({ + required Uri? url, Map? headers, Object? body, - _i4.Encoding? encoding, + _i5.Encoding? encoding, + required ({_i4.InternetAddress host, int port})? proxyInfo, }) => (super.noSuchMethod( Invocation.method( #post, - [url], + [], { + #url: url, #headers: headers, #body: body, #encoding: encoding, + #proxyInfo: proxyInfo, }, ), returnValue: _i3.Future<_i2.Response>.value(_FakeResponse_0( this, Invocation.method( #post, - [url], + [], { + #url: url, #headers: headers, #body: body, #encoding: encoding, + #proxyInfo: proxyInfo, }, ), )), ) as _i3.Future<_i2.Response>); - @override - _i3.Future<_i2.Response> put( - Uri? url, { - Map? headers, - Object? body, - _i4.Encoding? encoding, - }) => - (super.noSuchMethod( - Invocation.method( - #put, - [url], - { - #headers: headers, - #body: body, - #encoding: encoding, - }, - ), - returnValue: _i3.Future<_i2.Response>.value(_FakeResponse_0( - this, - Invocation.method( - #put, - [url], - { - #headers: headers, - #body: body, - #encoding: encoding, - }, - ), - )), - ) as _i3.Future<_i2.Response>); - @override - _i3.Future<_i2.Response> patch( - Uri? url, { - Map? headers, - Object? body, - _i4.Encoding? encoding, - }) => - (super.noSuchMethod( - Invocation.method( - #patch, - [url], - { - #headers: headers, - #body: body, - #encoding: encoding, - }, - ), - returnValue: _i3.Future<_i2.Response>.value(_FakeResponse_0( - this, - Invocation.method( - #patch, - [url], - { - #headers: headers, - #body: body, - #encoding: encoding, - }, - ), - )), - ) as _i3.Future<_i2.Response>); - @override - _i3.Future<_i2.Response> delete( - Uri? url, { - Map? headers, - Object? body, - _i4.Encoding? encoding, - }) => - (super.noSuchMethod( - Invocation.method( - #delete, - [url], - { - #headers: headers, - #body: body, - #encoding: encoding, - }, - ), - returnValue: _i3.Future<_i2.Response>.value(_FakeResponse_0( - this, - Invocation.method( - #delete, - [url], - { - #headers: headers, - #body: body, - #encoding: encoding, - }, - ), - )), - ) as _i3.Future<_i2.Response>); - @override - _i3.Future read( - Uri? url, { - Map? headers, - }) => - (super.noSuchMethod( - Invocation.method( - #read, - [url], - {#headers: headers}, - ), - returnValue: _i3.Future.value(''), - ) as _i3.Future); - @override - _i3.Future<_i5.Uint8List> readBytes( - Uri? url, { - Map? headers, - }) => - (super.noSuchMethod( - Invocation.method( - #readBytes, - [url], - {#headers: headers}, - ), - returnValue: _i3.Future<_i5.Uint8List>.value(_i5.Uint8List(0)), - ) as _i3.Future<_i5.Uint8List>); - @override - _i3.Future<_i2.StreamedResponse> send(_i2.BaseRequest? request) => - (super.noSuchMethod( - Invocation.method( - #send, - [request], - ), - returnValue: - _i3.Future<_i2.StreamedResponse>.value(_FakeStreamedResponse_1( - this, - Invocation.method( - #send, - [request], - ), - )), - ) as _i3.Future<_i2.StreamedResponse>); - @override - void close() => super.noSuchMethod( - Invocation.method( - #close, - [], - ), - returnValueForMissingStub: null, - ); } 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 5edc4c538..29318d2c5 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 @@ -492,10 +492,12 @@ class MockManager extends _i1.Mock implements _i12.Manager { returnValue: _i9.Future.value(false), ) as _i9.Future); @override - _i9.Future initializeNew() => (super.noSuchMethod( + _i9.Future initializeNew( + ({String mnemonicPassphrase, int wordCount})? data) => + (super.noSuchMethod( Invocation.method( #initializeNew, - [], + [data], ), returnValue: _i9.Future.value(), returnValueForMissingStub: _i9.Future.value(), 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 a84bb6a51..cd9108d2a 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 @@ -453,10 +453,12 @@ class MockManager extends _i1.Mock implements _i10.Manager { returnValue: _i8.Future.value(false), ) as _i8.Future); @override - _i8.Future initializeNew() => (super.noSuchMethod( + _i8.Future initializeNew( + ({String mnemonicPassphrase, int wordCount})? data) => + (super.noSuchMethod( Invocation.method( #initializeNew, - [], + [data], ), returnValue: _i8.Future.value(), returnValueForMissingStub: _i8.Future.value(), 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 f44df83ca..65ab3b1f2 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 @@ -451,10 +451,12 @@ class MockManager extends _i1.Mock implements _i10.Manager { returnValue: _i8.Future.value(false), ) as _i8.Future); @override - _i8.Future initializeNew() => (super.noSuchMethod( + _i8.Future initializeNew( + ({String mnemonicPassphrase, int wordCount})? data) => + (super.noSuchMethod( Invocation.method( #initializeNew, - [], + [data], ), returnValue: _i8.Future.value(), returnValueForMissingStub: _i8.Future.value(), diff --git a/test/screen_tests/exchange/exchange_view_test.mocks.dart b/test/screen_tests/exchange/exchange_view_test.mocks.dart index 7b55ab9e0..5e23da459 100644 --- a/test/screen_tests/exchange/exchange_view_test.mocks.dart +++ b/test/screen_tests/exchange/exchange_view_test.mocks.dart @@ -3,11 +3,10 @@ // Do not manually edit this file. // ignore_for_file: no_leading_underscores_for_library_prefixes -import 'dart:async' as _i6; -import 'dart:ui' as _i9; +import 'dart:async' as _i7; +import 'dart:ui' as _i10; import 'package:decimal/decimal.dart' as _i16; -import 'package:http/http.dart' as _i14; import 'package:mockito/mockito.dart' as _i1; import 'package:stackwallet/models/exchange/change_now/cn_exchange_estimate.dart' as _i19; @@ -22,19 +21,20 @@ import 'package:stackwallet/models/exchange/response_objects/fixed_rate_market.d import 'package:stackwallet/models/exchange/response_objects/range.dart' as _i17; import 'package:stackwallet/models/exchange/response_objects/trade.dart' - as _i11; + as _i12; import 'package:stackwallet/models/isar/exchange_cache/currency.dart' as _i15; import 'package:stackwallet/models/isar/exchange_cache/pair.dart' as _i23; +import 'package:stackwallet/networking/http.dart' as _i2; import 'package:stackwallet/services/exchange/change_now/change_now_api.dart' - as _i13; -import 'package:stackwallet/services/exchange/exchange_response.dart' as _i2; -import 'package:stackwallet/services/trade_notes_service.dart' as _i12; -import 'package:stackwallet/services/trade_service.dart' as _i10; -import 'package:stackwallet/utilities/amount/amount_unit.dart' as _i7; -import 'package:stackwallet/utilities/enums/backup_frequency_type.dart' as _i5; -import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i8; -import 'package:stackwallet/utilities/enums/sync_type_enum.dart' as _i4; -import 'package:stackwallet/utilities/prefs.dart' as _i3; + as _i14; +import 'package:stackwallet/services/exchange/exchange_response.dart' as _i3; +import 'package:stackwallet/services/trade_notes_service.dart' as _i13; +import 'package:stackwallet/services/trade_service.dart' as _i11; +import 'package:stackwallet/utilities/amount/amount_unit.dart' as _i8; +import 'package:stackwallet/utilities/enums/backup_frequency_type.dart' as _i6; +import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i9; +import 'package:stackwallet/utilities/enums/sync_type_enum.dart' as _i5; +import 'package:stackwallet/utilities/prefs.dart' as _i4; // ignore_for_file: type=lint // ignore_for_file: avoid_redundant_argument_values @@ -47,9 +47,19 @@ import 'package:stackwallet/utilities/prefs.dart' as _i3; // ignore_for_file: camel_case_types // ignore_for_file: subtype_of_sealed_class -class _FakeExchangeResponse_0 extends _i1.SmartFake - implements _i2.ExchangeResponse { - _FakeExchangeResponse_0( +class _FakeHTTP_0 extends _i1.SmartFake implements _i2.HTTP { + _FakeHTTP_0( + Object parent, + Invocation parentInvocation, + ) : super( + parent, + parentInvocation, + ); +} + +class _FakeExchangeResponse_1 extends _i1.SmartFake + implements _i3.ExchangeResponse { + _FakeExchangeResponse_1( Object parent, Invocation parentInvocation, ) : super( @@ -61,7 +71,7 @@ class _FakeExchangeResponse_0 extends _i1.SmartFake /// A class which mocks [Prefs]. /// /// See the documentation for Mockito's code generation for more information. -class MockPrefs extends _i1.Mock implements _i3.Prefs { +class MockPrefs extends _i1.Mock implements _i4.Prefs { MockPrefs() { _i1.throwOnMissingStub(this); } @@ -117,12 +127,12 @@ class MockPrefs extends _i1.Mock implements _i3.Prefs { returnValueForMissingStub: null, ); @override - _i4.SyncingType get syncType => (super.noSuchMethod( + _i5.SyncingType get syncType => (super.noSuchMethod( Invocation.getter(#syncType), - returnValue: _i4.SyncingType.currentWalletOnly, - ) as _i4.SyncingType); + returnValue: _i5.SyncingType.currentWalletOnly, + ) as _i5.SyncingType); @override - set syncType(_i4.SyncingType? syncType) => super.noSuchMethod( + set syncType(_i5.SyncingType? syncType) => super.noSuchMethod( Invocation.setter( #syncType, syncType, @@ -234,6 +244,19 @@ class MockPrefs extends _i1.Mock implements _i3.Prefs { returnValueForMissingStub: null, ); @override + bool get torKillSwitch => (super.noSuchMethod( + Invocation.getter(#torKillSwitch), + returnValue: false, + ) as bool); + @override + set torKillSwitch(bool? torKillswitch) => super.noSuchMethod( + Invocation.setter( + #torKillSwitch, + torKillswitch, + ), + returnValueForMissingStub: null, + ); + @override bool get showTestNetCoins => (super.noSuchMethod( Invocation.getter(#showTestNetCoins), returnValue: false, @@ -268,12 +291,12 @@ class MockPrefs extends _i1.Mock implements _i3.Prefs { returnValueForMissingStub: null, ); @override - _i5.BackupFrequencyType get backupFrequencyType => (super.noSuchMethod( + _i6.BackupFrequencyType get backupFrequencyType => (super.noSuchMethod( Invocation.getter(#backupFrequencyType), - returnValue: _i5.BackupFrequencyType.everyTenMinutes, - ) as _i5.BackupFrequencyType); + returnValue: _i6.BackupFrequencyType.everyTenMinutes, + ) as _i6.BackupFrequencyType); @override - set backupFrequencyType(_i5.BackupFrequencyType? backupFrequencyType) => + set backupFrequencyType(_i6.BackupFrequencyType? backupFrequencyType) => super.noSuchMethod( Invocation.setter( #backupFrequencyType, @@ -406,66 +429,79 @@ class MockPrefs extends _i1.Mock implements _i3.Prefs { returnValueForMissingStub: null, ); @override + bool get useTor => (super.noSuchMethod( + Invocation.getter(#useTor), + returnValue: false, + ) as bool); + @override + set useTor(bool? useTor) => super.noSuchMethod( + Invocation.setter( + #useTor, + useTor, + ), + returnValueForMissingStub: null, + ); + @override bool get hasListeners => (super.noSuchMethod( Invocation.getter(#hasListeners), returnValue: false, ) as bool); @override - _i6.Future init() => (super.noSuchMethod( + _i7.Future init() => (super.noSuchMethod( Invocation.method( #init, [], ), - returnValue: _i6.Future.value(), - returnValueForMissingStub: _i6.Future.value(), - ) as _i6.Future); + returnValue: _i7.Future.value(), + returnValueForMissingStub: _i7.Future.value(), + ) as _i7.Future); @override - _i6.Future incrementCurrentNotificationIndex() => (super.noSuchMethod( + _i7.Future incrementCurrentNotificationIndex() => (super.noSuchMethod( Invocation.method( #incrementCurrentNotificationIndex, [], ), - returnValue: _i6.Future.value(), - returnValueForMissingStub: _i6.Future.value(), - ) as _i6.Future); + returnValue: _i7.Future.value(), + returnValueForMissingStub: _i7.Future.value(), + ) as _i7.Future); @override - _i6.Future isExternalCallsSet() => (super.noSuchMethod( + _i7.Future isExternalCallsSet() => (super.noSuchMethod( Invocation.method( #isExternalCallsSet, [], ), - returnValue: _i6.Future.value(false), - ) as _i6.Future); + returnValue: _i7.Future.value(false), + ) as _i7.Future); @override - _i6.Future saveUserID(String? userId) => (super.noSuchMethod( + _i7.Future saveUserID(String? userId) => (super.noSuchMethod( Invocation.method( #saveUserID, [userId], ), - returnValue: _i6.Future.value(), - returnValueForMissingStub: _i6.Future.value(), - ) as _i6.Future); + returnValue: _i7.Future.value(), + returnValueForMissingStub: _i7.Future.value(), + ) as _i7.Future); @override - _i6.Future saveSignupEpoch(int? signupEpoch) => (super.noSuchMethod( + _i7.Future saveSignupEpoch(int? signupEpoch) => (super.noSuchMethod( Invocation.method( #saveSignupEpoch, [signupEpoch], ), - returnValue: _i6.Future.value(), - returnValueForMissingStub: _i6.Future.value(), - ) as _i6.Future); + returnValue: _i7.Future.value(), + returnValueForMissingStub: _i7.Future.value(), + ) as _i7.Future); @override - _i7.AmountUnit amountUnit(_i8.Coin? coin) => (super.noSuchMethod( + _i8.AmountUnit amountUnit(_i9.Coin? coin) => (super.noSuchMethod( Invocation.method( #amountUnit, [coin], ), - returnValue: _i7.AmountUnit.normal, - ) as _i7.AmountUnit); + returnValue: _i8.AmountUnit.normal, + ) as _i8.AmountUnit); @override void updateAmountUnit({ - required _i8.Coin? coin, - required _i7.AmountUnit? amountUnit, + required _i9.Coin? coin, + required _i8.AmountUnit? amountUnit, }) => super.noSuchMethod( Invocation.method( @@ -479,7 +515,7 @@ class MockPrefs extends _i1.Mock implements _i3.Prefs { returnValueForMissingStub: null, ); @override - int maxDecimals(_i8.Coin? coin) => (super.noSuchMethod( + int maxDecimals(_i9.Coin? coin) => (super.noSuchMethod( Invocation.method( #maxDecimals, [coin], @@ -488,7 +524,7 @@ class MockPrefs extends _i1.Mock implements _i3.Prefs { ) as int); @override void updateMaxDecimals({ - required _i8.Coin? coin, + required _i9.Coin? coin, required int? maxDecimals, }) => super.noSuchMethod( @@ -503,7 +539,7 @@ class MockPrefs extends _i1.Mock implements _i3.Prefs { returnValueForMissingStub: null, ); @override - void addListener(_i9.VoidCallback? listener) => super.noSuchMethod( + void addListener(_i10.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #addListener, [listener], @@ -511,7 +547,7 @@ class MockPrefs extends _i1.Mock implements _i3.Prefs { returnValueForMissingStub: null, ); @override - void removeListener(_i9.VoidCallback? listener) => super.noSuchMethod( + void removeListener(_i10.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #removeListener, [listener], @@ -539,29 +575,29 @@ class MockPrefs extends _i1.Mock implements _i3.Prefs { /// A class which mocks [TradesService]. /// /// See the documentation for Mockito's code generation for more information. -class MockTradesService extends _i1.Mock implements _i10.TradesService { +class MockTradesService extends _i1.Mock implements _i11.TradesService { MockTradesService() { _i1.throwOnMissingStub(this); } @override - List<_i11.Trade> get trades => (super.noSuchMethod( + List<_i12.Trade> get trades => (super.noSuchMethod( Invocation.getter(#trades), - returnValue: <_i11.Trade>[], - ) as List<_i11.Trade>); + returnValue: <_i12.Trade>[], + ) as List<_i12.Trade>); @override bool get hasListeners => (super.noSuchMethod( Invocation.getter(#hasListeners), returnValue: false, ) as bool); @override - _i11.Trade? get(String? tradeId) => (super.noSuchMethod(Invocation.method( + _i12.Trade? get(String? tradeId) => (super.noSuchMethod(Invocation.method( #get, [tradeId], - )) as _i11.Trade?); + )) as _i12.Trade?); @override - _i6.Future add({ - required _i11.Trade? trade, + _i7.Future add({ + required _i12.Trade? trade, required bool? shouldNotifyListeners, }) => (super.noSuchMethod( @@ -573,12 +609,12 @@ class MockTradesService extends _i1.Mock implements _i10.TradesService { #shouldNotifyListeners: shouldNotifyListeners, }, ), - returnValue: _i6.Future.value(), - returnValueForMissingStub: _i6.Future.value(), - ) as _i6.Future); + returnValue: _i7.Future.value(), + returnValueForMissingStub: _i7.Future.value(), + ) as _i7.Future); @override - _i6.Future edit({ - required _i11.Trade? trade, + _i7.Future edit({ + required _i12.Trade? trade, required bool? shouldNotifyListeners, }) => (super.noSuchMethod( @@ -590,12 +626,12 @@ class MockTradesService extends _i1.Mock implements _i10.TradesService { #shouldNotifyListeners: shouldNotifyListeners, }, ), - returnValue: _i6.Future.value(), - returnValueForMissingStub: _i6.Future.value(), - ) as _i6.Future); + returnValue: _i7.Future.value(), + returnValueForMissingStub: _i7.Future.value(), + ) as _i7.Future); @override - _i6.Future delete({ - required _i11.Trade? trade, + _i7.Future delete({ + required _i12.Trade? trade, required bool? shouldNotifyListeners, }) => (super.noSuchMethod( @@ -607,11 +643,11 @@ class MockTradesService extends _i1.Mock implements _i10.TradesService { #shouldNotifyListeners: shouldNotifyListeners, }, ), - returnValue: _i6.Future.value(), - returnValueForMissingStub: _i6.Future.value(), - ) as _i6.Future); + returnValue: _i7.Future.value(), + returnValueForMissingStub: _i7.Future.value(), + ) as _i7.Future); @override - _i6.Future deleteByUuid({ + _i7.Future deleteByUuid({ required String? uuid, required bool? shouldNotifyListeners, }) => @@ -624,11 +660,11 @@ class MockTradesService extends _i1.Mock implements _i10.TradesService { #shouldNotifyListeners: shouldNotifyListeners, }, ), - returnValue: _i6.Future.value(), - returnValueForMissingStub: _i6.Future.value(), - ) as _i6.Future); + returnValue: _i7.Future.value(), + returnValueForMissingStub: _i7.Future.value(), + ) as _i7.Future); @override - void addListener(_i9.VoidCallback? listener) => super.noSuchMethod( + void addListener(_i10.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #addListener, [listener], @@ -636,7 +672,7 @@ class MockTradesService extends _i1.Mock implements _i10.TradesService { returnValueForMissingStub: null, ); @override - void removeListener(_i9.VoidCallback? listener) => super.noSuchMethod( + void removeListener(_i10.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #removeListener, [listener], @@ -664,7 +700,7 @@ class MockTradesService extends _i1.Mock implements _i10.TradesService { /// A class which mocks [TradeNotesService]. /// /// See the documentation for Mockito's code generation for more information. -class MockTradeNotesService extends _i1.Mock implements _i12.TradeNotesService { +class MockTradeNotesService extends _i1.Mock implements _i13.TradeNotesService { MockTradeNotesService() { _i1.throwOnMissingStub(this); } @@ -689,7 +725,7 @@ class MockTradeNotesService extends _i1.Mock implements _i12.TradeNotesService { returnValue: '', ) as String); @override - _i6.Future set({ + _i7.Future set({ required String? tradeId, required String? note, }) => @@ -702,21 +738,21 @@ class MockTradeNotesService extends _i1.Mock implements _i12.TradeNotesService { #note: note, }, ), - returnValue: _i6.Future.value(), - returnValueForMissingStub: _i6.Future.value(), - ) as _i6.Future); + returnValue: _i7.Future.value(), + returnValueForMissingStub: _i7.Future.value(), + ) as _i7.Future); @override - _i6.Future delete({required String? tradeId}) => (super.noSuchMethod( + _i7.Future delete({required String? tradeId}) => (super.noSuchMethod( Invocation.method( #delete, [], {#tradeId: tradeId}, ), - returnValue: _i6.Future.value(), - returnValueForMissingStub: _i6.Future.value(), - ) as _i6.Future); + returnValue: _i7.Future.value(), + returnValueForMissingStub: _i7.Future.value(), + ) as _i7.Future); @override - void addListener(_i9.VoidCallback? listener) => super.noSuchMethod( + void addListener(_i10.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #addListener, [listener], @@ -724,7 +760,7 @@ class MockTradeNotesService extends _i1.Mock implements _i12.TradeNotesService { returnValueForMissingStub: null, ); @override - void removeListener(_i9.VoidCallback? listener) => super.noSuchMethod( + void removeListener(_i10.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #removeListener, [listener], @@ -752,21 +788,21 @@ class MockTradeNotesService extends _i1.Mock implements _i12.TradeNotesService { /// A class which mocks [ChangeNowAPI]. /// /// See the documentation for Mockito's code generation for more information. -class MockChangeNowAPI extends _i1.Mock implements _i13.ChangeNowAPI { +class MockChangeNowAPI extends _i1.Mock implements _i14.ChangeNowAPI { MockChangeNowAPI() { _i1.throwOnMissingStub(this); } @override - set client(_i14.Client? _client) => super.noSuchMethod( - Invocation.setter( - #client, - _client, + _i2.HTTP get client => (super.noSuchMethod( + Invocation.getter(#client), + returnValue: _FakeHTTP_0( + this, + Invocation.getter(#client), ), - returnValueForMissingStub: null, - ); + ) as _i2.HTTP); @override - _i6.Future<_i2.ExchangeResponse>> getAvailableCurrencies({ + _i7.Future<_i3.ExchangeResponse>> getAvailableCurrencies({ bool? fixedRate, bool? active, }) => @@ -780,8 +816,8 @@ class MockChangeNowAPI extends _i1.Mock implements _i13.ChangeNowAPI { }, ), returnValue: - _i6.Future<_i2.ExchangeResponse>>.value( - _FakeExchangeResponse_0>( + _i7.Future<_i3.ExchangeResponse>>.value( + _FakeExchangeResponse_1>( this, Invocation.method( #getAvailableCurrencies, @@ -792,26 +828,26 @@ class MockChangeNowAPI extends _i1.Mock implements _i13.ChangeNowAPI { }, ), )), - ) as _i6.Future<_i2.ExchangeResponse>>); + ) as _i7.Future<_i3.ExchangeResponse>>); @override - _i6.Future<_i2.ExchangeResponse>> getCurrenciesV2() => + _i7.Future<_i3.ExchangeResponse>> getCurrenciesV2() => (super.noSuchMethod( Invocation.method( #getCurrenciesV2, [], ), returnValue: - _i6.Future<_i2.ExchangeResponse>>.value( - _FakeExchangeResponse_0>( + _i7.Future<_i3.ExchangeResponse>>.value( + _FakeExchangeResponse_1>( this, Invocation.method( #getCurrenciesV2, [], ), )), - ) as _i6.Future<_i2.ExchangeResponse>>); + ) as _i7.Future<_i3.ExchangeResponse>>); @override - _i6.Future<_i2.ExchangeResponse>> getPairedCurrencies({ + _i7.Future<_i3.ExchangeResponse>> getPairedCurrencies({ required String? ticker, bool? fixedRate, }) => @@ -825,8 +861,8 @@ class MockChangeNowAPI extends _i1.Mock implements _i13.ChangeNowAPI { }, ), returnValue: - _i6.Future<_i2.ExchangeResponse>>.value( - _FakeExchangeResponse_0>( + _i7.Future<_i3.ExchangeResponse>>.value( + _FakeExchangeResponse_1>( this, Invocation.method( #getPairedCurrencies, @@ -837,9 +873,9 @@ class MockChangeNowAPI extends _i1.Mock implements _i13.ChangeNowAPI { }, ), )), - ) as _i6.Future<_i2.ExchangeResponse>>); + ) as _i7.Future<_i3.ExchangeResponse>>); @override - _i6.Future<_i2.ExchangeResponse<_i16.Decimal>> getMinimalExchangeAmount({ + _i7.Future<_i3.ExchangeResponse<_i16.Decimal>> getMinimalExchangeAmount({ required String? fromTicker, required String? toTicker, String? apiKey, @@ -854,8 +890,8 @@ class MockChangeNowAPI extends _i1.Mock implements _i13.ChangeNowAPI { #apiKey: apiKey, }, ), - returnValue: _i6.Future<_i2.ExchangeResponse<_i16.Decimal>>.value( - _FakeExchangeResponse_0<_i16.Decimal>( + returnValue: _i7.Future<_i3.ExchangeResponse<_i16.Decimal>>.value( + _FakeExchangeResponse_1<_i16.Decimal>( this, Invocation.method( #getMinimalExchangeAmount, @@ -867,9 +903,9 @@ class MockChangeNowAPI extends _i1.Mock implements _i13.ChangeNowAPI { }, ), )), - ) as _i6.Future<_i2.ExchangeResponse<_i16.Decimal>>); + ) as _i7.Future<_i3.ExchangeResponse<_i16.Decimal>>); @override - _i6.Future<_i2.ExchangeResponse<_i17.Range>> getRange({ + _i7.Future<_i3.ExchangeResponse<_i17.Range>> getRange({ required String? fromTicker, required String? toTicker, required bool? isFixedRate, @@ -886,8 +922,8 @@ class MockChangeNowAPI extends _i1.Mock implements _i13.ChangeNowAPI { #apiKey: apiKey, }, ), - returnValue: _i6.Future<_i2.ExchangeResponse<_i17.Range>>.value( - _FakeExchangeResponse_0<_i17.Range>( + returnValue: _i7.Future<_i3.ExchangeResponse<_i17.Range>>.value( + _FakeExchangeResponse_1<_i17.Range>( this, Invocation.method( #getRange, @@ -900,9 +936,9 @@ class MockChangeNowAPI extends _i1.Mock implements _i13.ChangeNowAPI { }, ), )), - ) as _i6.Future<_i2.ExchangeResponse<_i17.Range>>); + ) as _i7.Future<_i3.ExchangeResponse<_i17.Range>>); @override - _i6.Future<_i2.ExchangeResponse<_i18.Estimate>> getEstimatedExchangeAmount({ + _i7.Future<_i3.ExchangeResponse<_i18.Estimate>> getEstimatedExchangeAmount({ required String? fromTicker, required String? toTicker, required _i16.Decimal? fromAmount, @@ -919,8 +955,8 @@ class MockChangeNowAPI extends _i1.Mock implements _i13.ChangeNowAPI { #apiKey: apiKey, }, ), - returnValue: _i6.Future<_i2.ExchangeResponse<_i18.Estimate>>.value( - _FakeExchangeResponse_0<_i18.Estimate>( + returnValue: _i7.Future<_i3.ExchangeResponse<_i18.Estimate>>.value( + _FakeExchangeResponse_1<_i18.Estimate>( this, Invocation.method( #getEstimatedExchangeAmount, @@ -933,9 +969,9 @@ class MockChangeNowAPI extends _i1.Mock implements _i13.ChangeNowAPI { }, ), )), - ) as _i6.Future<_i2.ExchangeResponse<_i18.Estimate>>); + ) as _i7.Future<_i3.ExchangeResponse<_i18.Estimate>>); @override - _i6.Future<_i2.ExchangeResponse<_i18.Estimate>> + _i7.Future<_i3.ExchangeResponse<_i18.Estimate>> getEstimatedExchangeAmountFixedRate({ required String? fromTicker, required String? toTicker, @@ -957,8 +993,8 @@ class MockChangeNowAPI extends _i1.Mock implements _i13.ChangeNowAPI { #apiKey: apiKey, }, ), - returnValue: _i6.Future<_i2.ExchangeResponse<_i18.Estimate>>.value( - _FakeExchangeResponse_0<_i18.Estimate>( + returnValue: _i7.Future<_i3.ExchangeResponse<_i18.Estimate>>.value( + _FakeExchangeResponse_1<_i18.Estimate>( this, Invocation.method( #getEstimatedExchangeAmountFixedRate, @@ -973,9 +1009,9 @@ class MockChangeNowAPI extends _i1.Mock implements _i13.ChangeNowAPI { }, ), )), - ) as _i6.Future<_i2.ExchangeResponse<_i18.Estimate>>); + ) as _i7.Future<_i3.ExchangeResponse<_i18.Estimate>>); @override - _i6.Future<_i2.ExchangeResponse<_i19.CNExchangeEstimate>> + _i7.Future<_i3.ExchangeResponse<_i19.CNExchangeEstimate>> getEstimatedExchangeAmountV2({ required String? fromTicker, required String? toTicker, @@ -1002,8 +1038,8 @@ class MockChangeNowAPI extends _i1.Mock implements _i13.ChangeNowAPI { }, ), returnValue: - _i6.Future<_i2.ExchangeResponse<_i19.CNExchangeEstimate>>.value( - _FakeExchangeResponse_0<_i19.CNExchangeEstimate>( + _i7.Future<_i3.ExchangeResponse<_i19.CNExchangeEstimate>>.value( + _FakeExchangeResponse_1<_i19.CNExchangeEstimate>( this, Invocation.method( #getEstimatedExchangeAmountV2, @@ -1020,18 +1056,18 @@ class MockChangeNowAPI extends _i1.Mock implements _i13.ChangeNowAPI { }, ), )), - ) as _i6.Future<_i2.ExchangeResponse<_i19.CNExchangeEstimate>>); + ) as _i7.Future<_i3.ExchangeResponse<_i19.CNExchangeEstimate>>); @override - _i6.Future<_i2.ExchangeResponse>> + _i7.Future<_i3.ExchangeResponse>> getAvailableFixedRateMarkets({String? apiKey}) => (super.noSuchMethod( Invocation.method( #getAvailableFixedRateMarkets, [], {#apiKey: apiKey}, ), - returnValue: _i6 - .Future<_i2.ExchangeResponse>>.value( - _FakeExchangeResponse_0>( + returnValue: _i7 + .Future<_i3.ExchangeResponse>>.value( + _FakeExchangeResponse_1>( this, Invocation.method( #getAvailableFixedRateMarkets, @@ -1039,9 +1075,9 @@ class MockChangeNowAPI extends _i1.Mock implements _i13.ChangeNowAPI { {#apiKey: apiKey}, ), )), - ) as _i6.Future<_i2.ExchangeResponse>>); + ) as _i7.Future<_i3.ExchangeResponse>>); @override - _i6.Future<_i2.ExchangeResponse<_i21.ExchangeTransaction>> + _i7.Future<_i3.ExchangeResponse<_i21.ExchangeTransaction>> createStandardExchangeTransaction({ required String? fromTicker, required String? toTicker, @@ -1071,9 +1107,9 @@ class MockChangeNowAPI extends _i1.Mock implements _i13.ChangeNowAPI { #apiKey: apiKey, }, ), - returnValue: _i6 - .Future<_i2.ExchangeResponse<_i21.ExchangeTransaction>>.value( - _FakeExchangeResponse_0<_i21.ExchangeTransaction>( + returnValue: _i7 + .Future<_i3.ExchangeResponse<_i21.ExchangeTransaction>>.value( + _FakeExchangeResponse_1<_i21.ExchangeTransaction>( this, Invocation.method( #createStandardExchangeTransaction, @@ -1092,9 +1128,9 @@ class MockChangeNowAPI extends _i1.Mock implements _i13.ChangeNowAPI { }, ), )), - ) as _i6.Future<_i2.ExchangeResponse<_i21.ExchangeTransaction>>); + ) as _i7.Future<_i3.ExchangeResponse<_i21.ExchangeTransaction>>); @override - _i6.Future<_i2.ExchangeResponse<_i21.ExchangeTransaction>> + _i7.Future<_i3.ExchangeResponse<_i21.ExchangeTransaction>> createFixedRateExchangeTransaction({ required String? fromTicker, required String? toTicker, @@ -1128,9 +1164,9 @@ class MockChangeNowAPI extends _i1.Mock implements _i13.ChangeNowAPI { #apiKey: apiKey, }, ), - returnValue: _i6 - .Future<_i2.ExchangeResponse<_i21.ExchangeTransaction>>.value( - _FakeExchangeResponse_0<_i21.ExchangeTransaction>( + returnValue: _i7 + .Future<_i3.ExchangeResponse<_i21.ExchangeTransaction>>.value( + _FakeExchangeResponse_1<_i21.ExchangeTransaction>( this, Invocation.method( #createFixedRateExchangeTransaction, @@ -1151,10 +1187,10 @@ class MockChangeNowAPI extends _i1.Mock implements _i13.ChangeNowAPI { }, ), )), - ) as _i6.Future<_i2.ExchangeResponse<_i21.ExchangeTransaction>>); + ) as _i7.Future<_i3.ExchangeResponse<_i21.ExchangeTransaction>>); @override - _i6.Future< - _i2 + _i7.Future< + _i3 .ExchangeResponse<_i22.ExchangeTransactionStatus>> getTransactionStatus({ required String? id, String? apiKey, @@ -1168,9 +1204,9 @@ class MockChangeNowAPI extends _i1.Mock implements _i13.ChangeNowAPI { #apiKey: apiKey, }, ), - returnValue: _i6 - .Future<_i2.ExchangeResponse<_i22.ExchangeTransactionStatus>>.value( - _FakeExchangeResponse_0<_i22.ExchangeTransactionStatus>( + returnValue: _i7 + .Future<_i3.ExchangeResponse<_i22.ExchangeTransactionStatus>>.value( + _FakeExchangeResponse_1<_i22.ExchangeTransactionStatus>( this, Invocation.method( #getTransactionStatus, @@ -1181,9 +1217,9 @@ class MockChangeNowAPI extends _i1.Mock implements _i13.ChangeNowAPI { }, ), )), - ) as _i6.Future<_i2.ExchangeResponse<_i22.ExchangeTransactionStatus>>); + ) as _i7.Future<_i3.ExchangeResponse<_i22.ExchangeTransactionStatus>>); @override - _i6.Future<_i2.ExchangeResponse>> + _i7.Future<_i3.ExchangeResponse>> getAvailableFloatingRatePairs({bool? includePartners = false}) => (super.noSuchMethod( Invocation.method( @@ -1192,8 +1228,8 @@ class MockChangeNowAPI extends _i1.Mock implements _i13.ChangeNowAPI { {#includePartners: includePartners}, ), returnValue: - _i6.Future<_i2.ExchangeResponse>>.value( - _FakeExchangeResponse_0>( + _i7.Future<_i3.ExchangeResponse>>.value( + _FakeExchangeResponse_1>( this, Invocation.method( #getAvailableFloatingRatePairs, @@ -1201,5 +1237,5 @@ class MockChangeNowAPI extends _i1.Mock implements _i13.ChangeNowAPI { {#includePartners: includePartners}, ), )), - ) as _i6.Future<_i2.ExchangeResponse>>); + ) as _i7.Future<_i3.ExchangeResponse>>); } diff --git a/test/screen_tests/lockscreen_view_screen_test.mocks.dart b/test/screen_tests/lockscreen_view_screen_test.mocks.dart index 35a1a5f20..dd8f32b04 100644 --- a/test/screen_tests/lockscreen_view_screen_test.mocks.dart +++ b/test/screen_tests/lockscreen_view_screen_test.mocks.dart @@ -771,10 +771,12 @@ class MockManager extends _i1.Mock implements _i13.Manager { returnValue: _i8.Future.value(false), ) as _i8.Future); @override - _i8.Future initializeNew() => (super.noSuchMethod( + _i8.Future initializeNew( + ({String mnemonicPassphrase, int wordCount})? data) => + (super.noSuchMethod( Invocation.method( #initializeNew, - [], + [data], ), returnValue: _i8.Future.value(), returnValueForMissingStub: _i8.Future.value(), 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 8526c77f3..87686d271 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 @@ -558,10 +558,12 @@ class MockManager extends _i1.Mock implements _i10.Manager { returnValue: _i7.Future.value(false), ) as _i7.Future); @override - _i7.Future initializeNew() => (super.noSuchMethod( + _i7.Future initializeNew( + ({String mnemonicPassphrase, int wordCount})? data) => + (super.noSuchMethod( Invocation.method( #initializeNew, - [], + [data], ), returnValue: _i7.Future.value(), returnValueForMissingStub: _i7.Future.value(), 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 ba9350c78..221cbb329 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 @@ -558,10 +558,12 @@ class MockManager extends _i1.Mock implements _i10.Manager { returnValue: _i7.Future.value(false), ) as _i7.Future); @override - _i7.Future initializeNew() => (super.noSuchMethod( + _i7.Future initializeNew( + ({String mnemonicPassphrase, int wordCount})? data) => + (super.noSuchMethod( Invocation.method( #initializeNew, - [], + [data], ), returnValue: _i7.Future.value(), returnValueForMissingStub: _i7.Future.value(), 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 5f8055c5a..abb608127 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 @@ -558,10 +558,12 @@ class MockManager extends _i1.Mock implements _i10.Manager { returnValue: _i7.Future.value(false), ) as _i7.Future); @override - _i7.Future initializeNew() => (super.noSuchMethod( + _i7.Future initializeNew( + ({String mnemonicPassphrase, int wordCount})? data) => + (super.noSuchMethod( Invocation.method( #initializeNew, - [], + [data], ), returnValue: _i7.Future.value(), returnValueForMissingStub: _i7.Future.value(), 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 d621a4ae0..b60b30832 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 @@ -325,10 +325,12 @@ class MockManager extends _i1.Mock implements _i6.Manager { returnValue: _i8.Future.value(false), ) as _i8.Future); @override - _i8.Future initializeNew() => (super.noSuchMethod( + _i8.Future initializeNew( + ({String mnemonicPassphrase, int wordCount})? data) => + (super.noSuchMethod( Invocation.method( #initializeNew, - [], + [data], ), returnValue: _i8.Future.value(), returnValueForMissingStub: _i8.Future.value(), 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 6802650ab..90907cd14 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 @@ -556,10 +556,12 @@ class MockManager extends _i1.Mock implements _i10.Manager { returnValue: _i7.Future.value(false), ) as _i7.Future); @override - _i7.Future initializeNew() => (super.noSuchMethod( + _i7.Future initializeNew( + ({String mnemonicPassphrase, int wordCount})? data) => + (super.noSuchMethod( Invocation.method( #initializeNew, - [], + [data], ), returnValue: _i7.Future.value(), returnValueForMissingStub: _i7.Future.value(), 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 a9b4549a0..460a35f50 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 @@ -771,10 +771,12 @@ class MockManager extends _i1.Mock implements _i13.Manager { returnValue: _i8.Future.value(false), ) as _i8.Future); @override - _i8.Future initializeNew() => (super.noSuchMethod( + _i8.Future initializeNew( + ({String mnemonicPassphrase, int wordCount})? data) => + (super.noSuchMethod( Invocation.method( #initializeNew, - [], + [data], ), returnValue: _i8.Future.value(), returnValueForMissingStub: _i8.Future.value(), 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 a33b13e7a..b4a8329da 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 @@ -612,10 +612,12 @@ class MockManager extends _i1.Mock implements _i13.Manager { returnValue: _i9.Future.value(false), ) as _i9.Future); @override - _i9.Future initializeNew() => (super.noSuchMethod( + _i9.Future initializeNew( + ({String mnemonicPassphrase, int wordCount})? data) => + (super.noSuchMethod( Invocation.method( #initializeNew, - [], + [data], ), returnValue: _i9.Future.value(), returnValueForMissingStub: _i9.Future.value(), 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 e372e3781..25241ab80 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 @@ -325,10 +325,12 @@ class MockManager extends _i1.Mock implements _i6.Manager { returnValue: _i8.Future.value(false), ) as _i8.Future); @override - _i8.Future initializeNew() => (super.noSuchMethod( + _i8.Future initializeNew( + ({String mnemonicPassphrase, int wordCount})? data) => + (super.noSuchMethod( Invocation.method( #initializeNew, - [], + [data], ), returnValue: _i8.Future.value(), returnValueForMissingStub: _i8.Future.value(), 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 ece50ef76..d77078d9c 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 @@ -325,10 +325,12 @@ class MockManager extends _i1.Mock implements _i6.Manager { returnValue: _i8.Future.value(false), ) as _i8.Future); @override - _i8.Future initializeNew() => (super.noSuchMethod( + _i8.Future initializeNew( + ({String mnemonicPassphrase, int wordCount})? data) => + (super.noSuchMethod( Invocation.method( #initializeNew, - [], + [data], ), returnValue: _i8.Future.value(), returnValueForMissingStub: _i8.Future.value(), 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 b56c08998..0b8976a88 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 @@ -540,10 +540,12 @@ class MockManager extends _i1.Mock implements _i12.Manager { returnValue: _i9.Future.value(false), ) as _i9.Future); @override - _i9.Future initializeNew() => (super.noSuchMethod( + _i9.Future initializeNew( + ({String mnemonicPassphrase, int wordCount})? data) => + (super.noSuchMethod( Invocation.method( #initializeNew, - [], + [data], ), returnValue: _i9.Future.value(), returnValueForMissingStub: _i9.Future.value(), 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 5e62fd6d4..803ef81c6 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 @@ -540,10 +540,12 @@ class MockManager extends _i1.Mock implements _i12.Manager { returnValue: _i9.Future.value(false), ) as _i9.Future); @override - _i9.Future initializeNew() => (super.noSuchMethod( + _i9.Future initializeNew( + ({String mnemonicPassphrase, int wordCount})? data) => + (super.noSuchMethod( Invocation.method( #initializeNew, - [], + [data], ), returnValue: _i9.Future.value(), returnValueForMissingStub: _i9.Future.value(), 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 671af0d4b..4e59b2a40 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 @@ -325,10 +325,12 @@ class MockManager extends _i1.Mock implements _i6.Manager { returnValue: _i8.Future.value(false), ) as _i8.Future); @override - _i8.Future initializeNew() => (super.noSuchMethod( + _i8.Future initializeNew( + ({String mnemonicPassphrase, int wordCount})? data) => + (super.noSuchMethod( Invocation.method( #initializeNew, - [], + [data], ), returnValue: _i8.Future.value(), returnValueForMissingStub: _i8.Future.value(), 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 e3a475bdd..151ecd1ab 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 @@ -325,10 +325,12 @@ class MockManager extends _i1.Mock implements _i6.Manager { returnValue: _i8.Future.value(false), ) as _i8.Future); @override - _i8.Future initializeNew() => (super.noSuchMethod( + _i8.Future initializeNew( + ({String mnemonicPassphrase, int wordCount})? data) => + (super.noSuchMethod( Invocation.method( #initializeNew, - [], + [data], ), returnValue: _i8.Future.value(), returnValueForMissingStub: _i8.Future.value(), 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 439dd35ca..d9e9603d3 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 @@ -556,10 +556,12 @@ class MockManager extends _i1.Mock implements _i10.Manager { returnValue: _i7.Future.value(false), ) as _i7.Future); @override - _i7.Future initializeNew() => (super.noSuchMethod( + _i7.Future initializeNew( + ({String mnemonicPassphrase, int wordCount})? data) => + (super.noSuchMethod( Invocation.method( #initializeNew, - [], + [data], ), returnValue: _i7.Future.value(), returnValueForMissingStub: _i7.Future.value(), 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 cc20dce98..e0fae8b21 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 @@ -792,10 +792,12 @@ class MockManager extends _i1.Mock implements _i15.Manager { returnValue: _i8.Future.value(false), ) as _i8.Future); @override - _i8.Future initializeNew() => (super.noSuchMethod( + _i8.Future initializeNew( + ({String mnemonicPassphrase, int wordCount})? data) => + (super.noSuchMethod( Invocation.method( #initializeNew, - [], + [data], ), returnValue: _i8.Future.value(), returnValueForMissingStub: _i8.Future.value(), 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 4cfabb7bc..97837b511 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 @@ -556,10 +556,12 @@ class MockManager extends _i1.Mock implements _i10.Manager { returnValue: _i7.Future.value(false), ) as _i7.Future); @override - _i7.Future initializeNew() => (super.noSuchMethod( + _i7.Future initializeNew( + ({String mnemonicPassphrase, int wordCount})? data) => + (super.noSuchMethod( Invocation.method( #initializeNew, - [], + [data], ), returnValue: _i7.Future.value(), returnValueForMissingStub: _i7.Future.value(), 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 b48b433a9..97563c8ad 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 @@ -327,10 +327,12 @@ class MockManager extends _i1.Mock implements _i6.Manager { returnValue: _i8.Future.value(false), ) as _i8.Future); @override - _i8.Future initializeNew() => (super.noSuchMethod( + _i8.Future initializeNew( + ({String mnemonicPassphrase, int wordCount})? data) => + (super.noSuchMethod( Invocation.method( #initializeNew, - [], + [data], ), returnValue: _i8.Future.value(), returnValueForMissingStub: _i8.Future.value(), 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 df0e2d613..bab69e5d2 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 @@ -326,10 +326,12 @@ class MockManager extends _i1.Mock implements _i6.Manager { returnValue: _i8.Future.value(false), ) as _i8.Future); @override - _i8.Future initializeNew() => (super.noSuchMethod( + _i8.Future initializeNew( + ({String mnemonicPassphrase, int wordCount})? data) => + (super.noSuchMethod( Invocation.method( #initializeNew, - [], + [data], ), returnValue: _i8.Future.value(), returnValueForMissingStub: _i8.Future.value(), 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 e00ef1039..75c6d795e 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 @@ -325,10 +325,12 @@ class MockManager extends _i1.Mock implements _i6.Manager { returnValue: _i8.Future.value(false), ) as _i8.Future); @override - _i8.Future initializeNew() => (super.noSuchMethod( + _i8.Future initializeNew( + ({String mnemonicPassphrase, int wordCount})? data) => + (super.noSuchMethod( Invocation.method( #initializeNew, - [], + [data], ), returnValue: _i8.Future.value(), returnValueForMissingStub: _i8.Future.value(), 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 e5e86bf6e..eb261af73 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 @@ -367,10 +367,12 @@ class MockManager extends _i1.Mock implements _i9.Manager { returnValue: _i8.Future.value(false), ) as _i8.Future); @override - _i8.Future initializeNew() => (super.noSuchMethod( + _i8.Future initializeNew( + ({String mnemonicPassphrase, int wordCount})? data) => + (super.noSuchMethod( Invocation.method( #initializeNew, - [], + [data], ), returnValue: _i8.Future.value(), returnValueForMissingStub: _i8.Future.value(), 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 674ad6549..d43cb5430 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 @@ -327,10 +327,12 @@ class MockManager extends _i1.Mock implements _i6.Manager { returnValue: _i8.Future.value(false), ) as _i8.Future); @override - _i8.Future initializeNew() => (super.noSuchMethod( + _i8.Future initializeNew( + ({String mnemonicPassphrase, int wordCount})? data) => + (super.noSuchMethod( Invocation.method( #initializeNew, - [], + [data], ), returnValue: _i8.Future.value(), returnValueForMissingStub: _i8.Future.value(), diff --git a/test/services/change_now/change_now_test.dart b/test/services/change_now/change_now_test.dart index f79cbcd4d..f49c52064 100644 --- a/test/services/change_now/change_now_test.dart +++ b/test/services/change_now/change_now_test.dart @@ -2,7 +2,6 @@ import 'dart:convert'; import 'package:decimal/decimal.dart'; import 'package:flutter_test/flutter_test.dart'; -import 'package:http/http.dart'; import 'package:mockito/annotations.dart'; import 'package:mockito/mockito.dart'; import 'package:stackwallet/exceptions/exchange/exchange_exception.dart'; @@ -10,25 +9,28 @@ import 'package:stackwallet/models/exchange/change_now/exchange_transaction.dart import 'package:stackwallet/models/exchange/change_now/exchange_transaction_status.dart'; import 'package:stackwallet/models/exchange/response_objects/estimate.dart'; import 'package:stackwallet/models/isar/exchange_cache/pair.dart'; +import 'package:stackwallet/networking/http.dart'; import 'package:stackwallet/services/exchange/change_now/change_now_api.dart'; import 'change_now_sample_data.dart'; import 'change_now_test.mocks.dart'; -@GenerateMocks([Client]) +@GenerateMocks([HTTP]) void main() { group("getAvailableCurrencies", () { test("getAvailableCurrencies succeeds without options", () async { - final client = MockClient(); - ChangeNowAPI.instance.client = client; + final client = MockHTTP(); + + final instance = ChangeNowAPI(http: client); when(client.get( - Uri.parse("https://api.ChangeNow.io/v1/currencies"), + url: Uri.parse("https://api.ChangeNow.io/v1/currencies"), headers: {'Content-Type': 'application/json'}, + proxyInfo: null, )).thenAnswer((realInvocation) async => - Response(jsonEncode(availableCurrenciesJSON), 200)); + Response(utf8.encode(jsonEncode(availableCurrenciesJSON)), 200)); - final result = await ChangeNowAPI.instance.getAvailableCurrencies(); + final result = await instance.getAvailableCurrencies(); expect(result.exception, null); expect(result.value == null, false); @@ -36,17 +38,17 @@ void main() { }); test("getAvailableCurrencies succeeds with active option", () async { - final client = MockClient(); - ChangeNowAPI.instance.client = client; + final client = MockHTTP(); + final instance = ChangeNowAPI(http: client); when(client.get( - Uri.parse("https://api.ChangeNow.io/v1/currencies?active=true"), + url: Uri.parse("https://api.ChangeNow.io/v1/currencies?active=true"), headers: {'Content-Type': 'application/json'}, - )).thenAnswer((realInvocation) async => - Response(jsonEncode(availableCurrenciesJSONActive), 200)); + proxyInfo: null, + )).thenAnswer((realInvocation) async => Response( + utf8.encode(jsonEncode(availableCurrenciesJSONActive)), 200)); - final result = - await ChangeNowAPI.instance.getAvailableCurrencies(active: true); + final result = await instance.getAvailableCurrencies(active: true); expect(result.exception, null); expect(result.value == null, false); @@ -54,17 +56,17 @@ void main() { }); test("getAvailableCurrencies succeeds with fixedRate option", () async { - final client = MockClient(); - ChangeNowAPI.instance.client = client; + final client = MockHTTP(); + final instance = ChangeNowAPI(http: client); when(client.get( - Uri.parse("https://api.ChangeNow.io/v1/currencies?fixedRate=true"), + url: Uri.parse("https://api.ChangeNow.io/v1/currencies?fixedRate=true"), headers: {'Content-Type': 'application/json'}, - )).thenAnswer((realInvocation) async => - Response(jsonEncode(availableCurrenciesJSONFixedRate), 200)); + proxyInfo: null, + )).thenAnswer((realInvocation) async => Response( + utf8.encode(jsonEncode(availableCurrenciesJSONFixedRate)), 200)); - final result = - await ChangeNowAPI.instance.getAvailableCurrencies(fixedRate: true); + final result = await instance.getAvailableCurrencies(fixedRate: true); expect(result.exception, null); expect(result.value == null, false); @@ -73,18 +75,20 @@ void main() { test("getAvailableCurrencies succeeds with fixedRate and active options", () async { - final client = MockClient(); - ChangeNowAPI.instance.client = client; + final client = MockHTTP(); + final instance = ChangeNowAPI(http: client); when(client.get( - Uri.parse( + url: Uri.parse( "https://api.ChangeNow.io/v1/currencies?fixedRate=true&active=true"), headers: {'Content-Type': 'application/json'}, - )).thenAnswer((realInvocation) async => - Response(jsonEncode(availableCurrenciesJSONActiveFixedRate), 200)); + proxyInfo: null, + )).thenAnswer((realInvocation) async => Response( + utf8.encode(jsonEncode(availableCurrenciesJSONActiveFixedRate)), + 200)); - final result = await ChangeNowAPI.instance - .getAvailableCurrencies(active: true, fixedRate: true); + final result = + await instance.getAvailableCurrencies(active: true, fixedRate: true); expect(result.exception, null); expect(result.value == null, false); @@ -94,16 +98,17 @@ void main() { test( "getAvailableCurrencies fails with ChangeNowExceptionType.serializeResponseError", () async { - final client = MockClient(); - ChangeNowAPI.instance.client = client; + final client = MockHTTP(); + final instance = ChangeNowAPI(http: client); when(client.get( - Uri.parse("https://api.ChangeNow.io/v1/currencies"), + url: Uri.parse("https://api.ChangeNow.io/v1/currencies"), headers: {'Content-Type': 'application/json'}, - )).thenAnswer((realInvocation) async => - Response('{"some unexpected": "but valid json data"}', 200)); + proxyInfo: null, + )).thenAnswer((realInvocation) async => Response( + utf8.encode('{"some unexpected": "but valid json data"}'), 200)); - final result = await ChangeNowAPI.instance.getAvailableCurrencies(); + final result = await instance.getAvailableCurrencies(); expect( result.exception!.type, ExchangeExceptionType.serializeResponseError); @@ -111,15 +116,16 @@ void main() { }); test("getAvailableCurrencies fails for any other reason", () async { - final client = MockClient(); - ChangeNowAPI.instance.client = client; + final client = MockHTTP(); + final instance = ChangeNowAPI(http: client); when(client.get( - Uri.parse("https://api.ChangeNow.io/v1/currencies"), + url: Uri.parse("https://api.ChangeNow.io/v1/currencies"), headers: {'Content-Type': 'application/json'}, - )).thenAnswer((realInvocation) async => Response("", 400)); + proxyInfo: null, + )).thenAnswer((realInvocation) async => Response(utf8.encode(""), 400)); - final result = await ChangeNowAPI.instance.getAvailableCurrencies(); + final result = await instance.getAvailableCurrencies(); expect( result.exception!.type, ExchangeExceptionType.serializeResponseError); @@ -129,17 +135,17 @@ void main() { group("getPairedCurrencies", () { test("getPairedCurrencies succeeds without fixedRate option", () async { - final client = MockClient(); - ChangeNowAPI.instance.client = client; + final client = MockHTTP(); + final instance = ChangeNowAPI(http: client); when(client.get( - Uri.parse("https://api.ChangeNow.io/v1/currencies-to/XMR"), + url: Uri.parse("https://api.ChangeNow.io/v1/currencies-to/XMR"), headers: {'Content-Type': 'application/json'}, + proxyInfo: null, )).thenAnswer((realInvocation) async => - Response(jsonEncode(getPairedCurrenciesJSON), 200)); + Response(utf8.encode(jsonEncode(getPairedCurrenciesJSON)), 200)); - final result = - await ChangeNowAPI.instance.getPairedCurrencies(ticker: "XMR"); + final result = await instance.getPairedCurrencies(ticker: "XMR"); expect(result.exception, null); expect(result.value == null, false); @@ -147,18 +153,19 @@ void main() { }); test("getPairedCurrencies succeeds with fixedRate option", () async { - final client = MockClient(); - ChangeNowAPI.instance.client = client; + final client = MockHTTP(); + final instance = ChangeNowAPI(http: client); when(client.get( - Uri.parse( + url: Uri.parse( "https://api.ChangeNow.io/v1/currencies-to/XMR?fixedRate=true"), headers: {'Content-Type': 'application/json'}, - )).thenAnswer((realInvocation) async => - Response(jsonEncode(getPairedCurrenciesJSONFixedRate), 200)); + proxyInfo: null, + )).thenAnswer((realInvocation) async => Response( + utf8.encode(jsonEncode(getPairedCurrenciesJSONFixedRate)), 200)); - final result = await ChangeNowAPI.instance - .getPairedCurrencies(ticker: "XMR", fixedRate: true); + final result = + await instance.getPairedCurrencies(ticker: "XMR", fixedRate: true); expect(result.exception, null); expect(result.value == null, false); @@ -168,17 +175,17 @@ void main() { test( "getPairedCurrencies fails with ChangeNowExceptionType.serializeResponseError A", () async { - final client = MockClient(); - ChangeNowAPI.instance.client = client; + final client = MockHTTP(); + final instance = ChangeNowAPI(http: client); when(client.get( - Uri.parse("https://api.ChangeNow.io/v1/currencies-to/XMR"), + url: Uri.parse("https://api.ChangeNow.io/v1/currencies-to/XMR"), headers: {'Content-Type': 'application/json'}, - )).thenAnswer((realInvocation) async => - Response('[{"some unexpected": "but valid json data"}]', 200)); + proxyInfo: null, + )).thenAnswer((realInvocation) async => Response( + utf8.encode('[{"some unexpected": "but valid json data"}]'), 200)); - final result = - await ChangeNowAPI.instance.getPairedCurrencies(ticker: "XMR"); + final result = await instance.getPairedCurrencies(ticker: "XMR"); expect( result.exception!.type, ExchangeExceptionType.serializeResponseError); @@ -186,16 +193,17 @@ void main() { }); test("getPairedCurrencies fails for any other reason", () async { - final client = MockClient(); - ChangeNowAPI.instance.client = client; + final client = MockHTTP(); + final instance = ChangeNowAPI(http: client); when(client.get( - Uri.parse("https://api.ChangeNow.io/v1/currencies"), + url: Uri.parse("https://api.ChangeNow.io/v1/currencies"), headers: {'Content-Type': 'application/json'}, - )).thenAnswer((realInvocation) async => Response("", 400)); + proxyInfo: null, + )).thenAnswer((realInvocation) async => Response(utf8.encode(""), 400)); - final result = await ChangeNowAPI.instance - .getPairedCurrencies(ticker: "XMR", fixedRate: true); + final result = + await instance.getPairedCurrencies(ticker: "XMR", fixedRate: true); expect(result.exception!.type, ExchangeExceptionType.generic); expect(result.value == null, true); @@ -204,17 +212,18 @@ void main() { group("getMinimalExchangeAmount", () { test("getMinimalExchangeAmount succeeds", () async { - final client = MockClient(); - ChangeNowAPI.instance.client = client; + final client = MockHTTP(); + final instance = ChangeNowAPI(http: client); when(client.get( - Uri.parse( + url: Uri.parse( "https://api.ChangeNow.io/v1/min-amount/xmr_btc?api_key=testAPIKEY"), headers: {'Content-Type': 'application/json'}, - )).thenAnswer( - (realInvocation) async => Response('{"minAmount": 42}', 200)); + proxyInfo: null, + )).thenAnswer((realInvocation) async => + Response(utf8.encode('{"minAmount": 42}'), 200)); - final result = await ChangeNowAPI.instance.getMinimalExchangeAmount( + final result = await instance.getMinimalExchangeAmount( fromTicker: "xmr", toTicker: "btc", apiKey: "testAPIKEY", @@ -228,16 +237,18 @@ void main() { test( "getMinimalExchangeAmount fails with ChangeNowExceptionType.serializeResponseError", () async { - final client = MockClient(); - ChangeNowAPI.instance.client = client; + final client = MockHTTP(); + final instance = ChangeNowAPI(http: client); when(client.get( - Uri.parse( + url: Uri.parse( "https://api.ChangeNow.io/v1/min-amount/xmr_btc?api_key=testAPIKEY"), headers: {'Content-Type': 'application/json'}, - )).thenAnswer((realInvocation) async => Response('{"error": 42}', 200)); + proxyInfo: null, + )).thenAnswer((realInvocation) async => + Response(utf8.encode('{"error": 42}'), 200)); - final result = await ChangeNowAPI.instance.getMinimalExchangeAmount( + final result = await instance.getMinimalExchangeAmount( fromTicker: "xmr", toTicker: "btc", apiKey: "testAPIKEY", @@ -249,16 +260,17 @@ void main() { }); test("getMinimalExchangeAmount fails for any other reason", () async { - final client = MockClient(); - ChangeNowAPI.instance.client = client; + final client = MockHTTP(); + final instance = ChangeNowAPI(http: client); when(client.get( - Uri.parse( + url: Uri.parse( "https://api.ChangeNow.io/v1/min-amount/xmr_btc?api_key=testAPIKEY"), headers: {'Content-Type': 'application/json'}, - )).thenAnswer((realInvocation) async => Response('', 400)); + proxyInfo: null, + )).thenAnswer((realInvocation) async => Response(utf8.encode(''), 400)); - final result = await ChangeNowAPI.instance.getMinimalExchangeAmount( + final result = await instance.getMinimalExchangeAmount( fromTicker: "xmr", toTicker: "btc", apiKey: "testAPIKEY", @@ -272,18 +284,20 @@ void main() { group("getEstimatedExchangeAmount", () { test("getEstimatedExchangeAmount succeeds", () async { - final client = MockClient(); - ChangeNowAPI.instance.client = client; + final client = MockHTTP(); + final instance = ChangeNowAPI(http: client); when(client.get( - Uri.parse( + url: Uri.parse( "https://api.ChangeNow.io/v1/exchange-amount/42/xmr_btc?api_key=testAPIKEY"), headers: {'Content-Type': 'application/json'}, + proxyInfo: null, )).thenAnswer((realInvocation) async => Response( - '{"estimatedAmount": 58.4142873, "transactionSpeedForecast": "10-60", "warningMessage": null}', + utf8.encode( + '{"estimatedAmount": 58.4142873, "transactionSpeedForecast": "10-60", "warningMessage": null}'), 200)); - final result = await ChangeNowAPI.instance.getEstimatedExchangeAmount( + final result = await instance.getEstimatedExchangeAmount( fromTicker: "xmr", toTicker: "btc", fromAmount: Decimal.fromInt(42), @@ -298,16 +312,18 @@ void main() { test( "getEstimatedExchangeAmount fails with ChangeNowExceptionType.serializeResponseError", () async { - final client = MockClient(); - ChangeNowAPI.instance.client = client; + final client = MockHTTP(); + final instance = ChangeNowAPI(http: client); when(client.get( - Uri.parse( + url: Uri.parse( "https://api.ChangeNow.io/v1/exchange-amount/42/xmr_btc?api_key=testAPIKEY"), headers: {'Content-Type': 'application/json'}, - )).thenAnswer((realInvocation) async => Response('{"error": 42}', 200)); + proxyInfo: null, + )).thenAnswer((realInvocation) async => + Response(utf8.encode('{"error": 42}'), 200)); - final result = await ChangeNowAPI.instance.getEstimatedExchangeAmount( + final result = await instance.getEstimatedExchangeAmount( fromTicker: "xmr", toTicker: "btc", fromAmount: Decimal.fromInt(42), @@ -320,16 +336,17 @@ void main() { }); test("getEstimatedExchangeAmount fails for any other reason", () async { - final client = MockClient(); - ChangeNowAPI.instance.client = client; + final client = MockHTTP(); + final instance = ChangeNowAPI(http: client); when(client.get( - Uri.parse( + url: Uri.parse( "https://api.ChangeNow.io/v1/exchange-amount/42/xmr_btc?api_key=testAPIKEY"), headers: {'Content-Type': 'application/json'}, - )).thenAnswer((realInvocation) async => Response('', 400)); + proxyInfo: null, + )).thenAnswer((realInvocation) async => Response(utf8.encode(''), 400)); - final result = await ChangeNowAPI.instance.getEstimatedExchangeAmount( + final result = await instance.getEstimatedExchangeAmount( fromTicker: "xmr", toTicker: "btc", fromAmount: Decimal.fromInt(42), @@ -343,15 +360,16 @@ void main() { // group("getEstimatedFixedRateExchangeAmount", () { // test("getEstimatedFixedRateExchangeAmount succeeds", () async { - // final client = MockClient(); + // final client = MockHTTP(); // ChangeNow.instance.client = client; // - // when(client.get( + // when(client.get(url: // Uri.parse( // "https://api.ChangeNow.io/v1/exchange-amount/fixed-rate/10/xmr_btc?api_key=testAPIKEY&useRateId=true"), // headers: {'Content-Type': 'application/json'}, + // proxyInfo: null, // )).thenAnswer((realInvocation) async => - // Response(jsonEncode(estFixedRateExchangeAmountJSON), 200)); + // Response(utf8.encode(jsonEncode(estFixedRateExchangeAmountJSON )), 200)); // // final result = // await ChangeNow.instance.getEstimatedFixedRateExchangeAmount( @@ -370,13 +388,14 @@ void main() { // test( // "getEstimatedFixedRateExchangeAmount fails with ChangeNowExceptionType.serializeResponseError", // () async { - // final client = MockClient(); + // final client = MockHTTP(); // ChangeNow.instance.client = client; // - // when(client.get( + // when(client.get(url: // Uri.parse( // "https://api.ChangeNow.io/v1/exchange-amount/fixed-rate/10/xmr_btc?api_key=testAPIKEY&useRateId=true"), // headers: {'Content-Type': 'application/json'}, + // proxyInfo: null, // )).thenAnswer((realInvocation) async => Response('{"error": 42}', 200)); // // final result = @@ -394,13 +413,14 @@ void main() { // // test("getEstimatedFixedRateExchangeAmount fails for any other reason", // () async { - // final client = MockClient(); + // final client = MockHTTP(); // ChangeNow.instance.client = client; // - // when(client.get( + // when(client.get(url: // Uri.parse( // "https://api.ChangeNow.io/v1/exchange-amount/fixed-rate/10/xmr_btc?api_key=testAPIKEY&useRateId=true"), // headers: {'Content-Type': 'application/json'}, + // proxyInfo: null, // )).thenAnswer((realInvocation) async => Response('', 400)); // // final result = @@ -418,17 +438,18 @@ void main() { group("getAvailableFixedRateMarkets", () { test("getAvailableFixedRateMarkets succeeds", () async { - final client = MockClient(); - ChangeNowAPI.instance.client = client; + final client = MockHTTP(); + final instance = ChangeNowAPI(http: client); when(client.get( - Uri.parse( + url: Uri.parse( "https://api.ChangeNow.io/v1/market-info/fixed-rate/testAPIKEY"), headers: {'Content-Type': 'application/json'}, + proxyInfo: null, )).thenAnswer((realInvocation) async => - Response(jsonEncode(fixedRateMarketsJSON), 200)); + Response(utf8.encode(jsonEncode(fixedRateMarketsJSON)), 200)); - final result = await ChangeNowAPI.instance.getAvailableFixedRateMarkets( + final result = await instance.getAvailableFixedRateMarkets( apiKey: "testAPIKEY", ); @@ -440,16 +461,18 @@ void main() { test( "getAvailableFixedRateMarkets fails with ChangeNowExceptionType.serializeResponseError", () async { - final client = MockClient(); - ChangeNowAPI.instance.client = client; + final client = MockHTTP(); + final instance = ChangeNowAPI(http: client); when(client.get( - Uri.parse( + url: Uri.parse( "https://api.ChangeNow.io/v1/market-info/fixed-rate/testAPIKEY"), headers: {'Content-Type': 'application/json'}, - )).thenAnswer((realInvocation) async => Response('{"error": 42}', 200)); + proxyInfo: null, + )).thenAnswer((realInvocation) async => + Response(utf8.encode('{"error": 42}'), 200)); - final result = await ChangeNowAPI.instance.getAvailableFixedRateMarkets( + final result = await instance.getAvailableFixedRateMarkets( apiKey: "testAPIKEY", ); @@ -459,16 +482,17 @@ void main() { }); test("getAvailableFixedRateMarkets fails for any other reason", () async { - final client = MockClient(); - ChangeNowAPI.instance.client = client; + final client = MockHTTP(); + final instance = ChangeNowAPI(http: client); when(client.get( - Uri.parse( + url: Uri.parse( "https://api.ChangeNow.io/v1/market-info/fixed-rate/testAPIKEY"), headers: {'Content-Type': 'application/json'}, - )).thenAnswer((realInvocation) async => Response('', 400)); + proxyInfo: null, + )).thenAnswer((realInvocation) async => Response(utf8.encode(''), 400)); - final result = await ChangeNowAPI.instance.getAvailableFixedRateMarkets( + final result = await instance.getAvailableFixedRateMarkets( apiKey: "testAPIKEY", ); @@ -480,20 +504,20 @@ void main() { group("createStandardExchangeTransaction", () { test("createStandardExchangeTransaction succeeds", () async { - final client = MockClient(); - ChangeNowAPI.instance.client = client; + final client = MockHTTP(); + final instance = ChangeNowAPI(http: client); when(client.post( - Uri.parse("https://api.ChangeNow.io/v1/transactions/testAPIKEY"), + url: Uri.parse("https://api.ChangeNow.io/v1/transactions/testAPIKEY"), headers: {'Content-Type': 'application/json'}, + proxyInfo: null, body: '{"from":"xmr","to":"btc","address":"bc1qu58svs9983e2vuyqh7gq7ratf8k5qehz5k0cn5","amount":"0.3","flow":"standard","extraId":"","userId":"","contactEmail":"","refundAddress":"888tNkZrPN6JsEgekjMnABU4TBzc2Dt29EPAvkRxbANsAnjyPbb3iQ1YBRk1UXcdRsiKc9dhwMVgN5S9cQUiyoogDavup3H","refundExtraId":""}', encoding: null, - )).thenAnswer((realInvocation) async => - Response(jsonEncode(createStandardTransactionResponse), 200)); + )).thenAnswer((realInvocation) async => Response( + utf8.encode(jsonEncode(createStandardTransactionResponse)), 200)); - final result = - await ChangeNowAPI.instance.createStandardExchangeTransaction( + final result = await instance.createStandardExchangeTransaction( fromTicker: "xmr", toTicker: "btc", receivingAddress: "bc1qu58svs9983e2vuyqh7gq7ratf8k5qehz5k0cn5", @@ -511,19 +535,20 @@ void main() { test( "createStandardExchangeTransaction fails with ChangeNowExceptionType.serializeResponseError", () async { - final client = MockClient(); - ChangeNowAPI.instance.client = client; + final client = MockHTTP(); + final instance = ChangeNowAPI(http: client); when(client.post( - Uri.parse("https://api.ChangeNow.io/v1/transactions/testAPIKEY"), + url: Uri.parse("https://api.ChangeNow.io/v1/transactions/testAPIKEY"), headers: {'Content-Type': 'application/json'}, + proxyInfo: null, body: '{"from":"xmr","to":"btc","address":"bc1qu58svs9983e2vuyqh7gq7ratf8k5qehz5k0cn5","amount":"0.3","flow":"standard","extraId":"","userId":"","contactEmail":"","refundAddress":"888tNkZrPN6JsEgekjMnABU4TBzc2Dt29EPAvkRxbANsAnjyPbb3iQ1YBRk1UXcdRsiKc9dhwMVgN5S9cQUiyoogDavup3H","refundExtraId":""}', encoding: null, - )).thenAnswer((realInvocation) async => Response('{"error": 42}', 200)); + )).thenAnswer((realInvocation) async => + Response(utf8.encode('{"error": 42}'), 200)); - final result = - await ChangeNowAPI.instance.createStandardExchangeTransaction( + final result = await instance.createStandardExchangeTransaction( fromTicker: "xmr", toTicker: "btc", receivingAddress: "bc1qu58svs9983e2vuyqh7gq7ratf8k5qehz5k0cn5", @@ -540,19 +565,19 @@ void main() { test("createStandardExchangeTransaction fails for any other reason", () async { - final client = MockClient(); - ChangeNowAPI.instance.client = client; + final client = MockHTTP(); + final instance = ChangeNowAPI(http: client); when(client.post( - Uri.parse("https://api.ChangeNow.io/v1/transactions/testAPIKEY"), + url: Uri.parse("https://api.ChangeNow.io/v1/transactions/testAPIKEY"), headers: {'Content-Type': 'application/json'}, + proxyInfo: null, body: '{"from":"xmr","to":"btc","address":"bc1qu58svs9983e2vuyqh7gq7ratf8k5qehz5k0cn5","amount":"0.3","flow":"standard","extraId":"","userId":"","contactEmail":"","refundAddress":"888tNkZrPN6JsEgekjMnABU4TBzc2Dt29EPAvkRxbANsAnjyPbb3iQ1YBRk1UXcdRsiKc9dhwMVgN5S9cQUiyoogDavup3H","refundExtraId":""}', encoding: null, - )).thenAnswer((realInvocation) async => Response('', 400)); + )).thenAnswer((realInvocation) async => Response(utf8.encode(''), 400)); - final result = - await ChangeNowAPI.instance.createStandardExchangeTransaction( + final result = await instance.createStandardExchangeTransaction( fromTicker: "xmr", toTicker: "btc", receivingAddress: "bc1qu58svs9983e2vuyqh7gq7ratf8k5qehz5k0cn5", @@ -569,22 +594,27 @@ void main() { group("createFixedRateExchangeTransaction", () { test("createFixedRateExchangeTransaction succeeds", () async { - final client = MockClient(); - ChangeNowAPI.instance.client = client; + final client = MockHTTP(); + final instance = ChangeNowAPI(http: client); when(client.post( - Uri.parse( + url: Uri.parse( "https://api.ChangeNow.io/v1/transactions/fixed-rate/testAPIKEY"), headers: {'Content-Type': 'application/json'}, + proxyInfo: null, body: '{"from":"btc","to":"eth","address":"0x57f31ad4b64095347F87eDB1675566DAfF5EC886","flow":"fixed-rate","extraId":"","userId":"","contactEmail":"","refundAddress":"","refundExtraId":"","rateId":"","amount":"0.3"}', encoding: null, )).thenAnswer((realInvocation) async => Response( - '{"payinAddress": "33eFX2jfeWbXMSmRe9ewUUTrmSVSxZi5cj", "payoutAddress": "0x57f31ad4b64095347F87eDB1675566DAfF5EC886","payoutExtraId": "", "fromCurrency": "btc", "toCurrency": "eth", "refundAddress": "","refundExtraId": "","validUntil": "2019-09-09T14:01:04.921Z","id": "a5c73e2603f40d","amount": 62.9737711}', + utf8.encode( + '{"payinAddress": "33eFX2jfeWbXMSmRe9ewUUTrmSVSxZi5cj", "payoutAddress":' + ' "0x57f31ad4b64095347F87eDB1675566DAfF5EC886","payoutExtraId": "",' + ' "fromCurrency": "btc", "toCurrency": "eth", "refundAddress": "",' + '"refundExtraId": "","validUntil": "2019-09-09T14:01:04.921Z","id":' + ' "a5c73e2603f40d","amount": 62.9737711}'), 200)); - final result = - await ChangeNowAPI.instance.createFixedRateExchangeTransaction( + final result = await instance.createFixedRateExchangeTransaction( fromTicker: "btc", toTicker: "eth", receivingAddress: "0x57f31ad4b64095347F87eDB1675566DAfF5EC886", @@ -603,21 +633,21 @@ void main() { test( "createFixedRateExchangeTransaction fails with ChangeNowExceptionType.serializeResponseError", () async { - final client = MockClient(); - ChangeNowAPI.instance.client = client; + final client = MockHTTP(); + final instance = ChangeNowAPI(http: client); when(client.post( - Uri.parse( + url: Uri.parse( "https://api.ChangeNow.io/v1/transactions/fixed-rate/testAPIKEY"), headers: {'Content-Type': 'application/json'}, + proxyInfo: null, body: '{"from":"btc","to":"eth","address":"0x57f31ad4b64095347F87eDB1675566DAfF5EC886","amount":"0.3","flow":"fixed-rate","extraId":"","userId":"","contactEmail":"","refundAddress":"","refundExtraId":"","rateId":""}', encoding: null, - )).thenAnswer((realInvocation) async => - Response('{"id": "a5c73e2603f40d","amount": 62.9737711}', 200)); + )).thenAnswer((realInvocation) async => Response( + utf8.encode('{"id": "a5c73e2603f40d","amount": 62.9737711}'), 200)); - final result = - await ChangeNowAPI.instance.createFixedRateExchangeTransaction( + final result = await instance.createFixedRateExchangeTransaction( fromTicker: "btc", toTicker: "eth", receivingAddress: "0x57f31ad4b64095347F87eDB1675566DAfF5EC886", @@ -634,20 +664,20 @@ void main() { test("createFixedRateExchangeTransaction fails for any other reason", () async { - final client = MockClient(); - ChangeNowAPI.instance.client = client; + final client = MockHTTP(); + final instance = ChangeNowAPI(http: client); when(client.post( - Uri.parse( + url: Uri.parse( "https://api.ChangeNow.io/v1/transactions/fixed-rate/testAPIKEY"), headers: {'Content-Type': 'application/json'}, + proxyInfo: null, body: '{"from": "btc","to": "eth","address": "0x57f31ad4b64095347F87eDB1675566DAfF5EC886", "amount": "1.12345","extraId": "", "userId": "","contactEmail": "","refundAddress": "", "refundExtraId": "", "rateId": "" }', encoding: null, - )).thenAnswer((realInvocation) async => Response('', 400)); + )).thenAnswer((realInvocation) async => Response(utf8.encode(''), 400)); - final result = - await ChangeNowAPI.instance.createFixedRateExchangeTransaction( + final result = await instance.createFixedRateExchangeTransaction( fromTicker: "xmr", toTicker: "btc", receivingAddress: "bc1qu58svs9983e2vuyqh7gq7ratf8k5qehz5k0cn5", @@ -666,18 +696,25 @@ void main() { group("getTransactionStatus", () { test("getTransactionStatus succeeds", () async { - final client = MockClient(); - ChangeNowAPI.instance.client = client; + final client = MockHTTP(); + final instance = ChangeNowAPI(http: client); when(client.get( - Uri.parse( + url: Uri.parse( "https://api.ChangeNow.io/v1/transactions/47F87eDB1675566DAfF5EC886/testAPIKEY"), headers: {'Content-Type': 'application/json'}, + proxyInfo: null, )).thenAnswer((realInvocation) async => Response( - '{"status": "waiting", "payinAddress": "32Ge2ci26rj1sRGw2NjiQa9L7Xvxtgzhrj", "payoutAddress": "0x57f31ad4b64095347F87eDB1675566DAfF5EC886", "fromCurrency": "btc", "toCurrency": "eth", "id": "50727663e5d9a4", "updatedAt": "2019-08-22T14:47:49.943Z", "expectedSendAmount": 1, "expectedReceiveAmount": 52.31667, "createdAt": "2019-08-22T14:47:49.943Z", "isPartner": false}', + utf8.encode( + '{"status": "waiting", "payinAddress": "32Ge2ci26rj1sRGw2NjiQa9L7Xvxtgzhrj", ' + '"payoutAddress": "0x57f31ad4b64095347F87eDB1675566DAfF5EC886", ' + '"fromCurrency": "btc", "toCurrency": "eth", "id": "50727663e5d9a4", ' + '"updatedAt": "2019-08-22T14:47:49.943Z", "expectedSendAmount": 1, ' + '"expectedReceiveAmount": 52.31667, "createdAt": "2019-08-22T14:47:49.943Z",' + ' "isPartner": false}'), 200)); - final result = await ChangeNowAPI.instance.getTransactionStatus( + final result = await instance.getTransactionStatus( id: "47F87eDB1675566DAfF5EC886", apiKey: "testAPIKEY", ); @@ -690,16 +727,18 @@ void main() { test( "getTransactionStatus fails with ChangeNowExceptionType.serializeResponseError", () async { - final client = MockClient(); - ChangeNowAPI.instance.client = client; + final client = MockHTTP(); + final instance = ChangeNowAPI(http: client); when(client.get( - Uri.parse( + url: Uri.parse( "https://api.ChangeNow.io/v1/transactions/47F87eDB1675566DAfF5EC886/testAPIKEY"), headers: {'Content-Type': 'application/json'}, - )).thenAnswer((realInvocation) async => Response('{"error": 42}', 200)); + proxyInfo: null, + )).thenAnswer((realInvocation) async => + Response(utf8.encode('{"error": 42}'), 200)); - final result = await ChangeNowAPI.instance.getTransactionStatus( + final result = await instance.getTransactionStatus( id: "47F87eDB1675566DAfF5EC886", apiKey: "testAPIKEY", ); @@ -710,16 +749,17 @@ void main() { }); test("getTransactionStatus fails for any other reason", () async { - final client = MockClient(); - ChangeNowAPI.instance.client = client; + final client = MockHTTP(); + final instance = ChangeNowAPI(http: client); when(client.get( - Uri.parse( + url: Uri.parse( "https://api.ChangeNow.io/v1/transactions/47F87eDB1675566DAfF5EC886/testAPIKEY"), headers: {'Content-Type': 'application/json'}, - )).thenAnswer((realInvocation) async => Response('', 400)); + proxyInfo: null, + )).thenAnswer((realInvocation) async => Response(utf8.encode(''), 400)); - final result = await ChangeNowAPI.instance.getTransactionStatus( + final result = await instance.getTransactionStatus( id: "47F87eDB1675566DAfF5EC886", apiKey: "testAPIKEY", ); @@ -732,18 +772,18 @@ void main() { group("getAvailableFloatingRatePairs", () { test("getAvailableFloatingRatePairs succeeds", () async { - final client = MockClient(); - ChangeNowAPI.instance.client = client; + final client = MockHTTP(); + final instance = ChangeNowAPI(http: client); when(client.get( - Uri.parse( + url: Uri.parse( "https://api.ChangeNow.io/v1/market-info/available-pairs?includePartners=false"), headers: {'Content-Type': 'application/json'}, - )).thenAnswer((realInvocation) async => - Response('["btc_xmr","btc_firo","btc_doge","eth_ltc"]', 200)); + proxyInfo: null, + )).thenAnswer((realInvocation) async => Response( + utf8.encode('["btc_xmr","btc_firo","btc_doge","eth_ltc"]'), 200)); - final result = - await ChangeNowAPI.instance.getAvailableFloatingRatePairs(); + final result = await instance.getAvailableFloatingRatePairs(); expect(result.exception, null); expect(result.value == null, false); @@ -753,17 +793,18 @@ void main() { test( "getAvailableFloatingRatePairs fails with ChangeNowExceptionType.serializeResponseError", () async { - final client = MockClient(); - ChangeNowAPI.instance.client = client; + final client = MockHTTP(); + final instance = ChangeNowAPI(http: client); when(client.get( - Uri.parse( + url: Uri.parse( "https://api.ChangeNow.io/v1/market-info/available-pairs?includePartners=false"), headers: {'Content-Type': 'application/json'}, - )).thenAnswer((realInvocation) async => Response('{"error": 42}', 200)); + proxyInfo: null, + )).thenAnswer((realInvocation) async => + Response(utf8.encode('{"error": 42}'), 200)); - final result = - await ChangeNowAPI.instance.getAvailableFloatingRatePairs(); + final result = await instance.getAvailableFloatingRatePairs(); expect( result.exception!.type, ExchangeExceptionType.serializeResponseError); @@ -771,17 +812,17 @@ void main() { }); test("getAvailableFloatingRatePairs fails for any other reason", () async { - final client = MockClient(); - ChangeNowAPI.instance.client = client; + final client = MockHTTP(); + final instance = ChangeNowAPI(http: client); when(client.get( - Uri.parse( + url: Uri.parse( "https://api.ChangeNow.io/v1/market-info/available-pairs?includePartners=false"), headers: {'Content-Type': 'application/json'}, - )).thenAnswer((realInvocation) async => Response('', 400)); + proxyInfo: null, + )).thenAnswer((realInvocation) async => Response(utf8.encode(''), 400)); - final result = - await ChangeNowAPI.instance.getAvailableFloatingRatePairs(); + final result = await instance.getAvailableFloatingRatePairs(); expect( result.exception!.type, ExchangeExceptionType.serializeResponseError); diff --git a/test/services/change_now/change_now_test.mocks.dart b/test/services/change_now/change_now_test.mocks.dart index 21ccddff8..f0b375d72 100644 --- a/test/services/change_now/change_now_test.mocks.dart +++ b/test/services/change_now/change_now_test.mocks.dart @@ -4,11 +4,11 @@ // ignore_for_file: no_leading_underscores_for_library_prefixes import 'dart:async' as _i3; -import 'dart:convert' as _i4; -import 'dart:typed_data' as _i5; +import 'dart:convert' as _i5; +import 'dart:io' as _i4; -import 'package:http/http.dart' as _i2; import 'package:mockito/mockito.dart' as _i1; +import 'package:stackwallet/networking/http.dart' as _i2; // ignore_for_file: type=lint // ignore_for_file: avoid_redundant_argument_values @@ -31,233 +31,76 @@ class _FakeResponse_0 extends _i1.SmartFake implements _i2.Response { ); } -class _FakeStreamedResponse_1 extends _i1.SmartFake - implements _i2.StreamedResponse { - _FakeStreamedResponse_1( - Object parent, - Invocation parentInvocation, - ) : super( - parent, - parentInvocation, - ); -} - -/// A class which mocks [Client]. +/// A class which mocks [HTTP]. /// /// See the documentation for Mockito's code generation for more information. -class MockClient extends _i1.Mock implements _i2.Client { - MockClient() { +class MockHTTP extends _i1.Mock implements _i2.HTTP { + MockHTTP() { _i1.throwOnMissingStub(this); } @override - _i3.Future<_i2.Response> head( - Uri? url, { - Map? headers, - }) => - (super.noSuchMethod( - Invocation.method( - #head, - [url], - {#headers: headers}, - ), - returnValue: _i3.Future<_i2.Response>.value(_FakeResponse_0( - this, - Invocation.method( - #head, - [url], - {#headers: headers}, - ), - )), - ) as _i3.Future<_i2.Response>); - @override - _i3.Future<_i2.Response> get( - Uri? url, { + _i3.Future<_i2.Response> get({ + required Uri? url, Map? headers, + required ({_i4.InternetAddress host, int port})? proxyInfo, }) => (super.noSuchMethod( Invocation.method( #get, - [url], - {#headers: headers}, + [], + { + #url: url, + #headers: headers, + #proxyInfo: proxyInfo, + }, ), returnValue: _i3.Future<_i2.Response>.value(_FakeResponse_0( this, Invocation.method( #get, - [url], - {#headers: headers}, + [], + { + #url: url, + #headers: headers, + #proxyInfo: proxyInfo, + }, ), )), ) as _i3.Future<_i2.Response>); @override - _i3.Future<_i2.Response> post( - Uri? url, { + _i3.Future<_i2.Response> post({ + required Uri? url, Map? headers, Object? body, - _i4.Encoding? encoding, + _i5.Encoding? encoding, + required ({_i4.InternetAddress host, int port})? proxyInfo, }) => (super.noSuchMethod( Invocation.method( #post, - [url], + [], { + #url: url, #headers: headers, #body: body, #encoding: encoding, + #proxyInfo: proxyInfo, }, ), returnValue: _i3.Future<_i2.Response>.value(_FakeResponse_0( this, Invocation.method( #post, - [url], + [], { + #url: url, #headers: headers, #body: body, #encoding: encoding, + #proxyInfo: proxyInfo, }, ), )), ) as _i3.Future<_i2.Response>); - @override - _i3.Future<_i2.Response> put( - Uri? url, { - Map? headers, - Object? body, - _i4.Encoding? encoding, - }) => - (super.noSuchMethod( - Invocation.method( - #put, - [url], - { - #headers: headers, - #body: body, - #encoding: encoding, - }, - ), - returnValue: _i3.Future<_i2.Response>.value(_FakeResponse_0( - this, - Invocation.method( - #put, - [url], - { - #headers: headers, - #body: body, - #encoding: encoding, - }, - ), - )), - ) as _i3.Future<_i2.Response>); - @override - _i3.Future<_i2.Response> patch( - Uri? url, { - Map? headers, - Object? body, - _i4.Encoding? encoding, - }) => - (super.noSuchMethod( - Invocation.method( - #patch, - [url], - { - #headers: headers, - #body: body, - #encoding: encoding, - }, - ), - returnValue: _i3.Future<_i2.Response>.value(_FakeResponse_0( - this, - Invocation.method( - #patch, - [url], - { - #headers: headers, - #body: body, - #encoding: encoding, - }, - ), - )), - ) as _i3.Future<_i2.Response>); - @override - _i3.Future<_i2.Response> delete( - Uri? url, { - Map? headers, - Object? body, - _i4.Encoding? encoding, - }) => - (super.noSuchMethod( - Invocation.method( - #delete, - [url], - { - #headers: headers, - #body: body, - #encoding: encoding, - }, - ), - returnValue: _i3.Future<_i2.Response>.value(_FakeResponse_0( - this, - Invocation.method( - #delete, - [url], - { - #headers: headers, - #body: body, - #encoding: encoding, - }, - ), - )), - ) as _i3.Future<_i2.Response>); - @override - _i3.Future read( - Uri? url, { - Map? headers, - }) => - (super.noSuchMethod( - Invocation.method( - #read, - [url], - {#headers: headers}, - ), - returnValue: _i3.Future.value(''), - ) as _i3.Future); - @override - _i3.Future<_i5.Uint8List> readBytes( - Uri? url, { - Map? headers, - }) => - (super.noSuchMethod( - Invocation.method( - #readBytes, - [url], - {#headers: headers}, - ), - returnValue: _i3.Future<_i5.Uint8List>.value(_i5.Uint8List(0)), - ) as _i3.Future<_i5.Uint8List>); - @override - _i3.Future<_i2.StreamedResponse> send(_i2.BaseRequest? request) => - (super.noSuchMethod( - Invocation.method( - #send, - [request], - ), - returnValue: - _i3.Future<_i2.StreamedResponse>.value(_FakeStreamedResponse_1( - this, - Invocation.method( - #send, - [request], - ), - )), - ) as _i3.Future<_i2.StreamedResponse>); - @override - void close() => super.noSuchMethod( - Invocation.method( - #close, - [], - ), - returnValueForMissingStub: null, - ); } diff --git a/test/services/coins/bitcoincash/bitcoincash_wallet_test.dart b/test/services/coins/bitcoincash/bitcoincash_wallet_test.dart index 661c9a1b7..f3598dfa1 100644 --- a/test/services/coins/bitcoincash/bitcoincash_wallet_test.dart +++ b/test/services/coins/bitcoincash/bitcoincash_wallet_test.dart @@ -626,7 +626,8 @@ void main() async { await Hive.openBox(testWalletId); await Hive.openBox(DB.boxNamePrefs); - await expectLater(() => bch?.initializeNew(), throwsA(isA())) + await expectLater( + () => bch?.initializeNew(null), throwsA(isA())) .then((_) { expect(secureStore.interactions, 2); verifyNever(client?.ping()).called(0); diff --git a/test/services/coins/dogecoin/dogecoin_wallet_test.dart b/test/services/coins/dogecoin/dogecoin_wallet_test.dart index 712000aae..32872dd04 100644 --- a/test/services/coins/dogecoin/dogecoin_wallet_test.dart +++ b/test/services/coins/dogecoin/dogecoin_wallet_test.dart @@ -483,7 +483,8 @@ void main() { await Hive.openBox(testWalletId); await Hive.openBox(DB.boxNamePrefs); - await expectLater(() => doge?.initializeNew(), throwsA(isA())) + await expectLater( + () => doge?.initializeNew(null), throwsA(isA())) .then((_) { expect(secureStore.interactions, 2); verifyNever(client?.ping()).called(0); diff --git a/test/services/coins/fake_coin_service_api.dart b/test/services/coins/fake_coin_service_api.dart index ea70545d1..413c493ab 100644 --- a/test/services/coins/fake_coin_service_api.dart +++ b/test/services/coins/fake_coin_service_api.dart @@ -88,7 +88,9 @@ class FakeCoinServiceAPI extends CoinServiceAPI { } @override - Future initializeNew() { + Future initializeNew( + ({String mnemonicPassphrase, int wordCount})? data, + ) { // TODO: implement initializeNew throw UnimplementedError(); } diff --git a/test/services/coins/firo/firo_wallet_test.dart b/test/services/coins/firo/firo_wallet_test.dart index 2bda494fc..05b4aeeff 100644 --- a/test/services/coins/firo/firo_wallet_test.dart +++ b/test/services/coins/firo/firo_wallet_test.dart @@ -2286,8 +2286,8 @@ void main() { when(cachedClient.getAnonymitySet( groupId: "1", blockhash: "", coin: Coin.firo)) .thenAnswer((_) async => GetAnonymitySetSampleData.data); - when(cachedClient.getUsedCoinSerials(coin: Coin.firo)).thenAnswer( - (_) async => List.from( + when(cachedClient.getUsedCoinSerials(startNumber: 0, coin: Coin.firo)) + .thenAnswer((_) async => List.from( GetUsedSerialsSampleData.serials['serials'] as List)); final firo = FiroWallet( diff --git a/test/services/coins/manager_test.mocks.dart b/test/services/coins/manager_test.mocks.dart index ba4c8eb37..17d9efd5f 100644 --- a/test/services/coins/manager_test.mocks.dart +++ b/test/services/coins/manager_test.mocks.dart @@ -304,6 +304,11 @@ class MockFiroWallet extends _i1.Mock implements _i10.FiroWallet { ), ) as _i5.CachedElectrumX); @override + bool get lelantusCoinIsarRescanRequired => (super.noSuchMethod( + Invocation.getter(#lelantusCoinIsarRescanRequired), + returnValue: false, + ) as bool); + @override bool get isRefreshing => (super.noSuchMethod( Invocation.getter(#isRefreshing), returnValue: false, @@ -552,15 +557,35 @@ class MockFiroWallet extends _i1.Mock implements _i10.FiroWallet { returnValueForMissingStub: _i11.Future.value(), ) as _i11.Future); @override - _i11.Future initializeNew() => (super.noSuchMethod( + _i11.Future initializeNew( + ({String mnemonicPassphrase, int wordCount})? data) => + (super.noSuchMethod( Invocation.method( #initializeNew, + [data], + ), + returnValue: _i11.Future.value(), + returnValueForMissingStub: _i11.Future.value(), + ) as _i11.Future); + @override + _i11.Future setLelantusCoinIsarRescanRequiredDone() => + (super.noSuchMethod( + Invocation.method( + #setLelantusCoinIsarRescanRequiredDone, [], ), returnValue: _i11.Future.value(), returnValueForMissingStub: _i11.Future.value(), ) as _i11.Future); @override + _i11.Future firoRescanRecovery() => (super.noSuchMethod( + Invocation.method( + #firoRescanRecovery, + [], + ), + returnValue: _i11.Future.value(false), + ) as _i11.Future); + @override _i11.Future initializeExisting() => (super.noSuchMethod( Invocation.method( #initializeExisting, diff --git a/test/widget_tests/custom_buttons/favorite_toggle_test.mocks.dart b/test/widget_tests/custom_buttons/favorite_toggle_test.mocks.dart index 0abed1954..20727e854 100644 --- a/test/widget_tests/custom_buttons/favorite_toggle_test.mocks.dart +++ b/test/widget_tests/custom_buttons/favorite_toggle_test.mocks.dart @@ -3,13 +3,14 @@ // Do not manually edit this file. // ignore_for_file: no_leading_underscores_for_library_prefixes -import 'dart:async' as _i5; -import 'dart:typed_data' as _i6; +import 'dart:async' as _i6; +import 'dart:typed_data' as _i7; import 'package:mockito/mockito.dart' as _i1; -import 'package:stackwallet/db/isar/main_db.dart' as _i2; -import 'package:stackwallet/models/isar/stack_theme.dart' as _i4; -import 'package:stackwallet/themes/theme_service.dart' as _i3; +import 'package:stackwallet/db/isar/main_db.dart' as _i3; +import 'package:stackwallet/models/isar/stack_theme.dart' as _i5; +import 'package:stackwallet/networking/http.dart' as _i2; +import 'package:stackwallet/themes/theme_service.dart' as _i4; // ignore_for_file: type=lint // ignore_for_file: avoid_redundant_argument_values @@ -22,8 +23,18 @@ import 'package:stackwallet/themes/theme_service.dart' as _i3; // ignore_for_file: camel_case_types // ignore_for_file: subtype_of_sealed_class -class _FakeMainDB_0 extends _i1.SmartFake implements _i2.MainDB { - _FakeMainDB_0( +class _FakeHTTP_0 extends _i1.SmartFake implements _i2.HTTP { + _FakeHTTP_0( + Object parent, + Invocation parentInvocation, + ) : super( + parent, + parentInvocation, + ); +} + +class _FakeMainDB_1 extends _i1.SmartFake implements _i3.MainDB { + _FakeMainDB_1( Object parent, Invocation parentInvocation, ) : super( @@ -35,26 +46,42 @@ class _FakeMainDB_0 extends _i1.SmartFake implements _i2.MainDB { /// A class which mocks [ThemeService]. /// /// See the documentation for Mockito's code generation for more information. -class MockThemeService extends _i1.Mock implements _i3.ThemeService { +class MockThemeService extends _i1.Mock implements _i4.ThemeService { MockThemeService() { _i1.throwOnMissingStub(this); } @override - _i2.MainDB get db => (super.noSuchMethod( + _i2.HTTP get client => (super.noSuchMethod( + Invocation.getter(#client), + returnValue: _FakeHTTP_0( + this, + Invocation.getter(#client), + ), + ) as _i2.HTTP); + @override + set client(_i2.HTTP? _client) => super.noSuchMethod( + Invocation.setter( + #client, + _client, + ), + returnValueForMissingStub: null, + ); + @override + _i3.MainDB get db => (super.noSuchMethod( Invocation.getter(#db), - returnValue: _FakeMainDB_0( + returnValue: _FakeMainDB_1( this, Invocation.getter(#db), ), - ) as _i2.MainDB); + ) as _i3.MainDB); @override - List<_i4.StackTheme> get installedThemes => (super.noSuchMethod( + List<_i5.StackTheme> get installedThemes => (super.noSuchMethod( Invocation.getter(#installedThemes), - returnValue: <_i4.StackTheme>[], - ) as List<_i4.StackTheme>); + returnValue: <_i5.StackTheme>[], + ) as List<_i5.StackTheme>); @override - void init(_i2.MainDB? db) => super.noSuchMethod( + void init(_i3.MainDB? db) => super.noSuchMethod( Invocation.method( #init, [db], @@ -62,70 +89,70 @@ class MockThemeService extends _i1.Mock implements _i3.ThemeService { returnValueForMissingStub: null, ); @override - _i5.Future install({required _i6.Uint8List? themeArchiveData}) => + _i6.Future install({required _i7.Uint8List? themeArchiveData}) => (super.noSuchMethod( Invocation.method( #install, [], {#themeArchiveData: themeArchiveData}, ), - returnValue: _i5.Future.value(), - returnValueForMissingStub: _i5.Future.value(), - ) as _i5.Future); + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); @override - _i5.Future remove({required String? themeId}) => (super.noSuchMethod( + _i6.Future remove({required String? themeId}) => (super.noSuchMethod( Invocation.method( #remove, [], {#themeId: themeId}, ), - returnValue: _i5.Future.value(), - returnValueForMissingStub: _i5.Future.value(), - ) as _i5.Future); + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); @override - _i5.Future checkDefaultThemesOnStartup() => (super.noSuchMethod( + _i6.Future checkDefaultThemesOnStartup() => (super.noSuchMethod( Invocation.method( #checkDefaultThemesOnStartup, [], ), - returnValue: _i5.Future.value(), - returnValueForMissingStub: _i5.Future.value(), - ) as _i5.Future); + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); @override - _i5.Future verifyInstalled({required String? themeId}) => + _i6.Future verifyInstalled({required String? themeId}) => (super.noSuchMethod( Invocation.method( #verifyInstalled, [], {#themeId: themeId}, ), - returnValue: _i5.Future.value(false), - ) as _i5.Future); + returnValue: _i6.Future.value(false), + ) as _i6.Future); @override - _i5.Future> fetchThemes() => (super.noSuchMethod( + _i6.Future> fetchThemes() => (super.noSuchMethod( Invocation.method( #fetchThemes, [], ), - returnValue: _i5.Future>.value( - <_i3.StackThemeMetaData>[]), - ) as _i5.Future>); + returnValue: _i6.Future>.value( + <_i4.StackThemeMetaData>[]), + ) as _i6.Future>); @override - _i5.Future<_i6.Uint8List> fetchTheme( - {required _i3.StackThemeMetaData? themeMetaData}) => + _i6.Future<_i7.Uint8List> fetchTheme( + {required _i4.StackThemeMetaData? themeMetaData}) => (super.noSuchMethod( Invocation.method( #fetchTheme, [], {#themeMetaData: themeMetaData}, ), - returnValue: _i5.Future<_i6.Uint8List>.value(_i6.Uint8List(0)), - ) as _i5.Future<_i6.Uint8List>); + returnValue: _i6.Future<_i7.Uint8List>.value(_i7.Uint8List(0)), + ) as _i6.Future<_i7.Uint8List>); @override - _i4.StackTheme? getTheme({required String? themeId}) => + _i5.StackTheme? getTheme({required String? themeId}) => (super.noSuchMethod(Invocation.method( #getTheme, [], {#themeId: themeId}, - )) as _i4.StackTheme?); + )) as _i5.StackTheme?); } diff --git a/test/widget_tests/custom_loading_overlay_test.mocks.dart b/test/widget_tests/custom_loading_overlay_test.mocks.dart index c96558898..142052fa2 100644 --- a/test/widget_tests/custom_loading_overlay_test.mocks.dart +++ b/test/widget_tests/custom_loading_overlay_test.mocks.dart @@ -3,13 +3,14 @@ // Do not manually edit this file. // ignore_for_file: no_leading_underscores_for_library_prefixes -import 'dart:async' as _i5; -import 'dart:typed_data' as _i6; +import 'dart:async' as _i6; +import 'dart:typed_data' as _i7; import 'package:mockito/mockito.dart' as _i1; -import 'package:stackwallet/db/isar/main_db.dart' as _i2; -import 'package:stackwallet/models/isar/stack_theme.dart' as _i4; -import 'package:stackwallet/themes/theme_service.dart' as _i3; +import 'package:stackwallet/db/isar/main_db.dart' as _i3; +import 'package:stackwallet/models/isar/stack_theme.dart' as _i5; +import 'package:stackwallet/networking/http.dart' as _i2; +import 'package:stackwallet/themes/theme_service.dart' as _i4; // ignore_for_file: type=lint // ignore_for_file: avoid_redundant_argument_values @@ -22,8 +23,18 @@ import 'package:stackwallet/themes/theme_service.dart' as _i3; // ignore_for_file: camel_case_types // ignore_for_file: subtype_of_sealed_class -class _FakeMainDB_0 extends _i1.SmartFake implements _i2.MainDB { - _FakeMainDB_0( +class _FakeHTTP_0 extends _i1.SmartFake implements _i2.HTTP { + _FakeHTTP_0( + Object parent, + Invocation parentInvocation, + ) : super( + parent, + parentInvocation, + ); +} + +class _FakeMainDB_1 extends _i1.SmartFake implements _i3.MainDB { + _FakeMainDB_1( Object parent, Invocation parentInvocation, ) : super( @@ -35,26 +46,42 @@ class _FakeMainDB_0 extends _i1.SmartFake implements _i2.MainDB { /// A class which mocks [ThemeService]. /// /// See the documentation for Mockito's code generation for more information. -class MockThemeService extends _i1.Mock implements _i3.ThemeService { +class MockThemeService extends _i1.Mock implements _i4.ThemeService { MockThemeService() { _i1.throwOnMissingStub(this); } @override - _i2.MainDB get db => (super.noSuchMethod( + _i2.HTTP get client => (super.noSuchMethod( + Invocation.getter(#client), + returnValue: _FakeHTTP_0( + this, + Invocation.getter(#client), + ), + ) as _i2.HTTP); + @override + set client(_i2.HTTP? _client) => super.noSuchMethod( + Invocation.setter( + #client, + _client, + ), + returnValueForMissingStub: null, + ); + @override + _i3.MainDB get db => (super.noSuchMethod( Invocation.getter(#db), - returnValue: _FakeMainDB_0( + returnValue: _FakeMainDB_1( this, Invocation.getter(#db), ), - ) as _i2.MainDB); + ) as _i3.MainDB); @override - List<_i4.StackTheme> get installedThemes => (super.noSuchMethod( + List<_i5.StackTheme> get installedThemes => (super.noSuchMethod( Invocation.getter(#installedThemes), - returnValue: <_i4.StackTheme>[], - ) as List<_i4.StackTheme>); + returnValue: <_i5.StackTheme>[], + ) as List<_i5.StackTheme>); @override - void init(_i2.MainDB? db) => super.noSuchMethod( + void init(_i3.MainDB? db) => super.noSuchMethod( Invocation.method( #init, [db], @@ -62,70 +89,70 @@ class MockThemeService extends _i1.Mock implements _i3.ThemeService { returnValueForMissingStub: null, ); @override - _i5.Future install({required _i6.Uint8List? themeArchiveData}) => + _i6.Future install({required _i7.Uint8List? themeArchiveData}) => (super.noSuchMethod( Invocation.method( #install, [], {#themeArchiveData: themeArchiveData}, ), - returnValue: _i5.Future.value(), - returnValueForMissingStub: _i5.Future.value(), - ) as _i5.Future); + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); @override - _i5.Future remove({required String? themeId}) => (super.noSuchMethod( + _i6.Future remove({required String? themeId}) => (super.noSuchMethod( Invocation.method( #remove, [], {#themeId: themeId}, ), - returnValue: _i5.Future.value(), - returnValueForMissingStub: _i5.Future.value(), - ) as _i5.Future); + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); @override - _i5.Future checkDefaultThemesOnStartup() => (super.noSuchMethod( + _i6.Future checkDefaultThemesOnStartup() => (super.noSuchMethod( Invocation.method( #checkDefaultThemesOnStartup, [], ), - returnValue: _i5.Future.value(), - returnValueForMissingStub: _i5.Future.value(), - ) as _i5.Future); + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); @override - _i5.Future verifyInstalled({required String? themeId}) => + _i6.Future verifyInstalled({required String? themeId}) => (super.noSuchMethod( Invocation.method( #verifyInstalled, [], {#themeId: themeId}, ), - returnValue: _i5.Future.value(false), - ) as _i5.Future); + returnValue: _i6.Future.value(false), + ) as _i6.Future); @override - _i5.Future> fetchThemes() => (super.noSuchMethod( + _i6.Future> fetchThemes() => (super.noSuchMethod( Invocation.method( #fetchThemes, [], ), - returnValue: _i5.Future>.value( - <_i3.StackThemeMetaData>[]), - ) as _i5.Future>); + returnValue: _i6.Future>.value( + <_i4.StackThemeMetaData>[]), + ) as _i6.Future>); @override - _i5.Future<_i6.Uint8List> fetchTheme( - {required _i3.StackThemeMetaData? themeMetaData}) => + _i6.Future<_i7.Uint8List> fetchTheme( + {required _i4.StackThemeMetaData? themeMetaData}) => (super.noSuchMethod( Invocation.method( #fetchTheme, [], {#themeMetaData: themeMetaData}, ), - returnValue: _i5.Future<_i6.Uint8List>.value(_i6.Uint8List(0)), - ) as _i5.Future<_i6.Uint8List>); + returnValue: _i6.Future<_i7.Uint8List>.value(_i7.Uint8List(0)), + ) as _i6.Future<_i7.Uint8List>); @override - _i4.StackTheme? getTheme({required String? themeId}) => + _i5.StackTheme? getTheme({required String? themeId}) => (super.noSuchMethod(Invocation.method( #getTheme, [], {#themeId: themeId}, - )) as _i4.StackTheme?); + )) as _i5.StackTheme?); } diff --git a/test/widget_tests/desktop/desktop_scaffold_test.mocks.dart b/test/widget_tests/desktop/desktop_scaffold_test.mocks.dart index 37476e4c3..8507ace66 100644 --- a/test/widget_tests/desktop/desktop_scaffold_test.mocks.dart +++ b/test/widget_tests/desktop/desktop_scaffold_test.mocks.dart @@ -3,13 +3,14 @@ // Do not manually edit this file. // ignore_for_file: no_leading_underscores_for_library_prefixes -import 'dart:async' as _i5; -import 'dart:typed_data' as _i6; +import 'dart:async' as _i6; +import 'dart:typed_data' as _i7; import 'package:mockito/mockito.dart' as _i1; -import 'package:stackwallet/db/isar/main_db.dart' as _i2; -import 'package:stackwallet/models/isar/stack_theme.dart' as _i4; -import 'package:stackwallet/themes/theme_service.dart' as _i3; +import 'package:stackwallet/db/isar/main_db.dart' as _i3; +import 'package:stackwallet/models/isar/stack_theme.dart' as _i5; +import 'package:stackwallet/networking/http.dart' as _i2; +import 'package:stackwallet/themes/theme_service.dart' as _i4; // ignore_for_file: type=lint // ignore_for_file: avoid_redundant_argument_values @@ -22,8 +23,18 @@ import 'package:stackwallet/themes/theme_service.dart' as _i3; // ignore_for_file: camel_case_types // ignore_for_file: subtype_of_sealed_class -class _FakeMainDB_0 extends _i1.SmartFake implements _i2.MainDB { - _FakeMainDB_0( +class _FakeHTTP_0 extends _i1.SmartFake implements _i2.HTTP { + _FakeHTTP_0( + Object parent, + Invocation parentInvocation, + ) : super( + parent, + parentInvocation, + ); +} + +class _FakeMainDB_1 extends _i1.SmartFake implements _i3.MainDB { + _FakeMainDB_1( Object parent, Invocation parentInvocation, ) : super( @@ -35,26 +46,42 @@ class _FakeMainDB_0 extends _i1.SmartFake implements _i2.MainDB { /// A class which mocks [ThemeService]. /// /// See the documentation for Mockito's code generation for more information. -class MockThemeService extends _i1.Mock implements _i3.ThemeService { +class MockThemeService extends _i1.Mock implements _i4.ThemeService { MockThemeService() { _i1.throwOnMissingStub(this); } @override - _i2.MainDB get db => (super.noSuchMethod( + _i2.HTTP get client => (super.noSuchMethod( + Invocation.getter(#client), + returnValue: _FakeHTTP_0( + this, + Invocation.getter(#client), + ), + ) as _i2.HTTP); + @override + set client(_i2.HTTP? _client) => super.noSuchMethod( + Invocation.setter( + #client, + _client, + ), + returnValueForMissingStub: null, + ); + @override + _i3.MainDB get db => (super.noSuchMethod( Invocation.getter(#db), - returnValue: _FakeMainDB_0( + returnValue: _FakeMainDB_1( this, Invocation.getter(#db), ), - ) as _i2.MainDB); + ) as _i3.MainDB); @override - List<_i4.StackTheme> get installedThemes => (super.noSuchMethod( + List<_i5.StackTheme> get installedThemes => (super.noSuchMethod( Invocation.getter(#installedThemes), - returnValue: <_i4.StackTheme>[], - ) as List<_i4.StackTheme>); + returnValue: <_i5.StackTheme>[], + ) as List<_i5.StackTheme>); @override - void init(_i2.MainDB? db) => super.noSuchMethod( + void init(_i3.MainDB? db) => super.noSuchMethod( Invocation.method( #init, [db], @@ -62,70 +89,70 @@ class MockThemeService extends _i1.Mock implements _i3.ThemeService { returnValueForMissingStub: null, ); @override - _i5.Future install({required _i6.Uint8List? themeArchiveData}) => + _i6.Future install({required _i7.Uint8List? themeArchiveData}) => (super.noSuchMethod( Invocation.method( #install, [], {#themeArchiveData: themeArchiveData}, ), - returnValue: _i5.Future.value(), - returnValueForMissingStub: _i5.Future.value(), - ) as _i5.Future); + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); @override - _i5.Future remove({required String? themeId}) => (super.noSuchMethod( + _i6.Future remove({required String? themeId}) => (super.noSuchMethod( Invocation.method( #remove, [], {#themeId: themeId}, ), - returnValue: _i5.Future.value(), - returnValueForMissingStub: _i5.Future.value(), - ) as _i5.Future); + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); @override - _i5.Future checkDefaultThemesOnStartup() => (super.noSuchMethod( + _i6.Future checkDefaultThemesOnStartup() => (super.noSuchMethod( Invocation.method( #checkDefaultThemesOnStartup, [], ), - returnValue: _i5.Future.value(), - returnValueForMissingStub: _i5.Future.value(), - ) as _i5.Future); + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); @override - _i5.Future verifyInstalled({required String? themeId}) => + _i6.Future verifyInstalled({required String? themeId}) => (super.noSuchMethod( Invocation.method( #verifyInstalled, [], {#themeId: themeId}, ), - returnValue: _i5.Future.value(false), - ) as _i5.Future); + returnValue: _i6.Future.value(false), + ) as _i6.Future); @override - _i5.Future> fetchThemes() => (super.noSuchMethod( + _i6.Future> fetchThemes() => (super.noSuchMethod( Invocation.method( #fetchThemes, [], ), - returnValue: _i5.Future>.value( - <_i3.StackThemeMetaData>[]), - ) as _i5.Future>); + returnValue: _i6.Future>.value( + <_i4.StackThemeMetaData>[]), + ) as _i6.Future>); @override - _i5.Future<_i6.Uint8List> fetchTheme( - {required _i3.StackThemeMetaData? themeMetaData}) => + _i6.Future<_i7.Uint8List> fetchTheme( + {required _i4.StackThemeMetaData? themeMetaData}) => (super.noSuchMethod( Invocation.method( #fetchTheme, [], {#themeMetaData: themeMetaData}, ), - returnValue: _i5.Future<_i6.Uint8List>.value(_i6.Uint8List(0)), - ) as _i5.Future<_i6.Uint8List>); + returnValue: _i6.Future<_i7.Uint8List>.value(_i7.Uint8List(0)), + ) as _i6.Future<_i7.Uint8List>); @override - _i4.StackTheme? getTheme({required String? themeId}) => + _i5.StackTheme? getTheme({required String? themeId}) => (super.noSuchMethod(Invocation.method( #getTheme, [], {#themeId: themeId}, - )) as _i4.StackTheme?); + )) as _i5.StackTheme?); } diff --git a/test/widget_tests/managed_favorite_test.dart b/test/widget_tests/managed_favorite_test.dart index 3d8bb66fa..623e70e30 100644 --- a/test/widget_tests/managed_favorite_test.dart +++ b/test/widget_tests/managed_favorite_test.dart @@ -1,3 +1,5 @@ +import 'dart:io'; + import 'package:decimal/decimal.dart'; import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; @@ -14,6 +16,7 @@ import 'package:stackwallet/services/locale_service.dart'; import 'package:stackwallet/services/node_service.dart'; import 'package:stackwallet/services/wallets.dart'; import 'package:stackwallet/services/wallets_service.dart'; +import 'package:stackwallet/themes/coin_icon_provider.dart'; import 'package:stackwallet/themes/stack_colors.dart'; import 'package:stackwallet/themes/theme_service.dart'; import 'package:stackwallet/utilities/amount/amount.dart'; @@ -89,6 +92,10 @@ void main() { walletsChangeNotifierProvider.overrideWithValue(wallets), pThemeService.overrideWithValue(mockThemeService), prefsChangeNotifierProvider.overrideWithValue(mockPrefs), + coinIconProvider.overrideWithProvider( + (argument) => Provider((_) => + "${Directory.current.path}/test/sample_data/light/assets/dummy.svg"), + ), ], child: MaterialApp( theme: ThemeData( @@ -176,6 +183,10 @@ void main() { walletsServiceChangeNotifierProvider .overrideWithValue(mockWalletsService), prefsChangeNotifierProvider.overrideWithValue(mockPrefs), + coinIconProvider.overrideWithProvider( + (argument) => Provider((_) => + "${Directory.current.path}/test/sample_data/light/assets/dummy.svg"), + ), ], child: MaterialApp( theme: ThemeData( @@ -261,7 +272,11 @@ void main() { pThemeService.overrideWithValue(mockThemeService), prefsChangeNotifierProvider.overrideWithValue(mockPrefs), walletsServiceChangeNotifierProvider - .overrideWithValue(mockWalletsService) + .overrideWithValue(mockWalletsService), + coinIconProvider.overrideWithProvider( + (argument) => Provider((_) => + "${Directory.current.path}/test/sample_data/light/assets/dummy.svg"), + ), ], child: MaterialApp( theme: ThemeData( diff --git a/test/widget_tests/managed_favorite_test.mocks.dart b/test/widget_tests/managed_favorite_test.mocks.dart index f81f66ebd..e2232e066 100644 --- a/test/widget_tests/managed_favorite_test.mocks.dart +++ b/test/widget_tests/managed_favorite_test.mocks.dart @@ -3,9 +3,9 @@ // Do not manually edit this file. // ignore_for_file: no_leading_underscores_for_library_prefixes -import 'dart:async' as _i23; -import 'dart:typed_data' as _i29; -import 'dart:ui' as _i25; +import 'dart:async' as _i24; +import 'dart:typed_data' as _i30; +import 'dart:ui' as _i26; import 'package:bip32/bip32.dart' as _i16; import 'package:bip47/bip47.dart' as _i18; @@ -18,29 +18,30 @@ import 'package:stackwallet/electrumx_rpc/cached_electrumx.dart' as _i10; 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 _i36; +import 'package:stackwallet/models/isar/stack_theme.dart' as _i32; +import 'package:stackwallet/models/node_model.dart' as _i37; 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/models/signing_data.dart' as _i29; +import 'package:stackwallet/networking/http.dart' as _i19; +import 'package:stackwallet/services/coins/bitcoin/bitcoin_wallet.dart' as _i27; +import 'package:stackwallet/services/coins/coin_service.dart' as _i21; import 'package:stackwallet/services/coins/manager.dart' as _i6; -import 'package:stackwallet/services/locale_service.dart' as _i35; +import 'package:stackwallet/services/locale_service.dart' as _i36; import 'package:stackwallet/services/node_service.dart' as _i3; import 'package:stackwallet/services/transaction_notification_tracker.dart' as _i7; -import 'package:stackwallet/services/wallets.dart' as _i21; +import 'package:stackwallet/services/wallets.dart' as _i22; import 'package:stackwallet/services/wallets_service.dart' as _i2; -import 'package:stackwallet/themes/theme_service.dart' as _i30; +import 'package:stackwallet/themes/theme_service.dart' as _i31; 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/amount/amount_unit.dart' as _i35; +import 'package:stackwallet/utilities/enums/backup_frequency_type.dart' as _i34; +import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i23; +import 'package:stackwallet/utilities/enums/derive_path_type_enum.dart' as _i28; +import 'package:stackwallet/utilities/enums/sync_type_enum.dart' as _i33; import 'package:stackwallet/utilities/flutter_secure_storage_interface.dart' - as _i19; -import 'package:stackwallet/utilities/prefs.dart' as _i24; + as _i20; +import 'package:stackwallet/utilities/prefs.dart' as _i25; import 'package:tuple/tuple.dart' as _i15; // ignore_for_file: type=lint @@ -229,9 +230,8 @@ class _FakePaymentCode_16 extends _i1.SmartFake implements _i18.PaymentCode { ); } -class _FakeSecureStorageInterface_17 extends _i1.SmartFake - implements _i19.SecureStorageInterface { - _FakeSecureStorageInterface_17( +class _FakeHTTP_17 extends _i1.SmartFake implements _i19.HTTP { + _FakeHTTP_17( Object parent, Invocation parentInvocation, ) : super( @@ -240,9 +240,20 @@ class _FakeSecureStorageInterface_17 extends _i1.SmartFake ); } -class _FakeCoinServiceAPI_18 extends _i1.SmartFake - implements _i20.CoinServiceAPI { - _FakeCoinServiceAPI_18( +class _FakeSecureStorageInterface_18 extends _i1.SmartFake + implements _i20.SecureStorageInterface { + _FakeSecureStorageInterface_18( + Object parent, + Invocation parentInvocation, + ) : super( + parent, + parentInvocation, + ); +} + +class _FakeCoinServiceAPI_19 extends _i1.SmartFake + implements _i21.CoinServiceAPI { + _FakeCoinServiceAPI_19( Object parent, Invocation parentInvocation, ) : super( @@ -254,7 +265,7 @@ class _FakeCoinServiceAPI_18 extends _i1.SmartFake /// A class which mocks [Wallets]. /// /// See the documentation for Mockito's code generation for more information. -class MockWallets extends _i1.Mock implements _i21.Wallets { +class MockWallets extends _i1.Mock implements _i22.Wallets { MockWallets() { _i1.throwOnMissingStub(this); } @@ -321,7 +332,7 @@ class MockWallets extends _i1.Mock implements _i21.Wallets { returnValueForMissingStub: null, ); @override - List getWalletIdsFor({required _i22.Coin? coin}) => + List getWalletIdsFor({required _i23.Coin? coin}) => (super.noSuchMethod( Invocation.method( #getWalletIdsFor, @@ -331,20 +342,20 @@ class MockWallets extends _i1.Mock implements _i21.Wallets { returnValue: [], ) as List); @override - List<_i15.Tuple2<_i22.Coin, List<_i5.ChangeNotifierProvider<_i6.Manager>>>> + List<_i15.Tuple2<_i23.Coin, List<_i5.ChangeNotifierProvider<_i6.Manager>>>> getManagerProvidersByCoin() => (super.noSuchMethod( Invocation.method( #getManagerProvidersByCoin, [], ), - returnValue: <_i15.Tuple2<_i22.Coin, + returnValue: <_i15.Tuple2<_i23.Coin, List<_i5.ChangeNotifierProvider<_i6.Manager>>>>[], ) as List< - _i15.Tuple2<_i22.Coin, + _i15.Tuple2<_i23.Coin, List<_i5.ChangeNotifierProvider<_i6.Manager>>>>); @override List<_i5.ChangeNotifierProvider<_i6.Manager>> getManagerProvidersForCoin( - _i22.Coin? coin) => + _i23.Coin? coin) => (super.noSuchMethod( Invocation.method( #getManagerProvidersForCoin, @@ -408,17 +419,17 @@ class MockWallets extends _i1.Mock implements _i21.Wallets { returnValueForMissingStub: null, ); @override - _i23.Future load(_i24.Prefs? prefs) => (super.noSuchMethod( + _i24.Future load(_i25.Prefs? prefs) => (super.noSuchMethod( Invocation.method( #load, [prefs], ), - returnValue: _i23.Future.value(), - returnValueForMissingStub: _i23.Future.value(), - ) as _i23.Future); + returnValue: _i24.Future.value(), + returnValueForMissingStub: _i24.Future.value(), + ) as _i24.Future); @override - _i23.Future loadAfterStackRestore( - _i24.Prefs? prefs, + _i24.Future loadAfterStackRestore( + _i25.Prefs? prefs, List<_i6.Manager>? managers, ) => (super.noSuchMethod( @@ -429,11 +440,11 @@ class MockWallets extends _i1.Mock implements _i21.Wallets { managers, ], ), - returnValue: _i23.Future.value(), - returnValueForMissingStub: _i23.Future.value(), - ) as _i23.Future); + returnValue: _i24.Future.value(), + returnValueForMissingStub: _i24.Future.value(), + ) as _i24.Future); @override - void addListener(_i25.VoidCallback? listener) => super.noSuchMethod( + void addListener(_i26.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #addListener, [listener], @@ -441,7 +452,7 @@ class MockWallets extends _i1.Mock implements _i21.Wallets { returnValueForMissingStub: null, ); @override - void removeListener(_i25.VoidCallback? listener) => super.noSuchMethod( + void removeListener(_i26.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #removeListener, [listener], @@ -467,19 +478,19 @@ class MockWalletsService extends _i1.Mock implements _i2.WalletsService { } @override - _i23.Future> get walletNames => + _i24.Future> get walletNames => (super.noSuchMethod( Invocation.getter(#walletNames), - returnValue: _i23.Future>.value( + returnValue: _i24.Future>.value( {}), - ) as _i23.Future>); + ) as _i24.Future>); @override bool get hasListeners => (super.noSuchMethod( Invocation.getter(#hasListeners), returnValue: false, ) as bool); @override - _i23.Future renameWallet({ + _i24.Future renameWallet({ required String? from, required String? to, required bool? shouldNotifyListeners, @@ -494,8 +505,8 @@ class MockWalletsService extends _i1.Mock implements _i2.WalletsService { #shouldNotifyListeners: shouldNotifyListeners, }, ), - returnValue: _i23.Future.value(false), - ) as _i23.Future); + returnValue: _i24.Future.value(false), + ) as _i24.Future); @override Map fetchWalletsData() => (super.noSuchMethod( Invocation.method( @@ -505,10 +516,10 @@ class MockWalletsService extends _i1.Mock implements _i2.WalletsService { returnValue: {}, ) as Map); @override - _i23.Future addExistingStackWallet({ + _i24.Future addExistingStackWallet({ required String? name, required String? walletId, - required _i22.Coin? coin, + required _i23.Coin? coin, required bool? shouldNotifyListeners, }) => (super.noSuchMethod( @@ -522,13 +533,13 @@ class MockWalletsService extends _i1.Mock implements _i2.WalletsService { #shouldNotifyListeners: shouldNotifyListeners, }, ), - returnValue: _i23.Future.value(), - returnValueForMissingStub: _i23.Future.value(), - ) as _i23.Future); + returnValue: _i24.Future.value(), + returnValueForMissingStub: _i24.Future.value(), + ) as _i24.Future); @override - _i23.Future addNewWallet({ + _i24.Future addNewWallet({ required String? name, - required _i22.Coin? coin, + required _i23.Coin? coin, required bool? shouldNotifyListeners, }) => (super.noSuchMethod( @@ -541,46 +552,46 @@ class MockWalletsService extends _i1.Mock implements _i2.WalletsService { #shouldNotifyListeners: shouldNotifyListeners, }, ), - returnValue: _i23.Future.value(), - ) as _i23.Future); + returnValue: _i24.Future.value(), + ) as _i24.Future); @override - _i23.Future> getFavoriteWalletIds() => (super.noSuchMethod( + _i24.Future> getFavoriteWalletIds() => (super.noSuchMethod( Invocation.method( #getFavoriteWalletIds, [], ), - returnValue: _i23.Future>.value([]), - ) as _i23.Future>); + returnValue: _i24.Future>.value([]), + ) as _i24.Future>); @override - _i23.Future saveFavoriteWalletIds(List? walletIds) => + _i24.Future saveFavoriteWalletIds(List? walletIds) => (super.noSuchMethod( Invocation.method( #saveFavoriteWalletIds, [walletIds], ), - returnValue: _i23.Future.value(), - returnValueForMissingStub: _i23.Future.value(), - ) as _i23.Future); + returnValue: _i24.Future.value(), + returnValueForMissingStub: _i24.Future.value(), + ) as _i24.Future); @override - _i23.Future addFavorite(String? walletId) => (super.noSuchMethod( + _i24.Future addFavorite(String? walletId) => (super.noSuchMethod( Invocation.method( #addFavorite, [walletId], ), - returnValue: _i23.Future.value(), - returnValueForMissingStub: _i23.Future.value(), - ) as _i23.Future); + returnValue: _i24.Future.value(), + returnValueForMissingStub: _i24.Future.value(), + ) as _i24.Future); @override - _i23.Future removeFavorite(String? walletId) => (super.noSuchMethod( + _i24.Future removeFavorite(String? walletId) => (super.noSuchMethod( Invocation.method( #removeFavorite, [walletId], ), - returnValue: _i23.Future.value(), - returnValueForMissingStub: _i23.Future.value(), - ) as _i23.Future); + returnValue: _i24.Future.value(), + returnValueForMissingStub: _i24.Future.value(), + ) as _i24.Future); @override - _i23.Future moveFavorite({ + _i24.Future moveFavorite({ required int? fromIndex, required int? toIndex, }) => @@ -593,48 +604,48 @@ class MockWalletsService extends _i1.Mock implements _i2.WalletsService { #toIndex: toIndex, }, ), - returnValue: _i23.Future.value(), - returnValueForMissingStub: _i23.Future.value(), - ) as _i23.Future); + returnValue: _i24.Future.value(), + returnValueForMissingStub: _i24.Future.value(), + ) as _i24.Future); @override - _i23.Future checkForDuplicate(String? name) => (super.noSuchMethod( + _i24.Future checkForDuplicate(String? name) => (super.noSuchMethod( Invocation.method( #checkForDuplicate, [name], ), - returnValue: _i23.Future.value(false), - ) as _i23.Future); + returnValue: _i24.Future.value(false), + ) as _i24.Future); @override - _i23.Future getWalletId(String? walletName) => (super.noSuchMethod( + _i24.Future getWalletId(String? walletName) => (super.noSuchMethod( Invocation.method( #getWalletId, [walletName], ), - returnValue: _i23.Future.value(), - ) as _i23.Future); + returnValue: _i24.Future.value(), + ) as _i24.Future); @override - _i23.Future isMnemonicVerified({required String? walletId}) => + _i24.Future isMnemonicVerified({required String? walletId}) => (super.noSuchMethod( Invocation.method( #isMnemonicVerified, [], {#walletId: walletId}, ), - returnValue: _i23.Future.value(false), - ) as _i23.Future); + returnValue: _i24.Future.value(false), + ) as _i24.Future); @override - _i23.Future setMnemonicVerified({required String? walletId}) => + _i24.Future setMnemonicVerified({required String? walletId}) => (super.noSuchMethod( Invocation.method( #setMnemonicVerified, [], {#walletId: walletId}, ), - returnValue: _i23.Future.value(), - returnValueForMissingStub: _i23.Future.value(), - ) as _i23.Future); + returnValue: _i24.Future.value(), + returnValueForMissingStub: _i24.Future.value(), + ) as _i24.Future); @override - _i23.Future deleteWallet( + _i24.Future deleteWallet( String? name, bool? shouldNotifyListeners, ) => @@ -646,20 +657,20 @@ class MockWalletsService extends _i1.Mock implements _i2.WalletsService { shouldNotifyListeners, ], ), - returnValue: _i23.Future.value(0), - ) as _i23.Future); + returnValue: _i24.Future.value(0), + ) as _i24.Future); @override - _i23.Future refreshWallets(bool? shouldNotifyListeners) => + _i24.Future refreshWallets(bool? shouldNotifyListeners) => (super.noSuchMethod( Invocation.method( #refreshWallets, [shouldNotifyListeners], ), - returnValue: _i23.Future.value(), - returnValueForMissingStub: _i23.Future.value(), - ) as _i23.Future); + returnValue: _i24.Future.value(), + returnValueForMissingStub: _i24.Future.value(), + ) as _i24.Future); @override - void addListener(_i25.VoidCallback? listener) => super.noSuchMethod( + void addListener(_i26.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #addListener, [listener], @@ -667,7 +678,7 @@ class MockWalletsService extends _i1.Mock implements _i2.WalletsService { returnValueForMissingStub: null, ); @override - void removeListener(_i25.VoidCallback? listener) => super.noSuchMethod( + void removeListener(_i26.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #removeListener, [listener], @@ -695,13 +706,13 @@ class MockWalletsService extends _i1.Mock implements _i2.WalletsService { /// A class which mocks [BitcoinWallet]. /// /// See the documentation for Mockito's code generation for more information. -class MockBitcoinWallet extends _i1.Mock implements _i26.BitcoinWallet { +class MockBitcoinWallet extends _i1.Mock implements _i27.BitcoinWallet { MockBitcoinWallet() { _i1.throwOnMissingStub(this); } @override - set timer(_i23.Timer? _timer) => super.noSuchMethod( + set timer(_i24.Timer? _timer) => super.noSuchMethod( Invocation.setter( #timer, _timer, @@ -778,74 +789,74 @@ class MockBitcoinWallet extends _i1.Mock implements _i26.BitcoinWallet { returnValue: false, ) as bool); @override - _i22.Coin get coin => (super.noSuchMethod( + _i23.Coin get coin => (super.noSuchMethod( Invocation.getter(#coin), - returnValue: _i22.Coin.bitcoin, - ) as _i22.Coin); + returnValue: _i23.Coin.bitcoin, + ) as _i23.Coin); @override - _i23.Future> get utxos => (super.noSuchMethod( + _i24.Future> get utxos => (super.noSuchMethod( Invocation.getter(#utxos), - returnValue: _i23.Future>.value(<_i17.UTXO>[]), - ) as _i23.Future>); + returnValue: _i24.Future>.value(<_i17.UTXO>[]), + ) as _i24.Future>); @override - _i23.Future> get transactions => (super.noSuchMethod( + _i24.Future> get transactions => (super.noSuchMethod( Invocation.getter(#transactions), returnValue: - _i23.Future>.value(<_i17.Transaction>[]), - ) as _i23.Future>); + _i24.Future>.value(<_i17.Transaction>[]), + ) as _i24.Future>); @override - _i23.Future get currentReceivingAddress => (super.noSuchMethod( + _i24.Future get currentReceivingAddress => (super.noSuchMethod( Invocation.getter(#currentReceivingAddress), - returnValue: _i23.Future.value(''), - ) as _i23.Future); + returnValue: _i24.Future.value(''), + ) as _i24.Future); @override - _i23.Future get currentChangeAddress => (super.noSuchMethod( + _i24.Future get currentChangeAddress => (super.noSuchMethod( Invocation.getter(#currentChangeAddress), - returnValue: _i23.Future.value(''), - ) as _i23.Future); + returnValue: _i24.Future.value(''), + ) as _i24.Future); @override - _i23.Future get currentChangeAddressP2PKH => (super.noSuchMethod( + _i24.Future get currentChangeAddressP2PKH => (super.noSuchMethod( Invocation.getter(#currentChangeAddressP2PKH), - returnValue: _i23.Future.value(''), - ) as _i23.Future); + returnValue: _i24.Future.value(''), + ) as _i24.Future); @override bool get hasCalledExit => (super.noSuchMethod( Invocation.getter(#hasCalledExit), returnValue: false, ) as bool); @override - _i23.Future<_i8.FeeObject> get fees => (super.noSuchMethod( + _i24.Future<_i8.FeeObject> get fees => (super.noSuchMethod( Invocation.getter(#fees), - returnValue: _i23.Future<_i8.FeeObject>.value(_FakeFeeObject_5( + returnValue: _i24.Future<_i8.FeeObject>.value(_FakeFeeObject_5( this, Invocation.getter(#fees), )), - ) as _i23.Future<_i8.FeeObject>); + ) as _i24.Future<_i8.FeeObject>); @override - _i23.Future get maxFee => (super.noSuchMethod( + _i24.Future get maxFee => (super.noSuchMethod( Invocation.getter(#maxFee), - returnValue: _i23.Future.value(0), - ) as _i23.Future); + returnValue: _i24.Future.value(0), + ) as _i24.Future); @override - _i23.Future> get mnemonic => (super.noSuchMethod( + _i24.Future> get mnemonic => (super.noSuchMethod( Invocation.getter(#mnemonic), - returnValue: _i23.Future>.value([]), - ) as _i23.Future>); + returnValue: _i24.Future>.value([]), + ) as _i24.Future>); @override - _i23.Future get mnemonicString => (super.noSuchMethod( + _i24.Future get mnemonicString => (super.noSuchMethod( Invocation.getter(#mnemonicString), - returnValue: _i23.Future.value(), - ) as _i23.Future); + returnValue: _i24.Future.value(), + ) as _i24.Future); @override - _i23.Future get mnemonicPassphrase => (super.noSuchMethod( + _i24.Future get mnemonicPassphrase => (super.noSuchMethod( Invocation.getter(#mnemonicPassphrase), - returnValue: _i23.Future.value(), - ) as _i23.Future); + returnValue: _i24.Future.value(), + ) as _i24.Future); @override - _i23.Future get chainHeight => (super.noSuchMethod( + _i24.Future get chainHeight => (super.noSuchMethod( Invocation.getter(#chainHeight), - returnValue: _i23.Future.value(0), - ) as _i23.Future); + returnValue: _i24.Future.value(0), + ) as _i24.Future); @override int get storedChainHeight => (super.noSuchMethod( Invocation.getter(#storedChainHeight), @@ -917,10 +928,10 @@ class MockBitcoinWallet extends _i1.Mock implements _i26.BitcoinWallet { ), ) as _i11.Balance); @override - _i23.Future get xpub => (super.noSuchMethod( + _i24.Future get xpub => (super.noSuchMethod( Invocation.getter(#xpub), - returnValue: _i23.Future.value(''), - ) as _i23.Future); + returnValue: _i24.Future.value(''), + ) as _i24.Future); @override set onIsActiveWalletChanged(void Function(bool)? _onIsActiveWalletChanged) => super.noSuchMethod( @@ -947,26 +958,26 @@ class MockBitcoinWallet extends _i1.Mock implements _i26.BitcoinWallet { ), ) as _i13.NetworkType); @override - _i23.Future exit() => (super.noSuchMethod( + _i24.Future exit() => (super.noSuchMethod( Invocation.method( #exit, [], ), - returnValue: _i23.Future.value(), - returnValueForMissingStub: _i23.Future.value(), - ) as _i23.Future); + returnValue: _i24.Future.value(), + returnValueForMissingStub: _i24.Future.value(), + ) as _i24.Future); @override - _i27.DerivePathType addressType({required String? address}) => + _i28.DerivePathType addressType({required String? address}) => (super.noSuchMethod( Invocation.method( #addressType, [], {#address: address}, ), - returnValue: _i27.DerivePathType.bip44, - ) as _i27.DerivePathType); + returnValue: _i28.DerivePathType.bip44, + ) as _i28.DerivePathType); @override - _i23.Future recoverFromMnemonic({ + _i24.Future recoverFromMnemonic({ required String? mnemonic, String? mnemonicPassphrase, required int? maxUnusedAddressGap, @@ -985,47 +996,47 @@ class MockBitcoinWallet extends _i1.Mock implements _i26.BitcoinWallet { #height: height, }, ), - returnValue: _i23.Future.value(), - returnValueForMissingStub: _i23.Future.value(), - ) as _i23.Future); + returnValue: _i24.Future.value(), + returnValueForMissingStub: _i24.Future.value(), + ) as _i24.Future); @override - _i23.Future getTransactionCacheEarly(List? allAddresses) => + _i24.Future getTransactionCacheEarly(List? allAddresses) => (super.noSuchMethod( Invocation.method( #getTransactionCacheEarly, [allAddresses], ), - returnValue: _i23.Future.value(), - returnValueForMissingStub: _i23.Future.value(), - ) as _i23.Future); + returnValue: _i24.Future.value(), + returnValueForMissingStub: _i24.Future.value(), + ) as _i24.Future); @override - _i23.Future refreshIfThereIsNewData() => (super.noSuchMethod( + _i24.Future refreshIfThereIsNewData() => (super.noSuchMethod( Invocation.method( #refreshIfThereIsNewData, [], ), - returnValue: _i23.Future.value(false), - ) as _i23.Future); + returnValue: _i24.Future.value(false), + ) as _i24.Future); @override - _i23.Future getAllTxsToWatch() => (super.noSuchMethod( + _i24.Future getAllTxsToWatch() => (super.noSuchMethod( Invocation.method( #getAllTxsToWatch, [], ), - returnValue: _i23.Future.value(), - returnValueForMissingStub: _i23.Future.value(), - ) as _i23.Future); + returnValue: _i24.Future.value(), + returnValueForMissingStub: _i24.Future.value(), + ) as _i24.Future); @override - _i23.Future refresh() => (super.noSuchMethod( + _i24.Future refresh() => (super.noSuchMethod( Invocation.method( #refresh, [], ), - returnValue: _i23.Future.value(), - returnValueForMissingStub: _i23.Future.value(), - ) as _i23.Future); + returnValue: _i24.Future.value(), + returnValueForMissingStub: _i24.Future.value(), + ) as _i24.Future); @override - _i23.Future> prepareSend({ + _i24.Future> prepareSend({ required String? address, required _i14.Amount? amount, Map? args, @@ -1041,26 +1052,26 @@ class MockBitcoinWallet extends _i1.Mock implements _i26.BitcoinWallet { }, ), returnValue: - _i23.Future>.value({}), - ) as _i23.Future>); + _i24.Future>.value({}), + ) as _i24.Future>); @override - _i23.Future confirmSend({required Map? txData}) => + _i24.Future confirmSend({required Map? txData}) => (super.noSuchMethod( Invocation.method( #confirmSend, [], {#txData: txData}, ), - returnValue: _i23.Future.value(''), - ) as _i23.Future); + returnValue: _i24.Future.value(''), + ) as _i24.Future); @override - _i23.Future testNetworkConnection() => (super.noSuchMethod( + _i24.Future testNetworkConnection() => (super.noSuchMethod( Invocation.method( #testNetworkConnection, [], ), - returnValue: _i23.Future.value(false), - ) as _i23.Future); + returnValue: _i24.Future.value(false), + ) as _i24.Future); @override void startNetworkAlivePinging() => super.noSuchMethod( Invocation.method( @@ -1078,33 +1089,35 @@ class MockBitcoinWallet extends _i1.Mock implements _i26.BitcoinWallet { returnValueForMissingStub: null, ); @override - _i23.Future initializeNew() => (super.noSuchMethod( + _i24.Future initializeNew( + ({String mnemonicPassphrase, int wordCount})? data) => + (super.noSuchMethod( Invocation.method( #initializeNew, - [], + [data], ), - returnValue: _i23.Future.value(), - returnValueForMissingStub: _i23.Future.value(), - ) as _i23.Future); + returnValue: _i24.Future.value(), + returnValueForMissingStub: _i24.Future.value(), + ) as _i24.Future); @override - _i23.Future initializeExisting() => (super.noSuchMethod( + _i24.Future initializeExisting() => (super.noSuchMethod( Invocation.method( #initializeExisting, [], ), - returnValue: _i23.Future.value(), - returnValueForMissingStub: _i23.Future.value(), - ) as _i23.Future); + returnValue: _i24.Future.value(), + returnValueForMissingStub: _i24.Future.value(), + ) as _i24.Future); @override - _i23.Future updateSentCachedTxData(Map? txData) => + _i24.Future updateSentCachedTxData(Map? txData) => (super.noSuchMethod( Invocation.method( #updateSentCachedTxData, [txData], ), - returnValue: _i23.Future.value(), - returnValueForMissingStub: _i23.Future.value(), - ) as _i23.Future); + returnValue: _i24.Future.value(), + returnValueForMissingStub: _i24.Future.value(), + ) as _i24.Future); @override bool validateAddress(String? address) => (super.noSuchMethod( Invocation.method( @@ -1114,69 +1127,69 @@ class MockBitcoinWallet extends _i1.Mock implements _i26.BitcoinWallet { returnValue: false, ) as bool); @override - _i23.Future updateNode(bool? shouldRefresh) => (super.noSuchMethod( + _i24.Future updateNode(bool? shouldRefresh) => (super.noSuchMethod( Invocation.method( #updateNode, [shouldRefresh], ), - returnValue: _i23.Future.value(), - returnValueForMissingStub: _i23.Future.value(), - ) as _i23.Future); + returnValue: _i24.Future.value(), + returnValueForMissingStub: _i24.Future.value(), + ) as _i24.Future); @override - _i23.Future<_i9.ElectrumXNode> getCurrentNode() => (super.noSuchMethod( + _i24.Future<_i9.ElectrumXNode> getCurrentNode() => (super.noSuchMethod( Invocation.method( #getCurrentNode, [], ), - returnValue: _i23.Future<_i9.ElectrumXNode>.value(_FakeElectrumXNode_11( + returnValue: _i24.Future<_i9.ElectrumXNode>.value(_FakeElectrumXNode_11( this, Invocation.method( #getCurrentNode, [], ), )), - ) as _i23.Future<_i9.ElectrumXNode>); + ) as _i24.Future<_i9.ElectrumXNode>); @override - _i23.Future>> fastFetch( + _i24.Future>> fastFetch( List? allTxHashes) => (super.noSuchMethod( Invocation.method( #fastFetch, [allTxHashes], ), - returnValue: _i23.Future>>.value( + returnValue: _i24.Future>>.value( >[]), - ) as _i23.Future>>); + ) as _i24.Future>>); @override - _i23.Future getTxCount({required String? address}) => + _i24.Future getTxCount({required String? address}) => (super.noSuchMethod( Invocation.method( #getTxCount, [], {#address: address}, ), - returnValue: _i23.Future.value(0), - ) as _i23.Future); + returnValue: _i24.Future.value(0), + ) as _i24.Future); @override - _i23.Future checkCurrentReceivingAddressesForTransactions() => + _i24.Future checkCurrentReceivingAddressesForTransactions() => (super.noSuchMethod( Invocation.method( #checkCurrentReceivingAddressesForTransactions, [], ), - returnValue: _i23.Future.value(), - returnValueForMissingStub: _i23.Future.value(), - ) as _i23.Future); + returnValue: _i24.Future.value(), + returnValueForMissingStub: _i24.Future.value(), + ) as _i24.Future); @override - _i23.Future checkCurrentChangeAddressesForTransactions() => + _i24.Future checkCurrentChangeAddressesForTransactions() => (super.noSuchMethod( Invocation.method( #checkCurrentChangeAddressesForTransactions, [], ), - returnValue: _i23.Future.value(), - returnValueForMissingStub: _i23.Future.value(), - ) as _i23.Future); + returnValue: _i24.Future.value(), + returnValueForMissingStub: _i24.Future.value(), + ) as _i24.Future); @override int estimateTxFee({ required int? vSize, @@ -1219,7 +1232,7 @@ class MockBitcoinWallet extends _i1.Mock implements _i26.BitcoinWallet { }, )); @override - _i23.Future> fetchBuildTxData( + _i24.Future> fetchBuildTxData( List<_i17.UTXO>? utxosToUse) => (super.noSuchMethod( Invocation.method( @@ -1227,11 +1240,11 @@ class MockBitcoinWallet extends _i1.Mock implements _i26.BitcoinWallet { [utxosToUse], ), returnValue: - _i23.Future>.value(<_i28.SigningData>[]), - ) as _i23.Future>); + _i24.Future>.value(<_i29.SigningData>[]), + ) as _i24.Future>); @override - _i23.Future> buildTransaction({ - required List<_i28.SigningData>? utxoSigningData, + _i24.Future> buildTransaction({ + required List<_i29.SigningData>? utxoSigningData, required List? recipients, required List? satoshiAmounts, }) => @@ -1246,10 +1259,10 @@ class MockBitcoinWallet extends _i1.Mock implements _i26.BitcoinWallet { }, ), returnValue: - _i23.Future>.value({}), - ) as _i23.Future>); + _i24.Future>.value({}), + ) as _i24.Future>); @override - _i23.Future fullRescan( + _i24.Future fullRescan( int? maxUnusedAddressGap, int? maxNumberOfIndexesToCheck, ) => @@ -1261,11 +1274,11 @@ class MockBitcoinWallet extends _i1.Mock implements _i26.BitcoinWallet { maxNumberOfIndexesToCheck, ], ), - returnValue: _i23.Future.value(), - returnValueForMissingStub: _i23.Future.value(), - ) as _i23.Future); + returnValue: _i24.Future.value(), + returnValueForMissingStub: _i24.Future.value(), + ) as _i24.Future); @override - _i23.Future<_i14.Amount> estimateFeeFor( + _i24.Future<_i14.Amount> estimateFeeFor( _i14.Amount? amount, int? feeRate, ) => @@ -1277,7 +1290,7 @@ class MockBitcoinWallet extends _i1.Mock implements _i26.BitcoinWallet { feeRate, ], ), - returnValue: _i23.Future<_i14.Amount>.value(_FakeAmount_12( + returnValue: _i24.Future<_i14.Amount>.value(_FakeAmount_12( this, Invocation.method( #estimateFeeFor, @@ -1287,7 +1300,7 @@ class MockBitcoinWallet extends _i1.Mock implements _i26.BitcoinWallet { ], ), )), - ) as _i23.Future<_i14.Amount>); + ) as _i24.Future<_i14.Amount>); @override _i14.Amount roughFeeEstimate( int? inputCount, @@ -1316,32 +1329,32 @@ class MockBitcoinWallet extends _i1.Mock implements _i26.BitcoinWallet { ), ) as _i14.Amount); @override - _i23.Future<_i14.Amount> sweepAllEstimate(int? feeRate) => + _i24.Future<_i14.Amount> sweepAllEstimate(int? feeRate) => (super.noSuchMethod( Invocation.method( #sweepAllEstimate, [feeRate], ), - returnValue: _i23.Future<_i14.Amount>.value(_FakeAmount_12( + returnValue: _i24.Future<_i14.Amount>.value(_FakeAmount_12( this, Invocation.method( #sweepAllEstimate, [feeRate], ), )), - ) as _i23.Future<_i14.Amount>); + ) as _i24.Future<_i14.Amount>); @override - _i23.Future generateNewAddress() => (super.noSuchMethod( + _i24.Future generateNewAddress() => (super.noSuchMethod( Invocation.method( #generateNewAddress, [], ), - returnValue: _i23.Future.value(false), - ) as _i23.Future); + returnValue: _i24.Future.value(false), + ) as _i24.Future); @override void initCache( String? walletId, - _i22.Coin? coin, + _i23.Coin? coin, ) => super.noSuchMethod( Invocation.method( @@ -1354,14 +1367,14 @@ class MockBitcoinWallet extends _i1.Mock implements _i26.BitcoinWallet { returnValueForMissingStub: null, ); @override - _i23.Future updateCachedId(String? id) => (super.noSuchMethod( + _i24.Future updateCachedId(String? id) => (super.noSuchMethod( Invocation.method( #updateCachedId, [id], ), - returnValue: _i23.Future.value(), - returnValueForMissingStub: _i23.Future.value(), - ) as _i23.Future); + returnValue: _i24.Future.value(), + returnValueForMissingStub: _i24.Future.value(), + ) as _i24.Future); @override int getCachedChainHeight() => (super.noSuchMethod( Invocation.method( @@ -1371,14 +1384,14 @@ class MockBitcoinWallet extends _i1.Mock implements _i26.BitcoinWallet { returnValue: 0, ) as int); @override - _i23.Future updateCachedChainHeight(int? height) => (super.noSuchMethod( + _i24.Future updateCachedChainHeight(int? height) => (super.noSuchMethod( Invocation.method( #updateCachedChainHeight, [height], ), - returnValue: _i23.Future.value(), - returnValueForMissingStub: _i23.Future.value(), - ) as _i23.Future); + returnValue: _i24.Future.value(), + returnValueForMissingStub: _i24.Future.value(), + ) as _i24.Future); @override bool getCachedIsFavorite() => (super.noSuchMethod( Invocation.method( @@ -1388,15 +1401,15 @@ class MockBitcoinWallet extends _i1.Mock implements _i26.BitcoinWallet { returnValue: false, ) as bool); @override - _i23.Future updateCachedIsFavorite(bool? isFavorite) => + _i24.Future updateCachedIsFavorite(bool? isFavorite) => (super.noSuchMethod( Invocation.method( #updateCachedIsFavorite, [isFavorite], ), - returnValue: _i23.Future.value(), - returnValueForMissingStub: _i23.Future.value(), - ) as _i23.Future); + returnValue: _i24.Future.value(), + returnValueForMissingStub: _i24.Future.value(), + ) as _i24.Future); @override _i11.Balance getCachedBalance() => (super.noSuchMethod( Invocation.method( @@ -1412,15 +1425,15 @@ class MockBitcoinWallet extends _i1.Mock implements _i26.BitcoinWallet { ), ) as _i11.Balance); @override - _i23.Future updateCachedBalance(_i11.Balance? balance) => + _i24.Future updateCachedBalance(_i11.Balance? balance) => (super.noSuchMethod( Invocation.method( #updateCachedBalance, [balance], ), - returnValue: _i23.Future.value(), - returnValueForMissingStub: _i23.Future.value(), - ) as _i23.Future); + returnValue: _i24.Future.value(), + returnValueForMissingStub: _i24.Future.value(), + ) as _i24.Future); @override _i11.Balance getCachedBalanceSecondary() => (super.noSuchMethod( Invocation.method( @@ -1436,15 +1449,15 @@ class MockBitcoinWallet extends _i1.Mock implements _i26.BitcoinWallet { ), ) as _i11.Balance); @override - _i23.Future updateCachedBalanceSecondary(_i11.Balance? balance) => + _i24.Future updateCachedBalanceSecondary(_i11.Balance? balance) => (super.noSuchMethod( Invocation.method( #updateCachedBalanceSecondary, [balance], ), - returnValue: _i23.Future.value(), - returnValueForMissingStub: _i23.Future.value(), - ) as _i23.Future); + returnValue: _i24.Future.value(), + returnValueForMissingStub: _i24.Future.value(), + ) as _i24.Future); @override List getWalletTokenContractAddresses() => (super.noSuchMethod( Invocation.method( @@ -1454,16 +1467,16 @@ class MockBitcoinWallet extends _i1.Mock implements _i26.BitcoinWallet { returnValue: [], ) as List); @override - _i23.Future updateWalletTokenContractAddresses( + _i24.Future updateWalletTokenContractAddresses( List? contractAddresses) => (super.noSuchMethod( Invocation.method( #updateWalletTokenContractAddresses, [contractAddresses], ), - returnValue: _i23.Future.value(), - returnValueForMissingStub: _i23.Future.value(), - ) as _i23.Future); + returnValue: _i24.Future.value(), + returnValueForMissingStub: _i24.Future.value(), + ) as _i24.Future); @override void initWalletDB({_i12.MainDB? mockableOverride}) => super.noSuchMethod( Invocation.method( @@ -1474,11 +1487,11 @@ class MockBitcoinWallet extends _i1.Mock implements _i26.BitcoinWallet { returnValueForMissingStub: null, ); @override - _i23.Future<_i15.Tuple2<_i17.Transaction, _i17.Address>> parseTransaction( + _i24.Future<_i15.Tuple2<_i17.Transaction, _i17.Address>> parseTransaction( Map? txData, dynamic electrumxClient, List<_i17.Address>? myAddresses, - _i22.Coin? coin, + _i23.Coin? coin, int? minConfirms, String? walletId, ) => @@ -1495,7 +1508,7 @@ class MockBitcoinWallet extends _i1.Mock implements _i26.BitcoinWallet { ], ), returnValue: - _i23.Future<_i15.Tuple2<_i17.Transaction, _i17.Address>>.value( + _i24.Future<_i15.Tuple2<_i17.Transaction, _i17.Address>>.value( _FakeTuple2_13<_i17.Transaction, _i17.Address>( this, Invocation.method( @@ -1510,37 +1523,37 @@ class MockBitcoinWallet extends _i1.Mock implements _i26.BitcoinWallet { ], ), )), - ) as _i23.Future<_i15.Tuple2<_i17.Transaction, _i17.Address>>); + ) as _i24.Future<_i15.Tuple2<_i17.Transaction, _i17.Address>>); @override void initPaynymWalletInterface({ required String? walletId, required String? walletName, required _i13.NetworkType? network, - required _i22.Coin? coin, + required _i23.Coin? coin, required _i12.MainDB? db, required _i9.ElectrumX? electrumXClient, - required _i19.SecureStorageInterface? secureStorage, + required _i20.SecureStorageInterface? secureStorage, required int? dustLimit, required int? dustLimitP2PKH, required int? minConfirms, - required _i23.Future Function()? getMnemonicString, - required _i23.Future Function()? getMnemonicPassphrase, - required _i23.Future Function()? getChainHeight, - required _i23.Future Function()? getCurrentChangeAddress, + required _i24.Future Function()? getMnemonicString, + required _i24.Future Function()? getMnemonicPassphrase, + required _i24.Future Function()? getChainHeight, + required _i24.Future Function()? getCurrentChangeAddress, required int Function({ required int feeRatePerKB, required int vSize, })? estimateTxFee, - required _i23.Future> Function({ + required _i24.Future> Function({ required String address, required _i14.Amount amount, Map? args, })? prepareSend, - required _i23.Future Function({required String address})? getTxCount, - required _i23.Future> Function(List<_i17.UTXO>)? + required _i24.Future Function({required String address})? getTxCount, + required _i24.Future> Function(List<_i17.UTXO>)? fetchBuildTxData, - required _i23.Future Function()? refresh, - required _i23.Future Function()? checkChangeAddressForTransactions, + required _i24.Future Function()? refresh, + required _i24.Future Function()? checkChangeAddressForTransactions, }) => super.noSuchMethod( Invocation.method( @@ -1573,21 +1586,21 @@ class MockBitcoinWallet extends _i1.Mock implements _i26.BitcoinWallet { returnValueForMissingStub: null, ); @override - _i23.Future<_i16.BIP32> getBip47BaseNode() => (super.noSuchMethod( + _i24.Future<_i16.BIP32> getBip47BaseNode() => (super.noSuchMethod( Invocation.method( #getBip47BaseNode, [], ), - returnValue: _i23.Future<_i16.BIP32>.value(_FakeBIP32_14( + returnValue: _i24.Future<_i16.BIP32>.value(_FakeBIP32_14( this, Invocation.method( #getBip47BaseNode, [], ), )), - ) as _i23.Future<_i16.BIP32>); + ) as _i24.Future<_i16.BIP32>); @override - _i23.Future<_i29.Uint8List> getPrivateKeyForPaynymReceivingAddress({ + _i24.Future<_i30.Uint8List> getPrivateKeyForPaynymReceivingAddress({ required String? paymentCodeString, required int? index, }) => @@ -1600,10 +1613,10 @@ class MockBitcoinWallet extends _i1.Mock implements _i26.BitcoinWallet { #index: index, }, ), - returnValue: _i23.Future<_i29.Uint8List>.value(_i29.Uint8List(0)), - ) as _i23.Future<_i29.Uint8List>); + returnValue: _i24.Future<_i30.Uint8List>.value(_i30.Uint8List(0)), + ) as _i24.Future<_i30.Uint8List>); @override - _i23.Future<_i17.Address> currentReceivingPaynymAddress({ + _i24.Future<_i17.Address> currentReceivingPaynymAddress({ required _i18.PaymentCode? sender, required bool? isSegwit, }) => @@ -1616,7 +1629,7 @@ class MockBitcoinWallet extends _i1.Mock implements _i26.BitcoinWallet { #isSegwit: isSegwit, }, ), - returnValue: _i23.Future<_i17.Address>.value(_FakeAddress_15( + returnValue: _i24.Future<_i17.Address>.value(_FakeAddress_15( this, Invocation.method( #currentReceivingPaynymAddress, @@ -1627,9 +1640,9 @@ class MockBitcoinWallet extends _i1.Mock implements _i26.BitcoinWallet { }, ), )), - ) as _i23.Future<_i17.Address>); + ) as _i24.Future<_i17.Address>); @override - _i23.Future checkCurrentPaynymReceivingAddressForTransactions({ + _i24.Future checkCurrentPaynymReceivingAddressForTransactions({ required _i18.PaymentCode? sender, required bool? isSegwit, }) => @@ -1642,42 +1655,42 @@ class MockBitcoinWallet extends _i1.Mock implements _i26.BitcoinWallet { #isSegwit: isSegwit, }, ), - returnValue: _i23.Future.value(), - returnValueForMissingStub: _i23.Future.value(), - ) as _i23.Future); + returnValue: _i24.Future.value(), + returnValueForMissingStub: _i24.Future.value(), + ) as _i24.Future); @override - _i23.Future checkAllCurrentReceivingPaynymAddressesForTransactions() => + _i24.Future checkAllCurrentReceivingPaynymAddressesForTransactions() => (super.noSuchMethod( Invocation.method( #checkAllCurrentReceivingPaynymAddressesForTransactions, [], ), - returnValue: _i23.Future.value(), - returnValueForMissingStub: _i23.Future.value(), - ) as _i23.Future); + returnValue: _i24.Future.value(), + returnValueForMissingStub: _i24.Future.value(), + ) as _i24.Future); @override - _i23.Future<_i16.BIP32> deriveNotificationBip32Node() => (super.noSuchMethod( + _i24.Future<_i16.BIP32> deriveNotificationBip32Node() => (super.noSuchMethod( Invocation.method( #deriveNotificationBip32Node, [], ), - returnValue: _i23.Future<_i16.BIP32>.value(_FakeBIP32_14( + returnValue: _i24.Future<_i16.BIP32>.value(_FakeBIP32_14( this, Invocation.method( #deriveNotificationBip32Node, [], ), )), - ) as _i23.Future<_i16.BIP32>); + ) as _i24.Future<_i16.BIP32>); @override - _i23.Future<_i18.PaymentCode> getPaymentCode({required bool? isSegwit}) => + _i24.Future<_i18.PaymentCode> getPaymentCode({required bool? isSegwit}) => (super.noSuchMethod( Invocation.method( #getPaymentCode, [], {#isSegwit: isSegwit}, ), - returnValue: _i23.Future<_i18.PaymentCode>.value(_FakePaymentCode_16( + returnValue: _i24.Future<_i18.PaymentCode>.value(_FakePaymentCode_16( this, Invocation.method( #getPaymentCode, @@ -1685,27 +1698,27 @@ class MockBitcoinWallet extends _i1.Mock implements _i26.BitcoinWallet { {#isSegwit: isSegwit}, ), )), - ) as _i23.Future<_i18.PaymentCode>); + ) as _i24.Future<_i18.PaymentCode>); @override - _i23.Future<_i29.Uint8List> signWithNotificationKey(_i29.Uint8List? data) => + _i24.Future<_i30.Uint8List> signWithNotificationKey(_i30.Uint8List? data) => (super.noSuchMethod( Invocation.method( #signWithNotificationKey, [data], ), - returnValue: _i23.Future<_i29.Uint8List>.value(_i29.Uint8List(0)), - ) as _i23.Future<_i29.Uint8List>); + returnValue: _i24.Future<_i30.Uint8List>.value(_i30.Uint8List(0)), + ) as _i24.Future<_i30.Uint8List>); @override - _i23.Future signStringWithNotificationKey(String? data) => + _i24.Future signStringWithNotificationKey(String? data) => (super.noSuchMethod( Invocation.method( #signStringWithNotificationKey, [data], ), - returnValue: _i23.Future.value(''), - ) as _i23.Future); + returnValue: _i24.Future.value(''), + ) as _i24.Future); @override - _i23.Future> preparePaymentCodeSend({ + _i24.Future> preparePaymentCodeSend({ required _i18.PaymentCode? paymentCode, required bool? isSegwit, required _i14.Amount? amount, @@ -1723,10 +1736,10 @@ class MockBitcoinWallet extends _i1.Mock implements _i26.BitcoinWallet { }, ), returnValue: - _i23.Future>.value({}), - ) as _i23.Future>); + _i24.Future>.value({}), + ) as _i24.Future>); @override - _i23.Future<_i17.Address> nextUnusedSendAddressFrom({ + _i24.Future<_i17.Address> nextUnusedSendAddressFrom({ required _i18.PaymentCode? pCode, required bool? isSegwit, required _i16.BIP32? privateKeyNode, @@ -1743,7 +1756,7 @@ class MockBitcoinWallet extends _i1.Mock implements _i26.BitcoinWallet { #startIndex: startIndex, }, ), - returnValue: _i23.Future<_i17.Address>.value(_FakeAddress_15( + returnValue: _i24.Future<_i17.Address>.value(_FakeAddress_15( this, Invocation.method( #nextUnusedSendAddressFrom, @@ -1756,9 +1769,9 @@ class MockBitcoinWallet extends _i1.Mock implements _i26.BitcoinWallet { }, ), )), - ) as _i23.Future<_i17.Address>); + ) as _i24.Future<_i17.Address>); @override - _i23.Future> prepareNotificationTx({ + _i24.Future> prepareNotificationTx({ required int? selectedTxFeeRate, required String? targetPaymentCodeString, int? additionalOutputs = 0, @@ -1776,10 +1789,10 @@ class MockBitcoinWallet extends _i1.Mock implements _i26.BitcoinWallet { }, ), returnValue: - _i23.Future>.value({}), - ) as _i23.Future>); + _i24.Future>.value({}), + ) as _i24.Future>); @override - _i23.Future broadcastNotificationTx( + _i24.Future broadcastNotificationTx( {required Map? preparedTx}) => (super.noSuchMethod( Invocation.method( @@ -1787,19 +1800,19 @@ class MockBitcoinWallet extends _i1.Mock implements _i26.BitcoinWallet { [], {#preparedTx: preparedTx}, ), - returnValue: _i23.Future.value(''), - ) as _i23.Future); + returnValue: _i24.Future.value(''), + ) as _i24.Future); @override - _i23.Future hasConnected(String? paymentCodeString) => + _i24.Future hasConnected(String? paymentCodeString) => (super.noSuchMethod( Invocation.method( #hasConnected, [paymentCodeString], ), - returnValue: _i23.Future.value(false), - ) as _i23.Future); + returnValue: _i24.Future.value(false), + ) as _i24.Future); @override - _i23.Future<_i18.PaymentCode?> unBlindedPaymentCodeFromTransaction( + _i24.Future<_i18.PaymentCode?> unBlindedPaymentCodeFromTransaction( {required _i17.Transaction? transaction}) => (super.noSuchMethod( Invocation.method( @@ -1807,10 +1820,10 @@ class MockBitcoinWallet extends _i1.Mock implements _i26.BitcoinWallet { [], {#transaction: transaction}, ), - returnValue: _i23.Future<_i18.PaymentCode?>.value(), - ) as _i23.Future<_i18.PaymentCode?>); + returnValue: _i24.Future<_i18.PaymentCode?>.value(), + ) as _i24.Future<_i18.PaymentCode?>); @override - _i23.Future<_i18.PaymentCode?> unBlindedPaymentCodeFromTransactionBad( + _i24.Future<_i18.PaymentCode?> unBlindedPaymentCodeFromTransactionBad( {required _i17.Transaction? transaction}) => (super.noSuchMethod( Invocation.method( @@ -1818,31 +1831,31 @@ class MockBitcoinWallet extends _i1.Mock implements _i26.BitcoinWallet { [], {#transaction: transaction}, ), - returnValue: _i23.Future<_i18.PaymentCode?>.value(), - ) as _i23.Future<_i18.PaymentCode?>); + returnValue: _i24.Future<_i18.PaymentCode?>.value(), + ) as _i24.Future<_i18.PaymentCode?>); @override - _i23.Future> + _i24.Future> getAllPaymentCodesFromNotificationTransactions() => (super.noSuchMethod( Invocation.method( #getAllPaymentCodesFromNotificationTransactions, [], ), returnValue: - _i23.Future>.value(<_i18.PaymentCode>[]), - ) as _i23.Future>); + _i24.Future>.value(<_i18.PaymentCode>[]), + ) as _i24.Future>); @override - _i23.Future checkForNotificationTransactionsTo( + _i24.Future checkForNotificationTransactionsTo( Set? otherCodeStrings) => (super.noSuchMethod( Invocation.method( #checkForNotificationTransactionsTo, [otherCodeStrings], ), - returnValue: _i23.Future.value(), - returnValueForMissingStub: _i23.Future.value(), - ) as _i23.Future); + returnValue: _i24.Future.value(), + returnValueForMissingStub: _i24.Future.value(), + ) as _i24.Future); @override - _i23.Future restoreAllHistory({ + _i24.Future restoreAllHistory({ required int? maxUnusedAddressGap, required int? maxNumberOfIndexesToCheck, required Set? paymentCodeStrings, @@ -1857,11 +1870,11 @@ class MockBitcoinWallet extends _i1.Mock implements _i26.BitcoinWallet { #paymentCodeStrings: paymentCodeStrings, }, ), - returnValue: _i23.Future.value(), - returnValueForMissingStub: _i23.Future.value(), - ) as _i23.Future); + returnValue: _i24.Future.value(), + returnValueForMissingStub: _i24.Future.value(), + ) as _i24.Future); @override - _i23.Future restoreHistoryWith({ + _i24.Future restoreHistoryWith({ required _i18.PaymentCode? other, required bool? checkSegwitAsWell, required int? maxUnusedAddressGap, @@ -1878,58 +1891,58 @@ class MockBitcoinWallet extends _i1.Mock implements _i26.BitcoinWallet { #maxNumberOfIndexesToCheck: maxNumberOfIndexesToCheck, }, ), - returnValue: _i23.Future.value(), - returnValueForMissingStub: _i23.Future.value(), - ) as _i23.Future); + returnValue: _i24.Future.value(), + returnValueForMissingStub: _i24.Future.value(), + ) as _i24.Future); @override - _i23.Future<_i17.Address> getMyNotificationAddress() => (super.noSuchMethod( + _i24.Future<_i17.Address> getMyNotificationAddress() => (super.noSuchMethod( Invocation.method( #getMyNotificationAddress, [], ), - returnValue: _i23.Future<_i17.Address>.value(_FakeAddress_15( + returnValue: _i24.Future<_i17.Address>.value(_FakeAddress_15( this, Invocation.method( #getMyNotificationAddress, [], ), )), - ) as _i23.Future<_i17.Address>); + ) as _i24.Future<_i17.Address>); @override - _i23.Future> lookupKey(String? paymentCodeString) => + _i24.Future> lookupKey(String? paymentCodeString) => (super.noSuchMethod( Invocation.method( #lookupKey, [paymentCodeString], ), - returnValue: _i23.Future>.value([]), - ) as _i23.Future>); + returnValue: _i24.Future>.value([]), + ) as _i24.Future>); @override - _i23.Future paymentCodeStringByKey(String? key) => + _i24.Future paymentCodeStringByKey(String? key) => (super.noSuchMethod( Invocation.method( #paymentCodeStringByKey, [key], ), - returnValue: _i23.Future.value(), - ) as _i23.Future); + returnValue: _i24.Future.value(), + ) as _i24.Future); @override - _i23.Future storeCode(String? paymentCodeString) => + _i24.Future storeCode(String? paymentCodeString) => (super.noSuchMethod( Invocation.method( #storeCode, [paymentCodeString], ), - returnValue: _i23.Future.value(''), - ) as _i23.Future); + returnValue: _i24.Future.value(''), + ) as _i24.Future); @override void initCoinControlInterface({ required String? walletId, required String? walletName, - required _i22.Coin? coin, + required _i23.Coin? coin, required _i12.MainDB? db, - required _i23.Future Function()? getChainHeight, - required _i23.Future Function(_i11.Balance)? refreshedBalanceCallback, + required _i24.Future Function()? getChainHeight, + required _i24.Future Function(_i11.Balance)? refreshedBalanceCallback, }) => super.noSuchMethod( Invocation.method( @@ -1947,26 +1960,42 @@ class MockBitcoinWallet extends _i1.Mock implements _i26.BitcoinWallet { returnValueForMissingStub: null, ); @override - _i23.Future refreshBalance({bool? notify = false}) => + _i24.Future refreshBalance({bool? notify = false}) => (super.noSuchMethod( Invocation.method( #refreshBalance, [], {#notify: notify}, ), - returnValue: _i23.Future.value(), - returnValueForMissingStub: _i23.Future.value(), - ) as _i23.Future); + returnValue: _i24.Future.value(), + returnValueForMissingStub: _i24.Future.value(), + ) as _i24.Future); } /// A class which mocks [ThemeService]. /// /// See the documentation for Mockito's code generation for more information. -class MockThemeService extends _i1.Mock implements _i30.ThemeService { +class MockThemeService extends _i1.Mock implements _i31.ThemeService { MockThemeService() { _i1.throwOnMissingStub(this); } + @override + _i19.HTTP get client => (super.noSuchMethod( + Invocation.getter(#client), + returnValue: _FakeHTTP_17( + this, + Invocation.getter(#client), + ), + ) as _i19.HTTP); + @override + set client(_i19.HTTP? _client) => super.noSuchMethod( + Invocation.setter( + #client, + _client, + ), + returnValueForMissingStub: null, + ); @override _i12.MainDB get db => (super.noSuchMethod( Invocation.getter(#db), @@ -1976,10 +2005,10 @@ class MockThemeService extends _i1.Mock implements _i30.ThemeService { ), ) as _i12.MainDB); @override - List<_i31.StackTheme> get installedThemes => (super.noSuchMethod( + List<_i32.StackTheme> get installedThemes => (super.noSuchMethod( Invocation.getter(#installedThemes), - returnValue: <_i31.StackTheme>[], - ) as List<_i31.StackTheme>); + returnValue: <_i32.StackTheme>[], + ) as List<_i32.StackTheme>); @override void init(_i12.MainDB? db) => super.noSuchMethod( Invocation.method( @@ -1989,79 +2018,79 @@ class MockThemeService extends _i1.Mock implements _i30.ThemeService { returnValueForMissingStub: null, ); @override - _i23.Future install({required _i29.Uint8List? themeArchiveData}) => + _i24.Future install({required _i30.Uint8List? themeArchiveData}) => (super.noSuchMethod( Invocation.method( #install, [], {#themeArchiveData: themeArchiveData}, ), - returnValue: _i23.Future.value(), - returnValueForMissingStub: _i23.Future.value(), - ) as _i23.Future); + returnValue: _i24.Future.value(), + returnValueForMissingStub: _i24.Future.value(), + ) as _i24.Future); @override - _i23.Future remove({required String? themeId}) => (super.noSuchMethod( + _i24.Future remove({required String? themeId}) => (super.noSuchMethod( Invocation.method( #remove, [], {#themeId: themeId}, ), - returnValue: _i23.Future.value(), - returnValueForMissingStub: _i23.Future.value(), - ) as _i23.Future); + returnValue: _i24.Future.value(), + returnValueForMissingStub: _i24.Future.value(), + ) as _i24.Future); @override - _i23.Future checkDefaultThemesOnStartup() => (super.noSuchMethod( + _i24.Future checkDefaultThemesOnStartup() => (super.noSuchMethod( Invocation.method( #checkDefaultThemesOnStartup, [], ), - returnValue: _i23.Future.value(), - returnValueForMissingStub: _i23.Future.value(), - ) as _i23.Future); + returnValue: _i24.Future.value(), + returnValueForMissingStub: _i24.Future.value(), + ) as _i24.Future); @override - _i23.Future verifyInstalled({required String? themeId}) => + _i24.Future verifyInstalled({required String? themeId}) => (super.noSuchMethod( Invocation.method( #verifyInstalled, [], {#themeId: themeId}, ), - returnValue: _i23.Future.value(false), - ) as _i23.Future); + returnValue: _i24.Future.value(false), + ) as _i24.Future); @override - _i23.Future> fetchThemes() => + _i24.Future> fetchThemes() => (super.noSuchMethod( Invocation.method( #fetchThemes, [], ), - returnValue: _i23.Future>.value( - <_i30.StackThemeMetaData>[]), - ) as _i23.Future>); + returnValue: _i24.Future>.value( + <_i31.StackThemeMetaData>[]), + ) as _i24.Future>); @override - _i23.Future<_i29.Uint8List> fetchTheme( - {required _i30.StackThemeMetaData? themeMetaData}) => + _i24.Future<_i30.Uint8List> fetchTheme( + {required _i31.StackThemeMetaData? themeMetaData}) => (super.noSuchMethod( Invocation.method( #fetchTheme, [], {#themeMetaData: themeMetaData}, ), - returnValue: _i23.Future<_i29.Uint8List>.value(_i29.Uint8List(0)), - ) as _i23.Future<_i29.Uint8List>); + returnValue: _i24.Future<_i30.Uint8List>.value(_i30.Uint8List(0)), + ) as _i24.Future<_i30.Uint8List>); @override - _i31.StackTheme? getTheme({required String? themeId}) => + _i32.StackTheme? getTheme({required String? themeId}) => (super.noSuchMethod(Invocation.method( #getTheme, [], {#themeId: themeId}, - )) as _i31.StackTheme?); + )) as _i32.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 { +class MockPrefs extends _i1.Mock implements _i25.Prefs { MockPrefs() { _i1.throwOnMissingStub(this); } @@ -2117,12 +2146,12 @@ class MockPrefs extends _i1.Mock implements _i24.Prefs { returnValueForMissingStub: null, ); @override - _i32.SyncingType get syncType => (super.noSuchMethod( + _i33.SyncingType get syncType => (super.noSuchMethod( Invocation.getter(#syncType), - returnValue: _i32.SyncingType.currentWalletOnly, - ) as _i32.SyncingType); + returnValue: _i33.SyncingType.currentWalletOnly, + ) as _i33.SyncingType); @override - set syncType(_i32.SyncingType? syncType) => super.noSuchMethod( + set syncType(_i33.SyncingType? syncType) => super.noSuchMethod( Invocation.setter( #syncType, syncType, @@ -2234,6 +2263,19 @@ class MockPrefs extends _i1.Mock implements _i24.Prefs { returnValueForMissingStub: null, ); @override + bool get torKillSwitch => (super.noSuchMethod( + Invocation.getter(#torKillSwitch), + returnValue: false, + ) as bool); + @override + set torKillSwitch(bool? torKillswitch) => super.noSuchMethod( + Invocation.setter( + #torKillSwitch, + torKillswitch, + ), + returnValueForMissingStub: null, + ); + @override bool get showTestNetCoins => (super.noSuchMethod( Invocation.getter(#showTestNetCoins), returnValue: false, @@ -2268,12 +2310,12 @@ class MockPrefs extends _i1.Mock implements _i24.Prefs { returnValueForMissingStub: null, ); @override - _i33.BackupFrequencyType get backupFrequencyType => (super.noSuchMethod( + _i34.BackupFrequencyType get backupFrequencyType => (super.noSuchMethod( Invocation.getter(#backupFrequencyType), - returnValue: _i33.BackupFrequencyType.everyTenMinutes, - ) as _i33.BackupFrequencyType); + returnValue: _i34.BackupFrequencyType.everyTenMinutes, + ) as _i34.BackupFrequencyType); @override - set backupFrequencyType(_i33.BackupFrequencyType? backupFrequencyType) => + set backupFrequencyType(_i34.BackupFrequencyType? backupFrequencyType) => super.noSuchMethod( Invocation.setter( #backupFrequencyType, @@ -2406,66 +2448,79 @@ class MockPrefs extends _i1.Mock implements _i24.Prefs { returnValueForMissingStub: null, ); @override + bool get useTor => (super.noSuchMethod( + Invocation.getter(#useTor), + returnValue: false, + ) as bool); + @override + set useTor(bool? useTor) => super.noSuchMethod( + Invocation.setter( + #useTor, + useTor, + ), + returnValueForMissingStub: null, + ); + @override bool get hasListeners => (super.noSuchMethod( Invocation.getter(#hasListeners), returnValue: false, ) as bool); @override - _i23.Future init() => (super.noSuchMethod( + _i24.Future init() => (super.noSuchMethod( Invocation.method( #init, [], ), - returnValue: _i23.Future.value(), - returnValueForMissingStub: _i23.Future.value(), - ) as _i23.Future); + returnValue: _i24.Future.value(), + returnValueForMissingStub: _i24.Future.value(), + ) as _i24.Future); @override - _i23.Future incrementCurrentNotificationIndex() => (super.noSuchMethod( + _i24.Future incrementCurrentNotificationIndex() => (super.noSuchMethod( Invocation.method( #incrementCurrentNotificationIndex, [], ), - returnValue: _i23.Future.value(), - returnValueForMissingStub: _i23.Future.value(), - ) as _i23.Future); + returnValue: _i24.Future.value(), + returnValueForMissingStub: _i24.Future.value(), + ) as _i24.Future); @override - _i23.Future isExternalCallsSet() => (super.noSuchMethod( + _i24.Future isExternalCallsSet() => (super.noSuchMethod( Invocation.method( #isExternalCallsSet, [], ), - returnValue: _i23.Future.value(false), - ) as _i23.Future); + returnValue: _i24.Future.value(false), + ) as _i24.Future); @override - _i23.Future saveUserID(String? userId) => (super.noSuchMethod( + _i24.Future saveUserID(String? userId) => (super.noSuchMethod( Invocation.method( #saveUserID, [userId], ), - returnValue: _i23.Future.value(), - returnValueForMissingStub: _i23.Future.value(), - ) as _i23.Future); + returnValue: _i24.Future.value(), + returnValueForMissingStub: _i24.Future.value(), + ) as _i24.Future); @override - _i23.Future saveSignupEpoch(int? signupEpoch) => (super.noSuchMethod( + _i24.Future saveSignupEpoch(int? signupEpoch) => (super.noSuchMethod( Invocation.method( #saveSignupEpoch, [signupEpoch], ), - returnValue: _i23.Future.value(), - returnValueForMissingStub: _i23.Future.value(), - ) as _i23.Future); + returnValue: _i24.Future.value(), + returnValueForMissingStub: _i24.Future.value(), + ) as _i24.Future); @override - _i34.AmountUnit amountUnit(_i22.Coin? coin) => (super.noSuchMethod( + _i35.AmountUnit amountUnit(_i23.Coin? coin) => (super.noSuchMethod( Invocation.method( #amountUnit, [coin], ), - returnValue: _i34.AmountUnit.normal, - ) as _i34.AmountUnit); + returnValue: _i35.AmountUnit.normal, + ) as _i35.AmountUnit); @override void updateAmountUnit({ - required _i22.Coin? coin, - required _i34.AmountUnit? amountUnit, + required _i23.Coin? coin, + required _i35.AmountUnit? amountUnit, }) => super.noSuchMethod( Invocation.method( @@ -2479,7 +2534,7 @@ class MockPrefs extends _i1.Mock implements _i24.Prefs { returnValueForMissingStub: null, ); @override - int maxDecimals(_i22.Coin? coin) => (super.noSuchMethod( + int maxDecimals(_i23.Coin? coin) => (super.noSuchMethod( Invocation.method( #maxDecimals, [coin], @@ -2488,7 +2543,7 @@ class MockPrefs extends _i1.Mock implements _i24.Prefs { ) as int); @override void updateMaxDecimals({ - required _i22.Coin? coin, + required _i23.Coin? coin, required int? maxDecimals, }) => super.noSuchMethod( @@ -2503,7 +2558,7 @@ class MockPrefs extends _i1.Mock implements _i24.Prefs { returnValueForMissingStub: null, ); @override - void addListener(_i25.VoidCallback? listener) => super.noSuchMethod( + void addListener(_i26.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #addListener, [listener], @@ -2511,7 +2566,7 @@ class MockPrefs extends _i1.Mock implements _i24.Prefs { returnValueForMissingStub: null, ); @override - void removeListener(_i25.VoidCallback? listener) => super.noSuchMethod( + void removeListener(_i26.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #removeListener, [listener], @@ -2539,7 +2594,7 @@ class MockPrefs extends _i1.Mock implements _i24.Prefs { /// A class which mocks [LocaleService]. /// /// See the documentation for Mockito's code generation for more information. -class MockLocaleService extends _i1.Mock implements _i35.LocaleService { +class MockLocaleService extends _i1.Mock implements _i36.LocaleService { MockLocaleService() { _i1.throwOnMissingStub(this); } @@ -2555,17 +2610,17 @@ class MockLocaleService extends _i1.Mock implements _i35.LocaleService { returnValue: false, ) as bool); @override - _i23.Future loadLocale({bool? notify = true}) => (super.noSuchMethod( + _i24.Future loadLocale({bool? notify = true}) => (super.noSuchMethod( Invocation.method( #loadLocale, [], {#notify: notify}, ), - returnValue: _i23.Future.value(), - returnValueForMissingStub: _i23.Future.value(), - ) as _i23.Future); + returnValue: _i24.Future.value(), + returnValueForMissingStub: _i24.Future.value(), + ) as _i24.Future); @override - void addListener(_i25.VoidCallback? listener) => super.noSuchMethod( + void addListener(_i26.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #addListener, [listener], @@ -2573,7 +2628,7 @@ class MockLocaleService extends _i1.Mock implements _i35.LocaleService { returnValueForMissingStub: null, ); @override - void removeListener(_i25.VoidCallback? listener) => super.noSuchMethod( + void removeListener(_i26.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #removeListener, [listener], @@ -2603,41 +2658,41 @@ class MockLocaleService extends _i1.Mock implements _i35.LocaleService { /// See the documentation for Mockito's code generation for more information. class MockNodeService extends _i1.Mock implements _i3.NodeService { @override - _i19.SecureStorageInterface get secureStorageInterface => (super.noSuchMethod( + _i20.SecureStorageInterface get secureStorageInterface => (super.noSuchMethod( Invocation.getter(#secureStorageInterface), - returnValue: _FakeSecureStorageInterface_17( + returnValue: _FakeSecureStorageInterface_18( this, Invocation.getter(#secureStorageInterface), ), - ) as _i19.SecureStorageInterface); + ) as _i20.SecureStorageInterface); @override - List<_i36.NodeModel> get primaryNodes => (super.noSuchMethod( + List<_i37.NodeModel> get primaryNodes => (super.noSuchMethod( Invocation.getter(#primaryNodes), - returnValue: <_i36.NodeModel>[], - ) as List<_i36.NodeModel>); + returnValue: <_i37.NodeModel>[], + ) as List<_i37.NodeModel>); @override - List<_i36.NodeModel> get nodes => (super.noSuchMethod( + List<_i37.NodeModel> get nodes => (super.noSuchMethod( Invocation.getter(#nodes), - returnValue: <_i36.NodeModel>[], - ) as List<_i36.NodeModel>); + returnValue: <_i37.NodeModel>[], + ) as List<_i37.NodeModel>); @override bool get hasListeners => (super.noSuchMethod( Invocation.getter(#hasListeners), returnValue: false, ) as bool); @override - _i23.Future updateDefaults() => (super.noSuchMethod( + _i24.Future updateDefaults() => (super.noSuchMethod( Invocation.method( #updateDefaults, [], ), - returnValue: _i23.Future.value(), - returnValueForMissingStub: _i23.Future.value(), - ) as _i23.Future); + returnValue: _i24.Future.value(), + returnValueForMissingStub: _i24.Future.value(), + ) as _i24.Future); @override - _i23.Future setPrimaryNodeFor({ - required _i22.Coin? coin, - required _i36.NodeModel? node, + _i24.Future setPrimaryNodeFor({ + required _i23.Coin? coin, + required _i37.NodeModel? node, bool? shouldNotifyListeners = false, }) => (super.noSuchMethod( @@ -2650,44 +2705,44 @@ class MockNodeService extends _i1.Mock implements _i3.NodeService { #shouldNotifyListeners: shouldNotifyListeners, }, ), - returnValue: _i23.Future.value(), - returnValueForMissingStub: _i23.Future.value(), - ) as _i23.Future); + returnValue: _i24.Future.value(), + returnValueForMissingStub: _i24.Future.value(), + ) as _i24.Future); @override - _i36.NodeModel? getPrimaryNodeFor({required _i22.Coin? coin}) => + _i37.NodeModel? getPrimaryNodeFor({required _i23.Coin? coin}) => (super.noSuchMethod(Invocation.method( #getPrimaryNodeFor, [], {#coin: coin}, - )) as _i36.NodeModel?); + )) as _i37.NodeModel?); @override - List<_i36.NodeModel> getNodesFor(_i22.Coin? coin) => (super.noSuchMethod( + List<_i37.NodeModel> getNodesFor(_i23.Coin? coin) => (super.noSuchMethod( Invocation.method( #getNodesFor, [coin], ), - returnValue: <_i36.NodeModel>[], - ) as List<_i36.NodeModel>); + returnValue: <_i37.NodeModel>[], + ) as List<_i37.NodeModel>); @override - _i36.NodeModel? getNodeById({required String? id}) => + _i37.NodeModel? getNodeById({required String? id}) => (super.noSuchMethod(Invocation.method( #getNodeById, [], {#id: id}, - )) as _i36.NodeModel?); + )) as _i37.NodeModel?); @override - List<_i36.NodeModel> failoverNodesFor({required _i22.Coin? coin}) => + List<_i37.NodeModel> failoverNodesFor({required _i23.Coin? coin}) => (super.noSuchMethod( Invocation.method( #failoverNodesFor, [], {#coin: coin}, ), - returnValue: <_i36.NodeModel>[], - ) as List<_i36.NodeModel>); + returnValue: <_i37.NodeModel>[], + ) as List<_i37.NodeModel>); @override - _i23.Future add( - _i36.NodeModel? node, + _i24.Future add( + _i37.NodeModel? node, String? password, bool? shouldNotifyListeners, ) => @@ -2700,11 +2755,11 @@ class MockNodeService extends _i1.Mock implements _i3.NodeService { shouldNotifyListeners, ], ), - returnValue: _i23.Future.value(), - returnValueForMissingStub: _i23.Future.value(), - ) as _i23.Future); + returnValue: _i24.Future.value(), + returnValueForMissingStub: _i24.Future.value(), + ) as _i24.Future); @override - _i23.Future delete( + _i24.Future delete( String? id, bool? shouldNotifyListeners, ) => @@ -2716,11 +2771,11 @@ class MockNodeService extends _i1.Mock implements _i3.NodeService { shouldNotifyListeners, ], ), - returnValue: _i23.Future.value(), - returnValueForMissingStub: _i23.Future.value(), - ) as _i23.Future); + returnValue: _i24.Future.value(), + returnValueForMissingStub: _i24.Future.value(), + ) as _i24.Future); @override - _i23.Future setEnabledState( + _i24.Future setEnabledState( String? id, bool? enabled, bool? shouldNotifyListeners, @@ -2734,12 +2789,12 @@ class MockNodeService extends _i1.Mock implements _i3.NodeService { shouldNotifyListeners, ], ), - returnValue: _i23.Future.value(), - returnValueForMissingStub: _i23.Future.value(), - ) as _i23.Future); + returnValue: _i24.Future.value(), + returnValueForMissingStub: _i24.Future.value(), + ) as _i24.Future); @override - _i23.Future edit( - _i36.NodeModel? editedNode, + _i24.Future edit( + _i37.NodeModel? editedNode, String? password, bool? shouldNotifyListeners, ) => @@ -2752,20 +2807,20 @@ class MockNodeService extends _i1.Mock implements _i3.NodeService { shouldNotifyListeners, ], ), - returnValue: _i23.Future.value(), - returnValueForMissingStub: _i23.Future.value(), - ) as _i23.Future); + returnValue: _i24.Future.value(), + returnValueForMissingStub: _i24.Future.value(), + ) as _i24.Future); @override - _i23.Future updateCommunityNodes() => (super.noSuchMethod( + _i24.Future updateCommunityNodes() => (super.noSuchMethod( Invocation.method( #updateCommunityNodes, [], ), - returnValue: _i23.Future.value(), - returnValueForMissingStub: _i23.Future.value(), - ) as _i23.Future); + returnValue: _i24.Future.value(), + returnValueForMissingStub: _i24.Future.value(), + ) as _i24.Future); @override - void addListener(_i25.VoidCallback? listener) => super.noSuchMethod( + void addListener(_i26.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #addListener, [listener], @@ -2773,7 +2828,7 @@ class MockNodeService extends _i1.Mock implements _i3.NodeService { returnValueForMissingStub: null, ); @override - void removeListener(_i25.VoidCallback? listener) => super.noSuchMethod( + void removeListener(_i26.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #removeListener, [listener], @@ -2816,23 +2871,23 @@ class MockManager extends _i1.Mock implements _i6.Manager { returnValueForMissingStub: null, ); @override - _i20.CoinServiceAPI get wallet => (super.noSuchMethod( + _i21.CoinServiceAPI get wallet => (super.noSuchMethod( Invocation.getter(#wallet), - returnValue: _FakeCoinServiceAPI_18( + returnValue: _FakeCoinServiceAPI_19( this, Invocation.getter(#wallet), ), - ) as _i20.CoinServiceAPI); + ) as _i21.CoinServiceAPI); @override bool get hasBackgroundRefreshListener => (super.noSuchMethod( Invocation.getter(#hasBackgroundRefreshListener), returnValue: false, ) as bool); @override - _i22.Coin get coin => (super.noSuchMethod( + _i23.Coin get coin => (super.noSuchMethod( Invocation.getter(#coin), - returnValue: _i22.Coin.bitcoin, - ) as _i22.Coin); + returnValue: _i23.Coin.bitcoin, + ) as _i23.Coin); @override bool get isRefreshing => (super.noSuchMethod( Invocation.getter(#isRefreshing), @@ -2865,23 +2920,23 @@ class MockManager extends _i1.Mock implements _i6.Manager { returnValueForMissingStub: null, ); @override - _i23.Future<_i8.FeeObject> get fees => (super.noSuchMethod( + _i24.Future<_i8.FeeObject> get fees => (super.noSuchMethod( Invocation.getter(#fees), - returnValue: _i23.Future<_i8.FeeObject>.value(_FakeFeeObject_5( + returnValue: _i24.Future<_i8.FeeObject>.value(_FakeFeeObject_5( this, Invocation.getter(#fees), )), - ) as _i23.Future<_i8.FeeObject>); + ) as _i24.Future<_i8.FeeObject>); @override - _i23.Future get maxFee => (super.noSuchMethod( + _i24.Future get maxFee => (super.noSuchMethod( Invocation.getter(#maxFee), - returnValue: _i23.Future.value(0), - ) as _i23.Future); + returnValue: _i24.Future.value(0), + ) as _i24.Future); @override - _i23.Future get currentReceivingAddress => (super.noSuchMethod( + _i24.Future get currentReceivingAddress => (super.noSuchMethod( Invocation.getter(#currentReceivingAddress), - returnValue: _i23.Future.value(''), - ) as _i23.Future); + returnValue: _i24.Future.value(''), + ) as _i24.Future); @override _i11.Balance get balance => (super.noSuchMethod( Invocation.getter(#balance), @@ -2891,16 +2946,16 @@ class MockManager extends _i1.Mock implements _i6.Manager { ), ) as _i11.Balance); @override - _i23.Future> get transactions => (super.noSuchMethod( + _i24.Future> get transactions => (super.noSuchMethod( Invocation.getter(#transactions), returnValue: - _i23.Future>.value(<_i17.Transaction>[]), - ) as _i23.Future>); + _i24.Future>.value(<_i17.Transaction>[]), + ) as _i24.Future>); @override - _i23.Future> get utxos => (super.noSuchMethod( + _i24.Future> get utxos => (super.noSuchMethod( Invocation.getter(#utxos), - returnValue: _i23.Future>.value(<_i17.UTXO>[]), - ) as _i23.Future>); + returnValue: _i24.Future>.value(<_i17.UTXO>[]), + ) as _i24.Future>); @override set walletName(String? newName) => super.noSuchMethod( Invocation.setter( @@ -2920,15 +2975,15 @@ class MockManager extends _i1.Mock implements _i6.Manager { returnValue: '', ) as String); @override - _i23.Future> get mnemonic => (super.noSuchMethod( + _i24.Future> get mnemonic => (super.noSuchMethod( Invocation.getter(#mnemonic), - returnValue: _i23.Future>.value([]), - ) as _i23.Future>); + returnValue: _i24.Future>.value([]), + ) as _i24.Future>); @override - _i23.Future get mnemonicPassphrase => (super.noSuchMethod( + _i24.Future get mnemonicPassphrase => (super.noSuchMethod( Invocation.getter(#mnemonicPassphrase), - returnValue: _i23.Future.value(), - ) as _i23.Future); + returnValue: _i24.Future.value(), + ) as _i24.Future); @override bool get isConnected => (super.noSuchMethod( Invocation.getter(#isConnected), @@ -2975,24 +3030,24 @@ class MockManager extends _i1.Mock implements _i6.Manager { returnValue: false, ) as bool); @override - _i23.Future get xpub => (super.noSuchMethod( + _i24.Future get xpub => (super.noSuchMethod( Invocation.getter(#xpub), - returnValue: _i23.Future.value(''), - ) as _i23.Future); + returnValue: _i24.Future.value(''), + ) as _i24.Future); @override bool get hasListeners => (super.noSuchMethod( Invocation.getter(#hasListeners), returnValue: false, ) as bool); @override - _i23.Future updateNode(bool? shouldRefresh) => (super.noSuchMethod( + _i24.Future updateNode(bool? shouldRefresh) => (super.noSuchMethod( Invocation.method( #updateNode, [shouldRefresh], ), - returnValue: _i23.Future.value(), - returnValueForMissingStub: _i23.Future.value(), - ) as _i23.Future); + returnValue: _i24.Future.value(), + returnValueForMissingStub: _i24.Future.value(), + ) as _i24.Future); @override void dispose() => super.noSuchMethod( Invocation.method( @@ -3002,7 +3057,7 @@ class MockManager extends _i1.Mock implements _i6.Manager { returnValueForMissingStub: null, ); @override - _i23.Future> prepareSend({ + _i24.Future> prepareSend({ required String? address, required _i14.Amount? amount, Map? args, @@ -3018,27 +3073,27 @@ class MockManager extends _i1.Mock implements _i6.Manager { }, ), returnValue: - _i23.Future>.value({}), - ) as _i23.Future>); + _i24.Future>.value({}), + ) as _i24.Future>); @override - _i23.Future confirmSend({required Map? txData}) => + _i24.Future confirmSend({required Map? txData}) => (super.noSuchMethod( Invocation.method( #confirmSend, [], {#txData: txData}, ), - returnValue: _i23.Future.value(''), - ) as _i23.Future); + returnValue: _i24.Future.value(''), + ) as _i24.Future); @override - _i23.Future refresh() => (super.noSuchMethod( + _i24.Future refresh() => (super.noSuchMethod( Invocation.method( #refresh, [], ), - returnValue: _i23.Future.value(), - returnValueForMissingStub: _i23.Future.value(), - ) as _i23.Future); + returnValue: _i24.Future.value(), + returnValueForMissingStub: _i24.Future.value(), + ) as _i24.Future); @override bool validateAddress(String? address) => (super.noSuchMethod( Invocation.method( @@ -3048,33 +3103,35 @@ class MockManager extends _i1.Mock implements _i6.Manager { returnValue: false, ) as bool); @override - _i23.Future testNetworkConnection() => (super.noSuchMethod( + _i24.Future testNetworkConnection() => (super.noSuchMethod( Invocation.method( #testNetworkConnection, [], ), - returnValue: _i23.Future.value(false), - ) as _i23.Future); + returnValue: _i24.Future.value(false), + ) as _i24.Future); @override - _i23.Future initializeNew() => (super.noSuchMethod( + _i24.Future initializeNew( + ({String mnemonicPassphrase, int wordCount})? data) => + (super.noSuchMethod( Invocation.method( #initializeNew, - [], + [data], ), - returnValue: _i23.Future.value(), - returnValueForMissingStub: _i23.Future.value(), - ) as _i23.Future); + returnValue: _i24.Future.value(), + returnValueForMissingStub: _i24.Future.value(), + ) as _i24.Future); @override - _i23.Future initializeExisting() => (super.noSuchMethod( + _i24.Future initializeExisting() => (super.noSuchMethod( Invocation.method( #initializeExisting, [], ), - returnValue: _i23.Future.value(), - returnValueForMissingStub: _i23.Future.value(), - ) as _i23.Future); + returnValue: _i24.Future.value(), + returnValueForMissingStub: _i24.Future.value(), + ) as _i24.Future); @override - _i23.Future recoverFromMnemonic({ + _i24.Future recoverFromMnemonic({ required String? mnemonic, String? mnemonicPassphrase, required int? maxUnusedAddressGap, @@ -3093,20 +3150,20 @@ class MockManager extends _i1.Mock implements _i6.Manager { #height: height, }, ), - returnValue: _i23.Future.value(), - returnValueForMissingStub: _i23.Future.value(), - ) as _i23.Future); + returnValue: _i24.Future.value(), + returnValueForMissingStub: _i24.Future.value(), + ) as _i24.Future); @override - _i23.Future exitCurrentWallet() => (super.noSuchMethod( + _i24.Future exitCurrentWallet() => (super.noSuchMethod( Invocation.method( #exitCurrentWallet, [], ), - returnValue: _i23.Future.value(), - returnValueForMissingStub: _i23.Future.value(), - ) as _i23.Future); + returnValue: _i24.Future.value(), + returnValueForMissingStub: _i24.Future.value(), + ) as _i24.Future); @override - _i23.Future fullRescan( + _i24.Future fullRescan( int? maxUnusedAddressGap, int? maxNumberOfIndexesToCheck, ) => @@ -3118,11 +3175,11 @@ class MockManager extends _i1.Mock implements _i6.Manager { maxNumberOfIndexesToCheck, ], ), - returnValue: _i23.Future.value(), - returnValueForMissingStub: _i23.Future.value(), - ) as _i23.Future); + returnValue: _i24.Future.value(), + returnValueForMissingStub: _i24.Future.value(), + ) as _i24.Future); @override - _i23.Future<_i14.Amount> estimateFeeFor( + _i24.Future<_i14.Amount> estimateFeeFor( _i14.Amount? amount, int? feeRate, ) => @@ -3134,7 +3191,7 @@ class MockManager extends _i1.Mock implements _i6.Manager { feeRate, ], ), - returnValue: _i23.Future<_i14.Amount>.value(_FakeAmount_12( + returnValue: _i24.Future<_i14.Amount>.value(_FakeAmount_12( this, Invocation.method( #estimateFeeFor, @@ -3144,26 +3201,26 @@ class MockManager extends _i1.Mock implements _i6.Manager { ], ), )), - ) as _i23.Future<_i14.Amount>); + ) as _i24.Future<_i14.Amount>); @override - _i23.Future generateNewAddress() => (super.noSuchMethod( + _i24.Future generateNewAddress() => (super.noSuchMethod( Invocation.method( #generateNewAddress, [], ), - returnValue: _i23.Future.value(false), - ) as _i23.Future); + returnValue: _i24.Future.value(false), + ) as _i24.Future); @override - _i23.Future resetRescanOnOpen() => (super.noSuchMethod( + _i24.Future resetRescanOnOpen() => (super.noSuchMethod( Invocation.method( #resetRescanOnOpen, [], ), - returnValue: _i23.Future.value(), - returnValueForMissingStub: _i23.Future.value(), - ) as _i23.Future); + returnValue: _i24.Future.value(), + returnValueForMissingStub: _i24.Future.value(), + ) as _i24.Future); @override - void addListener(_i25.VoidCallback? listener) => super.noSuchMethod( + void addListener(_i26.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #addListener, [listener], @@ -3171,7 +3228,7 @@ class MockManager extends _i1.Mock implements _i6.Manager { returnValueForMissingStub: null, ); @override - void removeListener(_i25.VoidCallback? listener) => super.noSuchMethod( + void removeListener(_i26.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #removeListener, [listener], @@ -3191,7 +3248,7 @@ class MockManager extends _i1.Mock implements _i6.Manager { /// A class which mocks [CoinServiceAPI]. /// /// See the documentation for Mockito's code generation for more information. -class MockCoinServiceAPI extends _i1.Mock implements _i20.CoinServiceAPI { +class MockCoinServiceAPI extends _i1.Mock implements _i21.CoinServiceAPI { @override set onIsActiveWalletChanged(void Function(bool)? _onIsActiveWalletChanged) => super.noSuchMethod( @@ -3202,10 +3259,10 @@ class MockCoinServiceAPI extends _i1.Mock implements _i20.CoinServiceAPI { returnValueForMissingStub: null, ); @override - _i22.Coin get coin => (super.noSuchMethod( + _i23.Coin get coin => (super.noSuchMethod( Invocation.getter(#coin), - returnValue: _i22.Coin.bitcoin, - ) as _i22.Coin); + returnValue: _i23.Coin.bitcoin, + ) as _i23.Coin); @override bool get isRefreshing => (super.noSuchMethod( Invocation.getter(#isRefreshing), @@ -3238,23 +3295,23 @@ class MockCoinServiceAPI extends _i1.Mock implements _i20.CoinServiceAPI { returnValueForMissingStub: null, ); @override - _i23.Future<_i8.FeeObject> get fees => (super.noSuchMethod( + _i24.Future<_i8.FeeObject> get fees => (super.noSuchMethod( Invocation.getter(#fees), - returnValue: _i23.Future<_i8.FeeObject>.value(_FakeFeeObject_5( + returnValue: _i24.Future<_i8.FeeObject>.value(_FakeFeeObject_5( this, Invocation.getter(#fees), )), - ) as _i23.Future<_i8.FeeObject>); + ) as _i24.Future<_i8.FeeObject>); @override - _i23.Future get maxFee => (super.noSuchMethod( + _i24.Future get maxFee => (super.noSuchMethod( Invocation.getter(#maxFee), - returnValue: _i23.Future.value(0), - ) as _i23.Future); + returnValue: _i24.Future.value(0), + ) as _i24.Future); @override - _i23.Future get currentReceivingAddress => (super.noSuchMethod( + _i24.Future get currentReceivingAddress => (super.noSuchMethod( Invocation.getter(#currentReceivingAddress), - returnValue: _i23.Future.value(''), - ) as _i23.Future); + returnValue: _i24.Future.value(''), + ) as _i24.Future); @override _i11.Balance get balance => (super.noSuchMethod( Invocation.getter(#balance), @@ -3264,16 +3321,16 @@ class MockCoinServiceAPI extends _i1.Mock implements _i20.CoinServiceAPI { ), ) as _i11.Balance); @override - _i23.Future> get transactions => (super.noSuchMethod( + _i24.Future> get transactions => (super.noSuchMethod( Invocation.getter(#transactions), returnValue: - _i23.Future>.value(<_i17.Transaction>[]), - ) as _i23.Future>); + _i24.Future>.value(<_i17.Transaction>[]), + ) as _i24.Future>); @override - _i23.Future> get utxos => (super.noSuchMethod( + _i24.Future> get utxos => (super.noSuchMethod( Invocation.getter(#utxos), - returnValue: _i23.Future>.value(<_i17.UTXO>[]), - ) as _i23.Future>); + returnValue: _i24.Future>.value(<_i17.UTXO>[]), + ) as _i24.Future>); @override set walletName(String? newName) => super.noSuchMethod( Invocation.setter( @@ -3293,20 +3350,20 @@ class MockCoinServiceAPI extends _i1.Mock implements _i20.CoinServiceAPI { returnValue: '', ) as String); @override - _i23.Future> get mnemonic => (super.noSuchMethod( + _i24.Future> get mnemonic => (super.noSuchMethod( Invocation.getter(#mnemonic), - returnValue: _i23.Future>.value([]), - ) as _i23.Future>); + returnValue: _i24.Future>.value([]), + ) as _i24.Future>); @override - _i23.Future get mnemonicString => (super.noSuchMethod( + _i24.Future get mnemonicString => (super.noSuchMethod( Invocation.getter(#mnemonicString), - returnValue: _i23.Future.value(), - ) as _i23.Future); + returnValue: _i24.Future.value(), + ) as _i24.Future); @override - _i23.Future get mnemonicPassphrase => (super.noSuchMethod( + _i24.Future get mnemonicPassphrase => (super.noSuchMethod( Invocation.getter(#mnemonicPassphrase), - returnValue: _i23.Future.value(), - ) as _i23.Future); + returnValue: _i24.Future.value(), + ) as _i24.Future); @override bool get hasCalledExit => (super.noSuchMethod( Invocation.getter(#hasCalledExit), @@ -3323,7 +3380,7 @@ class MockCoinServiceAPI extends _i1.Mock implements _i20.CoinServiceAPI { returnValue: 0, ) as int); @override - _i23.Future> prepareSend({ + _i24.Future> prepareSend({ required String? address, required _i14.Amount? amount, Map? args, @@ -3339,36 +3396,36 @@ class MockCoinServiceAPI extends _i1.Mock implements _i20.CoinServiceAPI { }, ), returnValue: - _i23.Future>.value({}), - ) as _i23.Future>); + _i24.Future>.value({}), + ) as _i24.Future>); @override - _i23.Future confirmSend({required Map? txData}) => + _i24.Future confirmSend({required Map? txData}) => (super.noSuchMethod( Invocation.method( #confirmSend, [], {#txData: txData}, ), - returnValue: _i23.Future.value(''), - ) as _i23.Future); + returnValue: _i24.Future.value(''), + ) as _i24.Future); @override - _i23.Future refresh() => (super.noSuchMethod( + _i24.Future refresh() => (super.noSuchMethod( Invocation.method( #refresh, [], ), - returnValue: _i23.Future.value(), - returnValueForMissingStub: _i23.Future.value(), - ) as _i23.Future); + returnValue: _i24.Future.value(), + returnValueForMissingStub: _i24.Future.value(), + ) as _i24.Future); @override - _i23.Future updateNode(bool? shouldRefresh) => (super.noSuchMethod( + _i24.Future updateNode(bool? shouldRefresh) => (super.noSuchMethod( Invocation.method( #updateNode, [shouldRefresh], ), - returnValue: _i23.Future.value(), - returnValueForMissingStub: _i23.Future.value(), - ) as _i23.Future); + returnValue: _i24.Future.value(), + returnValueForMissingStub: _i24.Future.value(), + ) as _i24.Future); @override bool validateAddress(String? address) => (super.noSuchMethod( Invocation.method( @@ -3378,15 +3435,15 @@ class MockCoinServiceAPI extends _i1.Mock implements _i20.CoinServiceAPI { returnValue: false, ) as bool); @override - _i23.Future testNetworkConnection() => (super.noSuchMethod( + _i24.Future testNetworkConnection() => (super.noSuchMethod( Invocation.method( #testNetworkConnection, [], ), - returnValue: _i23.Future.value(false), - ) as _i23.Future); + returnValue: _i24.Future.value(false), + ) as _i24.Future); @override - _i23.Future recoverFromMnemonic({ + _i24.Future recoverFromMnemonic({ required String? mnemonic, String? mnemonicPassphrase, required int? maxUnusedAddressGap, @@ -3405,38 +3462,40 @@ class MockCoinServiceAPI extends _i1.Mock implements _i20.CoinServiceAPI { #height: height, }, ), - returnValue: _i23.Future.value(), - returnValueForMissingStub: _i23.Future.value(), - ) as _i23.Future); + returnValue: _i24.Future.value(), + returnValueForMissingStub: _i24.Future.value(), + ) as _i24.Future); @override - _i23.Future initializeNew() => (super.noSuchMethod( + _i24.Future initializeNew( + ({String mnemonicPassphrase, int wordCount})? data) => + (super.noSuchMethod( Invocation.method( #initializeNew, - [], + [data], ), - returnValue: _i23.Future.value(), - returnValueForMissingStub: _i23.Future.value(), - ) as _i23.Future); + returnValue: _i24.Future.value(), + returnValueForMissingStub: _i24.Future.value(), + ) as _i24.Future); @override - _i23.Future initializeExisting() => (super.noSuchMethod( + _i24.Future initializeExisting() => (super.noSuchMethod( Invocation.method( #initializeExisting, [], ), - returnValue: _i23.Future.value(), - returnValueForMissingStub: _i23.Future.value(), - ) as _i23.Future); + returnValue: _i24.Future.value(), + returnValueForMissingStub: _i24.Future.value(), + ) as _i24.Future); @override - _i23.Future exit() => (super.noSuchMethod( + _i24.Future exit() => (super.noSuchMethod( Invocation.method( #exit, [], ), - returnValue: _i23.Future.value(), - returnValueForMissingStub: _i23.Future.value(), - ) as _i23.Future); + returnValue: _i24.Future.value(), + returnValueForMissingStub: _i24.Future.value(), + ) as _i24.Future); @override - _i23.Future fullRescan( + _i24.Future fullRescan( int? maxUnusedAddressGap, int? maxNumberOfIndexesToCheck, ) => @@ -3448,11 +3507,11 @@ class MockCoinServiceAPI extends _i1.Mock implements _i20.CoinServiceAPI { maxNumberOfIndexesToCheck, ], ), - returnValue: _i23.Future.value(), - returnValueForMissingStub: _i23.Future.value(), - ) as _i23.Future); + returnValue: _i24.Future.value(), + returnValueForMissingStub: _i24.Future.value(), + ) as _i24.Future); @override - _i23.Future<_i14.Amount> estimateFeeFor( + _i24.Future<_i14.Amount> estimateFeeFor( _i14.Amount? amount, int? feeRate, ) => @@ -3464,7 +3523,7 @@ class MockCoinServiceAPI extends _i1.Mock implements _i20.CoinServiceAPI { feeRate, ], ), - returnValue: _i23.Future<_i14.Amount>.value(_FakeAmount_12( + returnValue: _i24.Future<_i14.Amount>.value(_FakeAmount_12( this, Invocation.method( #estimateFeeFor, @@ -3474,23 +3533,23 @@ class MockCoinServiceAPI extends _i1.Mock implements _i20.CoinServiceAPI { ], ), )), - ) as _i23.Future<_i14.Amount>); + ) as _i24.Future<_i14.Amount>); @override - _i23.Future generateNewAddress() => (super.noSuchMethod( + _i24.Future generateNewAddress() => (super.noSuchMethod( Invocation.method( #generateNewAddress, [], ), - returnValue: _i23.Future.value(false), - ) as _i23.Future); + returnValue: _i24.Future.value(false), + ) as _i24.Future); @override - _i23.Future updateSentCachedTxData(Map? txData) => + _i24.Future updateSentCachedTxData(Map? txData) => (super.noSuchMethod( Invocation.method( #updateSentCachedTxData, [txData], ), - returnValue: _i23.Future.value(), - returnValueForMissingStub: _i23.Future.value(), - ) as _i23.Future); + returnValue: _i24.Future.value(), + returnValueForMissingStub: _i24.Future.value(), + ) as _i24.Future); } diff --git a/test/widget_tests/node_options_sheet_test.dart b/test/widget_tests/node_options_sheet_test.dart index b80e4682d..ce2b52560 100644 --- a/test/widget_tests/node_options_sheet_test.dart +++ b/test/widget_tests/node_options_sheet_test.dart @@ -9,6 +9,7 @@ import 'package:stackwallet/models/isar/stack_theme.dart'; import 'package:stackwallet/models/node_model.dart'; import 'package:stackwallet/providers/providers.dart'; import 'package:stackwallet/services/node_service.dart'; +import 'package:stackwallet/services/tor_service.dart'; import 'package:stackwallet/services/wallets.dart'; import 'package:stackwallet/themes/stack_colors.dart'; import 'package:stackwallet/utilities/enums/coin_enum.dart'; @@ -19,7 +20,7 @@ import 'package:tuple/tuple.dart'; import '../sample_data/theme_json.dart'; import 'node_options_sheet_test.mocks.dart'; -@GenerateMocks([Wallets, Prefs, NodeService]) +@GenerateMocks([Wallets, Prefs, NodeService, TorService]) void main() { testWidgets("Load Node Options widget", (tester) async { final mockWallets = MockWallets(); @@ -163,6 +164,7 @@ void main() { final mockWallets = MockWallets(); final mockPrefs = MockPrefs(); final mockNodeService = MockNodeService(); + final mockTorService = MockTorService(); when(mockNodeService.getNodeById(id: "node id")).thenAnswer( (realInvocation) => NodeModel( @@ -193,7 +195,8 @@ void main() { overrides: [ walletsChangeNotifierProvider.overrideWithValue(mockWallets), prefsChangeNotifierProvider.overrideWithValue(mockPrefs), - nodeServiceChangeNotifierProvider.overrideWithValue(mockNodeService) + nodeServiceChangeNotifierProvider.overrideWithValue(mockNodeService), + pTorService.overrideWithValue(mockTorService), ], child: MaterialApp( theme: ThemeData( diff --git a/test/widget_tests/node_options_sheet_test.mocks.dart b/test/widget_tests/node_options_sheet_test.mocks.dart index 86fdf5727..203e196a0 100644 --- a/test/widget_tests/node_options_sheet_test.mocks.dart +++ b/test/widget_tests/node_options_sheet_test.mocks.dart @@ -3,25 +3,28 @@ // Do not manually edit this file. // ignore_for_file: no_leading_underscores_for_library_prefixes -import 'dart:async' as _i11; -import 'dart:ui' as _i13; +import 'dart:async' as _i12; +import 'dart:io' as _i8; +import 'dart:ui' as _i14; import 'package:flutter/foundation.dart' as _i4; import 'package:flutter_riverpod/flutter_riverpod.dart' as _i5; import 'package:mockito/mockito.dart' as _i1; -import 'package:stackwallet/models/node_model.dart' as _i17; +import 'package:stackwallet/models/node_model.dart' as _i18; import 'package:stackwallet/services/coins/manager.dart' as _i6; import 'package:stackwallet/services/node_service.dart' as _i3; -import 'package:stackwallet/services/wallets.dart' as _i8; +import 'package:stackwallet/services/tor_service.dart' as _i19; +import 'package:stackwallet/services/wallets.dart' as _i9; import 'package:stackwallet/services/wallets_service.dart' as _i2; -import 'package:stackwallet/utilities/amount/amount_unit.dart' as _i16; -import 'package:stackwallet/utilities/enums/backup_frequency_type.dart' as _i15; -import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i9; -import 'package:stackwallet/utilities/enums/sync_type_enum.dart' as _i14; +import 'package:stackwallet/utilities/amount/amount_unit.dart' as _i17; +import 'package:stackwallet/utilities/enums/backup_frequency_type.dart' as _i16; +import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i10; +import 'package:stackwallet/utilities/enums/sync_type_enum.dart' as _i15; import 'package:stackwallet/utilities/flutter_secure_storage_interface.dart' as _i7; -import 'package:stackwallet/utilities/prefs.dart' as _i12; -import 'package:tuple/tuple.dart' as _i10; +import 'package:stackwallet/utilities/prefs.dart' as _i13; +import 'package:tor_ffi_plugin/tor_ffi_plugin.dart' as _i20; +import 'package:tuple/tuple.dart' as _i11; // ignore_for_file: type=lint // ignore_for_file: avoid_redundant_argument_values @@ -87,10 +90,21 @@ class _FakeSecureStorageInterface_4 extends _i1.SmartFake ); } +class _FakeInternetAddress_5 extends _i1.SmartFake + implements _i8.InternetAddress { + _FakeInternetAddress_5( + 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 _i8.Wallets { +class MockWallets extends _i1.Mock implements _i9.Wallets { MockWallets() { _i1.throwOnMissingStub(this); } @@ -157,7 +171,7 @@ class MockWallets extends _i1.Mock implements _i8.Wallets { returnValueForMissingStub: null, ); @override - List getWalletIdsFor({required _i9.Coin? coin}) => + List getWalletIdsFor({required _i10.Coin? coin}) => (super.noSuchMethod( Invocation.method( #getWalletIdsFor, @@ -167,20 +181,20 @@ class MockWallets extends _i1.Mock implements _i8.Wallets { returnValue: [], ) as List); @override - List<_i10.Tuple2<_i9.Coin, List<_i5.ChangeNotifierProvider<_i6.Manager>>>> + List<_i11.Tuple2<_i10.Coin, List<_i5.ChangeNotifierProvider<_i6.Manager>>>> getManagerProvidersByCoin() => (super.noSuchMethod( Invocation.method( #getManagerProvidersByCoin, [], ), - returnValue: <_i10.Tuple2<_i9.Coin, + returnValue: <_i11.Tuple2<_i10.Coin, List<_i5.ChangeNotifierProvider<_i6.Manager>>>>[], ) as List< - _i10.Tuple2<_i9.Coin, + _i11.Tuple2<_i10.Coin, List<_i5.ChangeNotifierProvider<_i6.Manager>>>>); @override List<_i5.ChangeNotifierProvider<_i6.Manager>> getManagerProvidersForCoin( - _i9.Coin? coin) => + _i10.Coin? coin) => (super.noSuchMethod( Invocation.method( #getManagerProvidersForCoin, @@ -244,17 +258,17 @@ class MockWallets extends _i1.Mock implements _i8.Wallets { returnValueForMissingStub: null, ); @override - _i11.Future load(_i12.Prefs? prefs) => (super.noSuchMethod( + _i12.Future load(_i13.Prefs? prefs) => (super.noSuchMethod( Invocation.method( #load, [prefs], ), - returnValue: _i11.Future.value(), - returnValueForMissingStub: _i11.Future.value(), - ) as _i11.Future); + returnValue: _i12.Future.value(), + returnValueForMissingStub: _i12.Future.value(), + ) as _i12.Future); @override - _i11.Future loadAfterStackRestore( - _i12.Prefs? prefs, + _i12.Future loadAfterStackRestore( + _i13.Prefs? prefs, List<_i6.Manager>? managers, ) => (super.noSuchMethod( @@ -265,11 +279,11 @@ class MockWallets extends _i1.Mock implements _i8.Wallets { managers, ], ), - returnValue: _i11.Future.value(), - returnValueForMissingStub: _i11.Future.value(), - ) as _i11.Future); + returnValue: _i12.Future.value(), + returnValueForMissingStub: _i12.Future.value(), + ) as _i12.Future); @override - void addListener(_i13.VoidCallback? listener) => super.noSuchMethod( + void addListener(_i14.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #addListener, [listener], @@ -277,7 +291,7 @@ class MockWallets extends _i1.Mock implements _i8.Wallets { returnValueForMissingStub: null, ); @override - void removeListener(_i13.VoidCallback? listener) => super.noSuchMethod( + void removeListener(_i14.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #removeListener, [listener], @@ -297,7 +311,7 @@ class MockWallets extends _i1.Mock implements _i8.Wallets { /// A class which mocks [Prefs]. /// /// See the documentation for Mockito's code generation for more information. -class MockPrefs extends _i1.Mock implements _i12.Prefs { +class MockPrefs extends _i1.Mock implements _i13.Prefs { MockPrefs() { _i1.throwOnMissingStub(this); } @@ -353,12 +367,12 @@ class MockPrefs extends _i1.Mock implements _i12.Prefs { returnValueForMissingStub: null, ); @override - _i14.SyncingType get syncType => (super.noSuchMethod( + _i15.SyncingType get syncType => (super.noSuchMethod( Invocation.getter(#syncType), - returnValue: _i14.SyncingType.currentWalletOnly, - ) as _i14.SyncingType); + returnValue: _i15.SyncingType.currentWalletOnly, + ) as _i15.SyncingType); @override - set syncType(_i14.SyncingType? syncType) => super.noSuchMethod( + set syncType(_i15.SyncingType? syncType) => super.noSuchMethod( Invocation.setter( #syncType, syncType, @@ -470,6 +484,19 @@ class MockPrefs extends _i1.Mock implements _i12.Prefs { returnValueForMissingStub: null, ); @override + bool get torKillSwitch => (super.noSuchMethod( + Invocation.getter(#torKillSwitch), + returnValue: false, + ) as bool); + @override + set torKillSwitch(bool? torKillswitch) => super.noSuchMethod( + Invocation.setter( + #torKillSwitch, + torKillswitch, + ), + returnValueForMissingStub: null, + ); + @override bool get showTestNetCoins => (super.noSuchMethod( Invocation.getter(#showTestNetCoins), returnValue: false, @@ -504,12 +531,12 @@ class MockPrefs extends _i1.Mock implements _i12.Prefs { returnValueForMissingStub: null, ); @override - _i15.BackupFrequencyType get backupFrequencyType => (super.noSuchMethod( + _i16.BackupFrequencyType get backupFrequencyType => (super.noSuchMethod( Invocation.getter(#backupFrequencyType), - returnValue: _i15.BackupFrequencyType.everyTenMinutes, - ) as _i15.BackupFrequencyType); + returnValue: _i16.BackupFrequencyType.everyTenMinutes, + ) as _i16.BackupFrequencyType); @override - set backupFrequencyType(_i15.BackupFrequencyType? backupFrequencyType) => + set backupFrequencyType(_i16.BackupFrequencyType? backupFrequencyType) => super.noSuchMethod( Invocation.setter( #backupFrequencyType, @@ -642,66 +669,79 @@ class MockPrefs extends _i1.Mock implements _i12.Prefs { returnValueForMissingStub: null, ); @override + bool get useTor => (super.noSuchMethod( + Invocation.getter(#useTor), + returnValue: false, + ) as bool); + @override + set useTor(bool? useTor) => super.noSuchMethod( + Invocation.setter( + #useTor, + useTor, + ), + returnValueForMissingStub: null, + ); + @override bool get hasListeners => (super.noSuchMethod( Invocation.getter(#hasListeners), returnValue: false, ) as bool); @override - _i11.Future init() => (super.noSuchMethod( + _i12.Future init() => (super.noSuchMethod( Invocation.method( #init, [], ), - returnValue: _i11.Future.value(), - returnValueForMissingStub: _i11.Future.value(), - ) as _i11.Future); + returnValue: _i12.Future.value(), + returnValueForMissingStub: _i12.Future.value(), + ) as _i12.Future); @override - _i11.Future incrementCurrentNotificationIndex() => (super.noSuchMethod( + _i12.Future incrementCurrentNotificationIndex() => (super.noSuchMethod( Invocation.method( #incrementCurrentNotificationIndex, [], ), - returnValue: _i11.Future.value(), - returnValueForMissingStub: _i11.Future.value(), - ) as _i11.Future); + returnValue: _i12.Future.value(), + returnValueForMissingStub: _i12.Future.value(), + ) as _i12.Future); @override - _i11.Future isExternalCallsSet() => (super.noSuchMethod( + _i12.Future isExternalCallsSet() => (super.noSuchMethod( Invocation.method( #isExternalCallsSet, [], ), - returnValue: _i11.Future.value(false), - ) as _i11.Future); + returnValue: _i12.Future.value(false), + ) as _i12.Future); @override - _i11.Future saveUserID(String? userId) => (super.noSuchMethod( + _i12.Future saveUserID(String? userId) => (super.noSuchMethod( Invocation.method( #saveUserID, [userId], ), - returnValue: _i11.Future.value(), - returnValueForMissingStub: _i11.Future.value(), - ) as _i11.Future); + returnValue: _i12.Future.value(), + returnValueForMissingStub: _i12.Future.value(), + ) as _i12.Future); @override - _i11.Future saveSignupEpoch(int? signupEpoch) => (super.noSuchMethod( + _i12.Future saveSignupEpoch(int? signupEpoch) => (super.noSuchMethod( Invocation.method( #saveSignupEpoch, [signupEpoch], ), - returnValue: _i11.Future.value(), - returnValueForMissingStub: _i11.Future.value(), - ) as _i11.Future); + returnValue: _i12.Future.value(), + returnValueForMissingStub: _i12.Future.value(), + ) as _i12.Future); @override - _i16.AmountUnit amountUnit(_i9.Coin? coin) => (super.noSuchMethod( + _i17.AmountUnit amountUnit(_i10.Coin? coin) => (super.noSuchMethod( Invocation.method( #amountUnit, [coin], ), - returnValue: _i16.AmountUnit.normal, - ) as _i16.AmountUnit); + returnValue: _i17.AmountUnit.normal, + ) as _i17.AmountUnit); @override void updateAmountUnit({ - required _i9.Coin? coin, - required _i16.AmountUnit? amountUnit, + required _i10.Coin? coin, + required _i17.AmountUnit? amountUnit, }) => super.noSuchMethod( Invocation.method( @@ -715,7 +755,7 @@ class MockPrefs extends _i1.Mock implements _i12.Prefs { returnValueForMissingStub: null, ); @override - int maxDecimals(_i9.Coin? coin) => (super.noSuchMethod( + int maxDecimals(_i10.Coin? coin) => (super.noSuchMethod( Invocation.method( #maxDecimals, [coin], @@ -724,7 +764,7 @@ class MockPrefs extends _i1.Mock implements _i12.Prefs { ) as int); @override void updateMaxDecimals({ - required _i9.Coin? coin, + required _i10.Coin? coin, required int? maxDecimals, }) => super.noSuchMethod( @@ -739,7 +779,7 @@ class MockPrefs extends _i1.Mock implements _i12.Prefs { returnValueForMissingStub: null, ); @override - void addListener(_i13.VoidCallback? listener) => super.noSuchMethod( + void addListener(_i14.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #addListener, [listener], @@ -747,7 +787,7 @@ class MockPrefs extends _i1.Mock implements _i12.Prefs { returnValueForMissingStub: null, ); @override - void removeListener(_i13.VoidCallback? listener) => super.noSuchMethod( + void removeListener(_i14.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #removeListener, [listener], @@ -789,33 +829,33 @@ class MockNodeService extends _i1.Mock implements _i3.NodeService { ), ) as _i7.SecureStorageInterface); @override - List<_i17.NodeModel> get primaryNodes => (super.noSuchMethod( + List<_i18.NodeModel> get primaryNodes => (super.noSuchMethod( Invocation.getter(#primaryNodes), - returnValue: <_i17.NodeModel>[], - ) as List<_i17.NodeModel>); + returnValue: <_i18.NodeModel>[], + ) as List<_i18.NodeModel>); @override - List<_i17.NodeModel> get nodes => (super.noSuchMethod( + List<_i18.NodeModel> get nodes => (super.noSuchMethod( Invocation.getter(#nodes), - returnValue: <_i17.NodeModel>[], - ) as List<_i17.NodeModel>); + returnValue: <_i18.NodeModel>[], + ) as List<_i18.NodeModel>); @override bool get hasListeners => (super.noSuchMethod( Invocation.getter(#hasListeners), returnValue: false, ) as bool); @override - _i11.Future updateDefaults() => (super.noSuchMethod( + _i12.Future updateDefaults() => (super.noSuchMethod( Invocation.method( #updateDefaults, [], ), - returnValue: _i11.Future.value(), - returnValueForMissingStub: _i11.Future.value(), - ) as _i11.Future); + returnValue: _i12.Future.value(), + returnValueForMissingStub: _i12.Future.value(), + ) as _i12.Future); @override - _i11.Future setPrimaryNodeFor({ - required _i9.Coin? coin, - required _i17.NodeModel? node, + _i12.Future setPrimaryNodeFor({ + required _i10.Coin? coin, + required _i18.NodeModel? node, bool? shouldNotifyListeners = false, }) => (super.noSuchMethod( @@ -828,44 +868,44 @@ class MockNodeService extends _i1.Mock implements _i3.NodeService { #shouldNotifyListeners: shouldNotifyListeners, }, ), - returnValue: _i11.Future.value(), - returnValueForMissingStub: _i11.Future.value(), - ) as _i11.Future); + returnValue: _i12.Future.value(), + returnValueForMissingStub: _i12.Future.value(), + ) as _i12.Future); @override - _i17.NodeModel? getPrimaryNodeFor({required _i9.Coin? coin}) => + _i18.NodeModel? getPrimaryNodeFor({required _i10.Coin? coin}) => (super.noSuchMethod(Invocation.method( #getPrimaryNodeFor, [], {#coin: coin}, - )) as _i17.NodeModel?); + )) as _i18.NodeModel?); @override - List<_i17.NodeModel> getNodesFor(_i9.Coin? coin) => (super.noSuchMethod( + List<_i18.NodeModel> getNodesFor(_i10.Coin? coin) => (super.noSuchMethod( Invocation.method( #getNodesFor, [coin], ), - returnValue: <_i17.NodeModel>[], - ) as List<_i17.NodeModel>); + returnValue: <_i18.NodeModel>[], + ) as List<_i18.NodeModel>); @override - _i17.NodeModel? getNodeById({required String? id}) => + _i18.NodeModel? getNodeById({required String? id}) => (super.noSuchMethod(Invocation.method( #getNodeById, [], {#id: id}, - )) as _i17.NodeModel?); + )) as _i18.NodeModel?); @override - List<_i17.NodeModel> failoverNodesFor({required _i9.Coin? coin}) => + List<_i18.NodeModel> failoverNodesFor({required _i10.Coin? coin}) => (super.noSuchMethod( Invocation.method( #failoverNodesFor, [], {#coin: coin}, ), - returnValue: <_i17.NodeModel>[], - ) as List<_i17.NodeModel>); + returnValue: <_i18.NodeModel>[], + ) as List<_i18.NodeModel>); @override - _i11.Future add( - _i17.NodeModel? node, + _i12.Future add( + _i18.NodeModel? node, String? password, bool? shouldNotifyListeners, ) => @@ -878,11 +918,11 @@ class MockNodeService extends _i1.Mock implements _i3.NodeService { shouldNotifyListeners, ], ), - returnValue: _i11.Future.value(), - returnValueForMissingStub: _i11.Future.value(), - ) as _i11.Future); + returnValue: _i12.Future.value(), + returnValueForMissingStub: _i12.Future.value(), + ) as _i12.Future); @override - _i11.Future delete( + _i12.Future delete( String? id, bool? shouldNotifyListeners, ) => @@ -894,11 +934,11 @@ class MockNodeService extends _i1.Mock implements _i3.NodeService { shouldNotifyListeners, ], ), - returnValue: _i11.Future.value(), - returnValueForMissingStub: _i11.Future.value(), - ) as _i11.Future); + returnValue: _i12.Future.value(), + returnValueForMissingStub: _i12.Future.value(), + ) as _i12.Future); @override - _i11.Future setEnabledState( + _i12.Future setEnabledState( String? id, bool? enabled, bool? shouldNotifyListeners, @@ -912,12 +952,12 @@ class MockNodeService extends _i1.Mock implements _i3.NodeService { shouldNotifyListeners, ], ), - returnValue: _i11.Future.value(), - returnValueForMissingStub: _i11.Future.value(), - ) as _i11.Future); + returnValue: _i12.Future.value(), + returnValueForMissingStub: _i12.Future.value(), + ) as _i12.Future); @override - _i11.Future edit( - _i17.NodeModel? editedNode, + _i12.Future edit( + _i18.NodeModel? editedNode, String? password, bool? shouldNotifyListeners, ) => @@ -930,20 +970,20 @@ class MockNodeService extends _i1.Mock implements _i3.NodeService { shouldNotifyListeners, ], ), - returnValue: _i11.Future.value(), - returnValueForMissingStub: _i11.Future.value(), - ) as _i11.Future); + returnValue: _i12.Future.value(), + returnValueForMissingStub: _i12.Future.value(), + ) as _i12.Future); @override - _i11.Future updateCommunityNodes() => (super.noSuchMethod( + _i12.Future updateCommunityNodes() => (super.noSuchMethod( Invocation.method( #updateCommunityNodes, [], ), - returnValue: _i11.Future.value(), - returnValueForMissingStub: _i11.Future.value(), - ) as _i11.Future); + returnValue: _i12.Future.value(), + returnValueForMissingStub: _i12.Future.value(), + ) as _i12.Future); @override - void addListener(_i13.VoidCallback? listener) => super.noSuchMethod( + void addListener(_i14.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #addListener, [listener], @@ -951,7 +991,7 @@ class MockNodeService extends _i1.Mock implements _i3.NodeService { returnValueForMissingStub: null, ); @override - void removeListener(_i13.VoidCallback? listener) => super.noSuchMethod( + void removeListener(_i14.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #removeListener, [listener], @@ -975,3 +1015,56 @@ class MockNodeService extends _i1.Mock implements _i3.NodeService { returnValueForMissingStub: null, ); } + +/// A class which mocks [TorService]. +/// +/// See the documentation for Mockito's code generation for more information. +class MockTorService extends _i1.Mock implements _i19.TorService { + MockTorService() { + _i1.throwOnMissingStub(this); + } + + @override + bool get enabled => (super.noSuchMethod( + Invocation.getter(#enabled), + returnValue: false, + ) as bool); + @override + ({_i8.InternetAddress host, int port}) get proxyInfo => (super.noSuchMethod( + Invocation.getter(#proxyInfo), + returnValue: ( + host: _FakeInternetAddress_5( + this, + Invocation.getter(#proxyInfo), + ), + port: 0 + ), + ) as ({_i8.InternetAddress host, int port})); + @override + void init({_i20.Tor? mockableOverride}) => super.noSuchMethod( + Invocation.method( + #init, + [], + {#mockableOverride: mockableOverride}, + ), + returnValueForMissingStub: null, + ); + @override + _i12.Future start() => (super.noSuchMethod( + Invocation.method( + #start, + [], + ), + returnValue: _i12.Future.value(), + returnValueForMissingStub: _i12.Future.value(), + ) as _i12.Future); + @override + _i12.Future stop() => (super.noSuchMethod( + Invocation.method( + #stop, + [], + ), + returnValue: _i12.Future.value(), + returnValueForMissingStub: _i12.Future.value(), + ) as _i12.Future); +} diff --git a/test/widget_tests/table_view/table_view_row_test.dart b/test/widget_tests/table_view/table_view_row_test.dart index 4a84f0e64..9e9f4360e 100644 --- a/test/widget_tests/table_view/table_view_row_test.dart +++ b/test/widget_tests/table_view/table_view_row_test.dart @@ -1,3 +1,5 @@ +import 'dart:io'; + import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_test/flutter_test.dart'; @@ -12,6 +14,7 @@ import 'package:stackwallet/services/coins/coin_service.dart'; import 'package:stackwallet/services/coins/manager.dart'; import 'package:stackwallet/services/wallets.dart'; import 'package:stackwallet/services/wallets_service.dart'; +import 'package:stackwallet/themes/coin_icon_provider.dart'; import 'package:stackwallet/themes/stack_colors.dart'; import 'package:stackwallet/themes/theme_service.dart'; import 'package:stackwallet/utilities/amount/amount.dart'; @@ -72,6 +75,10 @@ void main() { overrides: [ walletsChangeNotifierProvider.overrideWithValue(mockWallet), pThemeService.overrideWithValue(mockThemeService), + coinIconProvider.overrideWithProvider( + (argument) => Provider((_) => + "${Directory.current.path}/test/sample_data/light/assets/dummy.svg"), + ), ], child: MaterialApp( theme: ThemeData( 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 2079f64b0..afb3f48c9 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 @@ -3,40 +3,41 @@ // Do not manually edit this file. // ignore_for_file: no_leading_underscores_for_library_prefixes -import 'dart:async' as _i22; -import 'dart:typed_data' as _i27; -import 'dart:ui' as _i24; +import 'dart:async' as _i23; +import 'dart:typed_data' as _i28; +import 'dart:ui' as _i25; -import 'package:bip32/bip32.dart' as _i16; -import 'package:bip47/bip47.dart' as _i18; -import 'package:bitcoindart/bitcoindart.dart' as _i13; +import 'package:bip32/bip32.dart' as _i17; +import 'package:bip47/bip47.dart' as _i19; +import 'package:bitcoindart/bitcoindart.dart' as _i14; import 'package:flutter/foundation.dart' as _i4; import 'package:flutter_riverpod/flutter_riverpod.dart' as _i5; import 'package:mockito/mockito.dart' as _i1; -import 'package:stackwallet/db/isar/main_db.dart' as _i7; -import 'package:stackwallet/electrumx_rpc/cached_electrumx.dart' as _i11; -import 'package:stackwallet/electrumx_rpc/electrumx.dart' as _i10; -import 'package:stackwallet/models/balance.dart' as _i12; -import 'package:stackwallet/models/isar/models/isar_models.dart' as _i17; -import 'package:stackwallet/models/isar/stack_theme.dart' as _i26; -import 'package:stackwallet/models/paymint/fee_object_model.dart' as _i9; -import 'package:stackwallet/models/signing_data.dart' as _i30; -import 'package:stackwallet/services/coins/bitcoin/bitcoin_wallet.dart' as _i28; -import 'package:stackwallet/services/coins/coin_service.dart' as _i19; +import 'package:stackwallet/db/isar/main_db.dart' as _i8; +import 'package:stackwallet/electrumx_rpc/cached_electrumx.dart' as _i12; +import 'package:stackwallet/electrumx_rpc/electrumx.dart' as _i11; +import 'package:stackwallet/models/balance.dart' as _i13; +import 'package:stackwallet/models/isar/models/isar_models.dart' as _i18; +import 'package:stackwallet/models/isar/stack_theme.dart' as _i27; +import 'package:stackwallet/models/paymint/fee_object_model.dart' as _i10; +import 'package:stackwallet/models/signing_data.dart' as _i31; +import 'package:stackwallet/networking/http.dart' as _i7; +import 'package:stackwallet/services/coins/bitcoin/bitcoin_wallet.dart' as _i29; +import 'package:stackwallet/services/coins/coin_service.dart' as _i20; import 'package:stackwallet/services/coins/manager.dart' as _i6; import 'package:stackwallet/services/node_service.dart' as _i3; import 'package:stackwallet/services/transaction_notification_tracker.dart' - as _i8; -import 'package:stackwallet/services/wallets.dart' as _i20; + as _i9; +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 _i25; -import 'package:stackwallet/utilities/amount/amount.dart' as _i14; -import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i21; -import 'package:stackwallet/utilities/enums/derive_path_type_enum.dart' as _i29; +import 'package:stackwallet/themes/theme_service.dart' as _i26; +import 'package:stackwallet/utilities/amount/amount.dart' as _i15; +import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i22; +import 'package:stackwallet/utilities/enums/derive_path_type_enum.dart' as _i30; import 'package:stackwallet/utilities/flutter_secure_storage_interface.dart' - as _i31; -import 'package:stackwallet/utilities/prefs.dart' as _i23; -import 'package:tuple/tuple.dart' as _i15; + as _i32; +import 'package:stackwallet/utilities/prefs.dart' as _i24; +import 'package:tuple/tuple.dart' as _i16; // ignore_for_file: type=lint // ignore_for_file: avoid_redundant_argument_values @@ -91,8 +92,8 @@ class _FakeManager_3 extends _i1.SmartFake implements _i6.Manager { ); } -class _FakeMainDB_4 extends _i1.SmartFake implements _i7.MainDB { - _FakeMainDB_4( +class _FakeHTTP_4 extends _i1.SmartFake implements _i7.HTTP { + _FakeHTTP_4( Object parent, Invocation parentInvocation, ) : super( @@ -101,9 +102,8 @@ class _FakeMainDB_4 extends _i1.SmartFake implements _i7.MainDB { ); } -class _FakeTransactionNotificationTracker_5 extends _i1.SmartFake - implements _i8.TransactionNotificationTracker { - _FakeTransactionNotificationTracker_5( +class _FakeMainDB_5 extends _i1.SmartFake implements _i8.MainDB { + _FakeMainDB_5( Object parent, Invocation parentInvocation, ) : super( @@ -112,8 +112,9 @@ class _FakeTransactionNotificationTracker_5 extends _i1.SmartFake ); } -class _FakeFeeObject_6 extends _i1.SmartFake implements _i9.FeeObject { - _FakeFeeObject_6( +class _FakeTransactionNotificationTracker_6 extends _i1.SmartFake + implements _i9.TransactionNotificationTracker { + _FakeTransactionNotificationTracker_6( Object parent, Invocation parentInvocation, ) : super( @@ -122,8 +123,8 @@ class _FakeFeeObject_6 extends _i1.SmartFake implements _i9.FeeObject { ); } -class _FakeElectrumX_7 extends _i1.SmartFake implements _i10.ElectrumX { - _FakeElectrumX_7( +class _FakeFeeObject_7 extends _i1.SmartFake implements _i10.FeeObject { + _FakeFeeObject_7( Object parent, Invocation parentInvocation, ) : super( @@ -132,9 +133,8 @@ class _FakeElectrumX_7 extends _i1.SmartFake implements _i10.ElectrumX { ); } -class _FakeCachedElectrumX_8 extends _i1.SmartFake - implements _i11.CachedElectrumX { - _FakeCachedElectrumX_8( +class _FakeElectrumX_8 extends _i1.SmartFake implements _i11.ElectrumX { + _FakeElectrumX_8( Object parent, Invocation parentInvocation, ) : super( @@ -143,8 +143,9 @@ class _FakeCachedElectrumX_8 extends _i1.SmartFake ); } -class _FakeBalance_9 extends _i1.SmartFake implements _i12.Balance { - _FakeBalance_9( +class _FakeCachedElectrumX_9 extends _i1.SmartFake + implements _i12.CachedElectrumX { + _FakeCachedElectrumX_9( Object parent, Invocation parentInvocation, ) : super( @@ -153,8 +154,8 @@ class _FakeBalance_9 extends _i1.SmartFake implements _i12.Balance { ); } -class _FakeNetworkType_10 extends _i1.SmartFake implements _i13.NetworkType { - _FakeNetworkType_10( +class _FakeBalance_10 extends _i1.SmartFake implements _i13.Balance { + _FakeBalance_10( Object parent, Invocation parentInvocation, ) : super( @@ -163,9 +164,8 @@ class _FakeNetworkType_10 extends _i1.SmartFake implements _i13.NetworkType { ); } -class _FakeElectrumXNode_11 extends _i1.SmartFake - implements _i10.ElectrumXNode { - _FakeElectrumXNode_11( +class _FakeNetworkType_11 extends _i1.SmartFake implements _i14.NetworkType { + _FakeNetworkType_11( Object parent, Invocation parentInvocation, ) : super( @@ -174,8 +174,9 @@ class _FakeElectrumXNode_11 extends _i1.SmartFake ); } -class _FakeAmount_12 extends _i1.SmartFake implements _i14.Amount { - _FakeAmount_12( +class _FakeElectrumXNode_12 extends _i1.SmartFake + implements _i11.ElectrumXNode { + _FakeElectrumXNode_12( Object parent, Invocation parentInvocation, ) : super( @@ -184,9 +185,8 @@ class _FakeAmount_12 extends _i1.SmartFake implements _i14.Amount { ); } -class _FakeTuple2_13 extends _i1.SmartFake - implements _i15.Tuple2 { - _FakeTuple2_13( +class _FakeAmount_13 extends _i1.SmartFake implements _i15.Amount { + _FakeAmount_13( Object parent, Invocation parentInvocation, ) : super( @@ -195,8 +195,9 @@ class _FakeTuple2_13 extends _i1.SmartFake ); } -class _FakeBIP32_14 extends _i1.SmartFake implements _i16.BIP32 { - _FakeBIP32_14( +class _FakeTuple2_14 extends _i1.SmartFake + implements _i16.Tuple2 { + _FakeTuple2_14( Object parent, Invocation parentInvocation, ) : super( @@ -205,8 +206,8 @@ class _FakeBIP32_14 extends _i1.SmartFake implements _i16.BIP32 { ); } -class _FakeAddress_15 extends _i1.SmartFake implements _i17.Address { - _FakeAddress_15( +class _FakeBIP32_15 extends _i1.SmartFake implements _i17.BIP32 { + _FakeBIP32_15( Object parent, Invocation parentInvocation, ) : super( @@ -215,8 +216,8 @@ class _FakeAddress_15 extends _i1.SmartFake implements _i17.Address { ); } -class _FakePaymentCode_16 extends _i1.SmartFake implements _i18.PaymentCode { - _FakePaymentCode_16( +class _FakeAddress_16 extends _i1.SmartFake implements _i18.Address { + _FakeAddress_16( Object parent, Invocation parentInvocation, ) : super( @@ -225,9 +226,19 @@ class _FakePaymentCode_16 extends _i1.SmartFake implements _i18.PaymentCode { ); } -class _FakeCoinServiceAPI_17 extends _i1.SmartFake - implements _i19.CoinServiceAPI { - _FakeCoinServiceAPI_17( +class _FakePaymentCode_17 extends _i1.SmartFake implements _i19.PaymentCode { + _FakePaymentCode_17( + Object parent, + Invocation parentInvocation, + ) : super( + parent, + parentInvocation, + ); +} + +class _FakeCoinServiceAPI_18 extends _i1.SmartFake + implements _i20.CoinServiceAPI { + _FakeCoinServiceAPI_18( Object parent, Invocation parentInvocation, ) : super( @@ -239,7 +250,7 @@ class _FakeCoinServiceAPI_17 extends _i1.SmartFake /// A class which mocks [Wallets]. /// /// See the documentation for Mockito's code generation for more information. -class MockWallets extends _i1.Mock implements _i20.Wallets { +class MockWallets extends _i1.Mock implements _i21.Wallets { MockWallets() { _i1.throwOnMissingStub(this); } @@ -306,7 +317,7 @@ class MockWallets extends _i1.Mock implements _i20.Wallets { returnValueForMissingStub: null, ); @override - List getWalletIdsFor({required _i21.Coin? coin}) => + List getWalletIdsFor({required _i22.Coin? coin}) => (super.noSuchMethod( Invocation.method( #getWalletIdsFor, @@ -316,20 +327,20 @@ class MockWallets extends _i1.Mock implements _i20.Wallets { returnValue: [], ) as List); @override - List<_i15.Tuple2<_i21.Coin, List<_i5.ChangeNotifierProvider<_i6.Manager>>>> + List<_i16.Tuple2<_i22.Coin, List<_i5.ChangeNotifierProvider<_i6.Manager>>>> getManagerProvidersByCoin() => (super.noSuchMethod( Invocation.method( #getManagerProvidersByCoin, [], ), - returnValue: <_i15.Tuple2<_i21.Coin, + returnValue: <_i16.Tuple2<_i22.Coin, List<_i5.ChangeNotifierProvider<_i6.Manager>>>>[], ) as List< - _i15.Tuple2<_i21.Coin, + _i16.Tuple2<_i22.Coin, List<_i5.ChangeNotifierProvider<_i6.Manager>>>>); @override List<_i5.ChangeNotifierProvider<_i6.Manager>> getManagerProvidersForCoin( - _i21.Coin? coin) => + _i22.Coin? coin) => (super.noSuchMethod( Invocation.method( #getManagerProvidersForCoin, @@ -393,17 +404,17 @@ class MockWallets extends _i1.Mock implements _i20.Wallets { returnValueForMissingStub: null, ); @override - _i22.Future load(_i23.Prefs? prefs) => (super.noSuchMethod( + _i23.Future load(_i24.Prefs? prefs) => (super.noSuchMethod( Invocation.method( #load, [prefs], ), - returnValue: _i22.Future.value(), - returnValueForMissingStub: _i22.Future.value(), - ) as _i22.Future); + returnValue: _i23.Future.value(), + returnValueForMissingStub: _i23.Future.value(), + ) as _i23.Future); @override - _i22.Future loadAfterStackRestore( - _i23.Prefs? prefs, + _i23.Future loadAfterStackRestore( + _i24.Prefs? prefs, List<_i6.Manager>? managers, ) => (super.noSuchMethod( @@ -414,11 +425,11 @@ class MockWallets extends _i1.Mock implements _i20.Wallets { managers, ], ), - returnValue: _i22.Future.value(), - returnValueForMissingStub: _i22.Future.value(), - ) as _i22.Future); + returnValue: _i23.Future.value(), + returnValueForMissingStub: _i23.Future.value(), + ) as _i23.Future); @override - void addListener(_i24.VoidCallback? listener) => super.noSuchMethod( + void addListener(_i25.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #addListener, [listener], @@ -426,7 +437,7 @@ class MockWallets extends _i1.Mock implements _i20.Wallets { returnValueForMissingStub: null, ); @override - void removeListener(_i24.VoidCallback? listener) => super.noSuchMethod( + void removeListener(_i25.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #removeListener, [listener], @@ -452,19 +463,19 @@ class MockWalletsService extends _i1.Mock implements _i2.WalletsService { } @override - _i22.Future> get walletNames => + _i23.Future> get walletNames => (super.noSuchMethod( Invocation.getter(#walletNames), - returnValue: _i22.Future>.value( + returnValue: _i23.Future>.value( {}), - ) as _i22.Future>); + ) as _i23.Future>); @override bool get hasListeners => (super.noSuchMethod( Invocation.getter(#hasListeners), returnValue: false, ) as bool); @override - _i22.Future renameWallet({ + _i23.Future renameWallet({ required String? from, required String? to, required bool? shouldNotifyListeners, @@ -479,8 +490,8 @@ class MockWalletsService extends _i1.Mock implements _i2.WalletsService { #shouldNotifyListeners: shouldNotifyListeners, }, ), - returnValue: _i22.Future.value(false), - ) as _i22.Future); + returnValue: _i23.Future.value(false), + ) as _i23.Future); @override Map fetchWalletsData() => (super.noSuchMethod( Invocation.method( @@ -490,10 +501,10 @@ class MockWalletsService extends _i1.Mock implements _i2.WalletsService { returnValue: {}, ) as Map); @override - _i22.Future addExistingStackWallet({ + _i23.Future addExistingStackWallet({ required String? name, required String? walletId, - required _i21.Coin? coin, + required _i22.Coin? coin, required bool? shouldNotifyListeners, }) => (super.noSuchMethod( @@ -507,13 +518,13 @@ class MockWalletsService extends _i1.Mock implements _i2.WalletsService { #shouldNotifyListeners: shouldNotifyListeners, }, ), - returnValue: _i22.Future.value(), - returnValueForMissingStub: _i22.Future.value(), - ) as _i22.Future); + returnValue: _i23.Future.value(), + returnValueForMissingStub: _i23.Future.value(), + ) as _i23.Future); @override - _i22.Future addNewWallet({ + _i23.Future addNewWallet({ required String? name, - required _i21.Coin? coin, + required _i22.Coin? coin, required bool? shouldNotifyListeners, }) => (super.noSuchMethod( @@ -526,46 +537,46 @@ class MockWalletsService extends _i1.Mock implements _i2.WalletsService { #shouldNotifyListeners: shouldNotifyListeners, }, ), - returnValue: _i22.Future.value(), - ) as _i22.Future); + returnValue: _i23.Future.value(), + ) as _i23.Future); @override - _i22.Future> getFavoriteWalletIds() => (super.noSuchMethod( + _i23.Future> getFavoriteWalletIds() => (super.noSuchMethod( Invocation.method( #getFavoriteWalletIds, [], ), - returnValue: _i22.Future>.value([]), - ) as _i22.Future>); + returnValue: _i23.Future>.value([]), + ) as _i23.Future>); @override - _i22.Future saveFavoriteWalletIds(List? walletIds) => + _i23.Future saveFavoriteWalletIds(List? walletIds) => (super.noSuchMethod( Invocation.method( #saveFavoriteWalletIds, [walletIds], ), - returnValue: _i22.Future.value(), - returnValueForMissingStub: _i22.Future.value(), - ) as _i22.Future); + returnValue: _i23.Future.value(), + returnValueForMissingStub: _i23.Future.value(), + ) as _i23.Future); @override - _i22.Future addFavorite(String? walletId) => (super.noSuchMethod( + _i23.Future addFavorite(String? walletId) => (super.noSuchMethod( Invocation.method( #addFavorite, [walletId], ), - returnValue: _i22.Future.value(), - returnValueForMissingStub: _i22.Future.value(), - ) as _i22.Future); + returnValue: _i23.Future.value(), + returnValueForMissingStub: _i23.Future.value(), + ) as _i23.Future); @override - _i22.Future removeFavorite(String? walletId) => (super.noSuchMethod( + _i23.Future removeFavorite(String? walletId) => (super.noSuchMethod( Invocation.method( #removeFavorite, [walletId], ), - returnValue: _i22.Future.value(), - returnValueForMissingStub: _i22.Future.value(), - ) as _i22.Future); + returnValue: _i23.Future.value(), + returnValueForMissingStub: _i23.Future.value(), + ) as _i23.Future); @override - _i22.Future moveFavorite({ + _i23.Future moveFavorite({ required int? fromIndex, required int? toIndex, }) => @@ -578,48 +589,48 @@ class MockWalletsService extends _i1.Mock implements _i2.WalletsService { #toIndex: toIndex, }, ), - returnValue: _i22.Future.value(), - returnValueForMissingStub: _i22.Future.value(), - ) as _i22.Future); + returnValue: _i23.Future.value(), + returnValueForMissingStub: _i23.Future.value(), + ) as _i23.Future); @override - _i22.Future checkForDuplicate(String? name) => (super.noSuchMethod( + _i23.Future checkForDuplicate(String? name) => (super.noSuchMethod( Invocation.method( #checkForDuplicate, [name], ), - returnValue: _i22.Future.value(false), - ) as _i22.Future); + returnValue: _i23.Future.value(false), + ) as _i23.Future); @override - _i22.Future getWalletId(String? walletName) => (super.noSuchMethod( + _i23.Future getWalletId(String? walletName) => (super.noSuchMethod( Invocation.method( #getWalletId, [walletName], ), - returnValue: _i22.Future.value(), - ) as _i22.Future); + returnValue: _i23.Future.value(), + ) as _i23.Future); @override - _i22.Future isMnemonicVerified({required String? walletId}) => + _i23.Future isMnemonicVerified({required String? walletId}) => (super.noSuchMethod( Invocation.method( #isMnemonicVerified, [], {#walletId: walletId}, ), - returnValue: _i22.Future.value(false), - ) as _i22.Future); + returnValue: _i23.Future.value(false), + ) as _i23.Future); @override - _i22.Future setMnemonicVerified({required String? walletId}) => + _i23.Future setMnemonicVerified({required String? walletId}) => (super.noSuchMethod( Invocation.method( #setMnemonicVerified, [], {#walletId: walletId}, ), - returnValue: _i22.Future.value(), - returnValueForMissingStub: _i22.Future.value(), - ) as _i22.Future); + returnValue: _i23.Future.value(), + returnValueForMissingStub: _i23.Future.value(), + ) as _i23.Future); @override - _i22.Future deleteWallet( + _i23.Future deleteWallet( String? name, bool? shouldNotifyListeners, ) => @@ -631,20 +642,20 @@ class MockWalletsService extends _i1.Mock implements _i2.WalletsService { shouldNotifyListeners, ], ), - returnValue: _i22.Future.value(0), - ) as _i22.Future); + returnValue: _i23.Future.value(0), + ) as _i23.Future); @override - _i22.Future refreshWallets(bool? shouldNotifyListeners) => + _i23.Future refreshWallets(bool? shouldNotifyListeners) => (super.noSuchMethod( Invocation.method( #refreshWallets, [shouldNotifyListeners], ), - returnValue: _i22.Future.value(), - returnValueForMissingStub: _i22.Future.value(), - ) as _i22.Future); + returnValue: _i23.Future.value(), + returnValueForMissingStub: _i23.Future.value(), + ) as _i23.Future); @override - void addListener(_i24.VoidCallback? listener) => super.noSuchMethod( + void addListener(_i25.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #addListener, [listener], @@ -652,7 +663,7 @@ class MockWalletsService extends _i1.Mock implements _i2.WalletsService { returnValueForMissingStub: null, ); @override - void removeListener(_i24.VoidCallback? listener) => super.noSuchMethod( + void removeListener(_i25.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #removeListener, [listener], @@ -680,26 +691,42 @@ class MockWalletsService extends _i1.Mock implements _i2.WalletsService { /// A class which mocks [ThemeService]. /// /// See the documentation for Mockito's code generation for more information. -class MockThemeService extends _i1.Mock implements _i25.ThemeService { +class MockThemeService extends _i1.Mock implements _i26.ThemeService { MockThemeService() { _i1.throwOnMissingStub(this); } @override - _i7.MainDB get db => (super.noSuchMethod( + _i7.HTTP get client => (super.noSuchMethod( + Invocation.getter(#client), + returnValue: _FakeHTTP_4( + this, + Invocation.getter(#client), + ), + ) as _i7.HTTP); + @override + set client(_i7.HTTP? _client) => super.noSuchMethod( + Invocation.setter( + #client, + _client, + ), + returnValueForMissingStub: null, + ); + @override + _i8.MainDB get db => (super.noSuchMethod( Invocation.getter(#db), - returnValue: _FakeMainDB_4( + returnValue: _FakeMainDB_5( this, Invocation.getter(#db), ), - ) as _i7.MainDB); + ) as _i8.MainDB); @override - List<_i26.StackTheme> get installedThemes => (super.noSuchMethod( + List<_i27.StackTheme> get installedThemes => (super.noSuchMethod( Invocation.getter(#installedThemes), - returnValue: <_i26.StackTheme>[], - ) as List<_i26.StackTheme>); + returnValue: <_i27.StackTheme>[], + ) as List<_i27.StackTheme>); @override - void init(_i7.MainDB? db) => super.noSuchMethod( + void init(_i8.MainDB? db) => super.noSuchMethod( Invocation.method( #init, [db], @@ -707,85 +734,85 @@ class MockThemeService extends _i1.Mock implements _i25.ThemeService { returnValueForMissingStub: null, ); @override - _i22.Future install({required _i27.Uint8List? themeArchiveData}) => + _i23.Future install({required _i28.Uint8List? themeArchiveData}) => (super.noSuchMethod( Invocation.method( #install, [], {#themeArchiveData: themeArchiveData}, ), - returnValue: _i22.Future.value(), - returnValueForMissingStub: _i22.Future.value(), - ) as _i22.Future); + returnValue: _i23.Future.value(), + returnValueForMissingStub: _i23.Future.value(), + ) as _i23.Future); @override - _i22.Future remove({required String? themeId}) => (super.noSuchMethod( + _i23.Future remove({required String? themeId}) => (super.noSuchMethod( Invocation.method( #remove, [], {#themeId: themeId}, ), - returnValue: _i22.Future.value(), - returnValueForMissingStub: _i22.Future.value(), - ) as _i22.Future); + returnValue: _i23.Future.value(), + returnValueForMissingStub: _i23.Future.value(), + ) as _i23.Future); @override - _i22.Future checkDefaultThemesOnStartup() => (super.noSuchMethod( + _i23.Future checkDefaultThemesOnStartup() => (super.noSuchMethod( Invocation.method( #checkDefaultThemesOnStartup, [], ), - returnValue: _i22.Future.value(), - returnValueForMissingStub: _i22.Future.value(), - ) as _i22.Future); + returnValue: _i23.Future.value(), + returnValueForMissingStub: _i23.Future.value(), + ) as _i23.Future); @override - _i22.Future verifyInstalled({required String? themeId}) => + _i23.Future verifyInstalled({required String? themeId}) => (super.noSuchMethod( Invocation.method( #verifyInstalled, [], {#themeId: themeId}, ), - returnValue: _i22.Future.value(false), - ) as _i22.Future); + returnValue: _i23.Future.value(false), + ) as _i23.Future); @override - _i22.Future> fetchThemes() => + _i23.Future> fetchThemes() => (super.noSuchMethod( Invocation.method( #fetchThemes, [], ), - returnValue: _i22.Future>.value( - <_i25.StackThemeMetaData>[]), - ) as _i22.Future>); + returnValue: _i23.Future>.value( + <_i26.StackThemeMetaData>[]), + ) as _i23.Future>); @override - _i22.Future<_i27.Uint8List> fetchTheme( - {required _i25.StackThemeMetaData? themeMetaData}) => + _i23.Future<_i28.Uint8List> fetchTheme( + {required _i26.StackThemeMetaData? themeMetaData}) => (super.noSuchMethod( Invocation.method( #fetchTheme, [], {#themeMetaData: themeMetaData}, ), - returnValue: _i22.Future<_i27.Uint8List>.value(_i27.Uint8List(0)), - ) as _i22.Future<_i27.Uint8List>); + returnValue: _i23.Future<_i28.Uint8List>.value(_i28.Uint8List(0)), + ) as _i23.Future<_i28.Uint8List>); @override - _i26.StackTheme? getTheme({required String? themeId}) => + _i27.StackTheme? getTheme({required String? themeId}) => (super.noSuchMethod(Invocation.method( #getTheme, [], {#themeId: themeId}, - )) as _i26.StackTheme?); + )) as _i27.StackTheme?); } /// A class which mocks [BitcoinWallet]. /// /// See the documentation for Mockito's code generation for more information. -class MockBitcoinWallet extends _i1.Mock implements _i28.BitcoinWallet { +class MockBitcoinWallet extends _i1.Mock implements _i29.BitcoinWallet { MockBitcoinWallet() { _i1.throwOnMissingStub(this); } @override - set timer(_i22.Timer? _timer) => super.noSuchMethod( + set timer(_i23.Timer? _timer) => super.noSuchMethod( Invocation.setter( #timer, _timer, @@ -793,15 +820,15 @@ class MockBitcoinWallet extends _i1.Mock implements _i28.BitcoinWallet { returnValueForMissingStub: null, ); @override - _i8.TransactionNotificationTracker get txTracker => (super.noSuchMethod( + _i9.TransactionNotificationTracker get txTracker => (super.noSuchMethod( Invocation.getter(#txTracker), - returnValue: _FakeTransactionNotificationTracker_5( + returnValue: _FakeTransactionNotificationTracker_6( this, Invocation.getter(#txTracker), ), - ) as _i8.TransactionNotificationTracker); + ) as _i9.TransactionNotificationTracker); @override - set txTracker(_i8.TransactionNotificationTracker? _txTracker) => + set txTracker(_i9.TransactionNotificationTracker? _txTracker) => super.noSuchMethod( Invocation.setter( #txTracker, @@ -862,74 +889,74 @@ class MockBitcoinWallet extends _i1.Mock implements _i28.BitcoinWallet { returnValue: false, ) as bool); @override - _i21.Coin get coin => (super.noSuchMethod( + _i22.Coin get coin => (super.noSuchMethod( Invocation.getter(#coin), - returnValue: _i21.Coin.bitcoin, - ) as _i21.Coin); + returnValue: _i22.Coin.bitcoin, + ) as _i22.Coin); @override - _i22.Future> get utxos => (super.noSuchMethod( + _i23.Future> get utxos => (super.noSuchMethod( Invocation.getter(#utxos), - returnValue: _i22.Future>.value(<_i17.UTXO>[]), - ) as _i22.Future>); + returnValue: _i23.Future>.value(<_i18.UTXO>[]), + ) as _i23.Future>); @override - _i22.Future> get transactions => (super.noSuchMethod( + _i23.Future> get transactions => (super.noSuchMethod( Invocation.getter(#transactions), returnValue: - _i22.Future>.value(<_i17.Transaction>[]), - ) as _i22.Future>); + _i23.Future>.value(<_i18.Transaction>[]), + ) as _i23.Future>); @override - _i22.Future get currentReceivingAddress => (super.noSuchMethod( + _i23.Future get currentReceivingAddress => (super.noSuchMethod( Invocation.getter(#currentReceivingAddress), - returnValue: _i22.Future.value(''), - ) as _i22.Future); + returnValue: _i23.Future.value(''), + ) as _i23.Future); @override - _i22.Future get currentChangeAddress => (super.noSuchMethod( + _i23.Future get currentChangeAddress => (super.noSuchMethod( Invocation.getter(#currentChangeAddress), - returnValue: _i22.Future.value(''), - ) as _i22.Future); + returnValue: _i23.Future.value(''), + ) as _i23.Future); @override - _i22.Future get currentChangeAddressP2PKH => (super.noSuchMethod( + _i23.Future get currentChangeAddressP2PKH => (super.noSuchMethod( Invocation.getter(#currentChangeAddressP2PKH), - returnValue: _i22.Future.value(''), - ) as _i22.Future); + returnValue: _i23.Future.value(''), + ) as _i23.Future); @override bool get hasCalledExit => (super.noSuchMethod( Invocation.getter(#hasCalledExit), returnValue: false, ) as bool); @override - _i22.Future<_i9.FeeObject> get fees => (super.noSuchMethod( + _i23.Future<_i10.FeeObject> get fees => (super.noSuchMethod( Invocation.getter(#fees), - returnValue: _i22.Future<_i9.FeeObject>.value(_FakeFeeObject_6( + returnValue: _i23.Future<_i10.FeeObject>.value(_FakeFeeObject_7( this, Invocation.getter(#fees), )), - ) as _i22.Future<_i9.FeeObject>); + ) as _i23.Future<_i10.FeeObject>); @override - _i22.Future get maxFee => (super.noSuchMethod( + _i23.Future get maxFee => (super.noSuchMethod( Invocation.getter(#maxFee), - returnValue: _i22.Future.value(0), - ) as _i22.Future); + returnValue: _i23.Future.value(0), + ) as _i23.Future); @override - _i22.Future> get mnemonic => (super.noSuchMethod( + _i23.Future> get mnemonic => (super.noSuchMethod( Invocation.getter(#mnemonic), - returnValue: _i22.Future>.value([]), - ) as _i22.Future>); + returnValue: _i23.Future>.value([]), + ) as _i23.Future>); @override - _i22.Future get mnemonicString => (super.noSuchMethod( + _i23.Future get mnemonicString => (super.noSuchMethod( Invocation.getter(#mnemonicString), - returnValue: _i22.Future.value(), - ) as _i22.Future); + returnValue: _i23.Future.value(), + ) as _i23.Future); @override - _i22.Future get mnemonicPassphrase => (super.noSuchMethod( + _i23.Future get mnemonicPassphrase => (super.noSuchMethod( Invocation.getter(#mnemonicPassphrase), - returnValue: _i22.Future.value(), - ) as _i22.Future); + returnValue: _i23.Future.value(), + ) as _i23.Future); @override - _i22.Future get chainHeight => (super.noSuchMethod( + _i23.Future get chainHeight => (super.noSuchMethod( Invocation.getter(#chainHeight), - returnValue: _i22.Future.value(0), - ) as _i22.Future); + returnValue: _i23.Future.value(0), + ) as _i23.Future); @override int get storedChainHeight => (super.noSuchMethod( Invocation.getter(#storedChainHeight), @@ -977,34 +1004,34 @@ class MockBitcoinWallet extends _i1.Mock implements _i28.BitcoinWallet { returnValueForMissingStub: null, ); @override - _i10.ElectrumX get electrumXClient => (super.noSuchMethod( + _i11.ElectrumX get electrumXClient => (super.noSuchMethod( Invocation.getter(#electrumXClient), - returnValue: _FakeElectrumX_7( + returnValue: _FakeElectrumX_8( this, Invocation.getter(#electrumXClient), ), - ) as _i10.ElectrumX); + ) as _i11.ElectrumX); @override - _i11.CachedElectrumX get cachedElectrumXClient => (super.noSuchMethod( + _i12.CachedElectrumX get cachedElectrumXClient => (super.noSuchMethod( Invocation.getter(#cachedElectrumXClient), - returnValue: _FakeCachedElectrumX_8( + returnValue: _FakeCachedElectrumX_9( this, Invocation.getter(#cachedElectrumXClient), ), - ) as _i11.CachedElectrumX); + ) as _i12.CachedElectrumX); @override - _i12.Balance get balance => (super.noSuchMethod( + _i13.Balance get balance => (super.noSuchMethod( Invocation.getter(#balance), - returnValue: _FakeBalance_9( + returnValue: _FakeBalance_10( this, Invocation.getter(#balance), ), - ) as _i12.Balance); + ) as _i13.Balance); @override - _i22.Future get xpub => (super.noSuchMethod( + _i23.Future get xpub => (super.noSuchMethod( Invocation.getter(#xpub), - returnValue: _i22.Future.value(''), - ) as _i22.Future); + returnValue: _i23.Future.value(''), + ) as _i23.Future); @override set onIsActiveWalletChanged(void Function(bool)? _onIsActiveWalletChanged) => super.noSuchMethod( @@ -1015,42 +1042,42 @@ class MockBitcoinWallet extends _i1.Mock implements _i28.BitcoinWallet { returnValueForMissingStub: null, ); @override - _i7.MainDB get db => (super.noSuchMethod( + _i8.MainDB get db => (super.noSuchMethod( Invocation.getter(#db), - returnValue: _FakeMainDB_4( + returnValue: _FakeMainDB_5( this, Invocation.getter(#db), ), - ) as _i7.MainDB); + ) as _i8.MainDB); @override - _i13.NetworkType get networkType => (super.noSuchMethod( + _i14.NetworkType get networkType => (super.noSuchMethod( Invocation.getter(#networkType), - returnValue: _FakeNetworkType_10( + returnValue: _FakeNetworkType_11( this, Invocation.getter(#networkType), ), - ) as _i13.NetworkType); + ) as _i14.NetworkType); @override - _i22.Future exit() => (super.noSuchMethod( + _i23.Future exit() => (super.noSuchMethod( Invocation.method( #exit, [], ), - returnValue: _i22.Future.value(), - returnValueForMissingStub: _i22.Future.value(), - ) as _i22.Future); + returnValue: _i23.Future.value(), + returnValueForMissingStub: _i23.Future.value(), + ) as _i23.Future); @override - _i29.DerivePathType addressType({required String? address}) => + _i30.DerivePathType addressType({required String? address}) => (super.noSuchMethod( Invocation.method( #addressType, [], {#address: address}, ), - returnValue: _i29.DerivePathType.bip44, - ) as _i29.DerivePathType); + returnValue: _i30.DerivePathType.bip44, + ) as _i30.DerivePathType); @override - _i22.Future recoverFromMnemonic({ + _i23.Future recoverFromMnemonic({ required String? mnemonic, String? mnemonicPassphrase, required int? maxUnusedAddressGap, @@ -1069,49 +1096,49 @@ class MockBitcoinWallet extends _i1.Mock implements _i28.BitcoinWallet { #height: height, }, ), - returnValue: _i22.Future.value(), - returnValueForMissingStub: _i22.Future.value(), - ) as _i22.Future); + returnValue: _i23.Future.value(), + returnValueForMissingStub: _i23.Future.value(), + ) as _i23.Future); @override - _i22.Future getTransactionCacheEarly(List? allAddresses) => + _i23.Future getTransactionCacheEarly(List? allAddresses) => (super.noSuchMethod( Invocation.method( #getTransactionCacheEarly, [allAddresses], ), - returnValue: _i22.Future.value(), - returnValueForMissingStub: _i22.Future.value(), - ) as _i22.Future); + returnValue: _i23.Future.value(), + returnValueForMissingStub: _i23.Future.value(), + ) as _i23.Future); @override - _i22.Future refreshIfThereIsNewData() => (super.noSuchMethod( + _i23.Future refreshIfThereIsNewData() => (super.noSuchMethod( Invocation.method( #refreshIfThereIsNewData, [], ), - returnValue: _i22.Future.value(false), - ) as _i22.Future); + returnValue: _i23.Future.value(false), + ) as _i23.Future); @override - _i22.Future getAllTxsToWatch() => (super.noSuchMethod( + _i23.Future getAllTxsToWatch() => (super.noSuchMethod( Invocation.method( #getAllTxsToWatch, [], ), - returnValue: _i22.Future.value(), - returnValueForMissingStub: _i22.Future.value(), - ) as _i22.Future); + returnValue: _i23.Future.value(), + returnValueForMissingStub: _i23.Future.value(), + ) as _i23.Future); @override - _i22.Future refresh() => (super.noSuchMethod( + _i23.Future refresh() => (super.noSuchMethod( Invocation.method( #refresh, [], ), - returnValue: _i22.Future.value(), - returnValueForMissingStub: _i22.Future.value(), - ) as _i22.Future); + returnValue: _i23.Future.value(), + returnValueForMissingStub: _i23.Future.value(), + ) as _i23.Future); @override - _i22.Future> prepareSend({ + _i23.Future> prepareSend({ required String? address, - required _i14.Amount? amount, + required _i15.Amount? amount, Map? args, }) => (super.noSuchMethod( @@ -1125,26 +1152,26 @@ class MockBitcoinWallet extends _i1.Mock implements _i28.BitcoinWallet { }, ), returnValue: - _i22.Future>.value({}), - ) as _i22.Future>); + _i23.Future>.value({}), + ) as _i23.Future>); @override - _i22.Future confirmSend({required Map? txData}) => + _i23.Future confirmSend({required Map? txData}) => (super.noSuchMethod( Invocation.method( #confirmSend, [], {#txData: txData}, ), - returnValue: _i22.Future.value(''), - ) as _i22.Future); + returnValue: _i23.Future.value(''), + ) as _i23.Future); @override - _i22.Future testNetworkConnection() => (super.noSuchMethod( + _i23.Future testNetworkConnection() => (super.noSuchMethod( Invocation.method( #testNetworkConnection, [], ), - returnValue: _i22.Future.value(false), - ) as _i22.Future); + returnValue: _i23.Future.value(false), + ) as _i23.Future); @override void startNetworkAlivePinging() => super.noSuchMethod( Invocation.method( @@ -1162,33 +1189,35 @@ class MockBitcoinWallet extends _i1.Mock implements _i28.BitcoinWallet { returnValueForMissingStub: null, ); @override - _i22.Future initializeNew() => (super.noSuchMethod( + _i23.Future initializeNew( + ({String mnemonicPassphrase, int wordCount})? data) => + (super.noSuchMethod( Invocation.method( #initializeNew, - [], + [data], ), - returnValue: _i22.Future.value(), - returnValueForMissingStub: _i22.Future.value(), - ) as _i22.Future); + returnValue: _i23.Future.value(), + returnValueForMissingStub: _i23.Future.value(), + ) as _i23.Future); @override - _i22.Future initializeExisting() => (super.noSuchMethod( + _i23.Future initializeExisting() => (super.noSuchMethod( Invocation.method( #initializeExisting, [], ), - returnValue: _i22.Future.value(), - returnValueForMissingStub: _i22.Future.value(), - ) as _i22.Future); + returnValue: _i23.Future.value(), + returnValueForMissingStub: _i23.Future.value(), + ) as _i23.Future); @override - _i22.Future updateSentCachedTxData(Map? txData) => + _i23.Future updateSentCachedTxData(Map? txData) => (super.noSuchMethod( Invocation.method( #updateSentCachedTxData, [txData], ), - returnValue: _i22.Future.value(), - returnValueForMissingStub: _i22.Future.value(), - ) as _i22.Future); + returnValue: _i23.Future.value(), + returnValueForMissingStub: _i23.Future.value(), + ) as _i23.Future); @override bool validateAddress(String? address) => (super.noSuchMethod( Invocation.method( @@ -1198,70 +1227,70 @@ class MockBitcoinWallet extends _i1.Mock implements _i28.BitcoinWallet { returnValue: false, ) as bool); @override - _i22.Future updateNode(bool? shouldRefresh) => (super.noSuchMethod( + _i23.Future updateNode(bool? shouldRefresh) => (super.noSuchMethod( Invocation.method( #updateNode, [shouldRefresh], ), - returnValue: _i22.Future.value(), - returnValueForMissingStub: _i22.Future.value(), - ) as _i22.Future); + returnValue: _i23.Future.value(), + returnValueForMissingStub: _i23.Future.value(), + ) as _i23.Future); @override - _i22.Future<_i10.ElectrumXNode> getCurrentNode() => (super.noSuchMethod( + _i23.Future<_i11.ElectrumXNode> getCurrentNode() => (super.noSuchMethod( Invocation.method( #getCurrentNode, [], ), returnValue: - _i22.Future<_i10.ElectrumXNode>.value(_FakeElectrumXNode_11( + _i23.Future<_i11.ElectrumXNode>.value(_FakeElectrumXNode_12( this, Invocation.method( #getCurrentNode, [], ), )), - ) as _i22.Future<_i10.ElectrumXNode>); + ) as _i23.Future<_i11.ElectrumXNode>); @override - _i22.Future>> fastFetch( + _i23.Future>> fastFetch( List? allTxHashes) => (super.noSuchMethod( Invocation.method( #fastFetch, [allTxHashes], ), - returnValue: _i22.Future>>.value( + returnValue: _i23.Future>>.value( >[]), - ) as _i22.Future>>); + ) as _i23.Future>>); @override - _i22.Future getTxCount({required String? address}) => + _i23.Future getTxCount({required String? address}) => (super.noSuchMethod( Invocation.method( #getTxCount, [], {#address: address}, ), - returnValue: _i22.Future.value(0), - ) as _i22.Future); + returnValue: _i23.Future.value(0), + ) as _i23.Future); @override - _i22.Future checkCurrentReceivingAddressesForTransactions() => + _i23.Future checkCurrentReceivingAddressesForTransactions() => (super.noSuchMethod( Invocation.method( #checkCurrentReceivingAddressesForTransactions, [], ), - returnValue: _i22.Future.value(), - returnValueForMissingStub: _i22.Future.value(), - ) as _i22.Future); + returnValue: _i23.Future.value(), + returnValueForMissingStub: _i23.Future.value(), + ) as _i23.Future); @override - _i22.Future checkCurrentChangeAddressesForTransactions() => + _i23.Future checkCurrentChangeAddressesForTransactions() => (super.noSuchMethod( Invocation.method( #checkCurrentChangeAddressesForTransactions, [], ), - returnValue: _i22.Future.value(), - returnValueForMissingStub: _i22.Future.value(), - ) as _i22.Future); + returnValue: _i23.Future.value(), + returnValueForMissingStub: _i23.Future.value(), + ) as _i23.Future); @override int estimateTxFee({ required int? vSize, @@ -1287,7 +1316,7 @@ class MockBitcoinWallet extends _i1.Mock implements _i28.BitcoinWallet { required bool? isSendAll, int? satsPerVByte, int? additionalOutputs = 0, - List<_i17.UTXO>? utxos, + List<_i18.UTXO>? utxos, }) => super.noSuchMethod(Invocation.method( #coinSelection, @@ -1304,19 +1333,19 @@ class MockBitcoinWallet extends _i1.Mock implements _i28.BitcoinWallet { }, )); @override - _i22.Future> fetchBuildTxData( - List<_i17.UTXO>? utxosToUse) => + _i23.Future> fetchBuildTxData( + List<_i18.UTXO>? utxosToUse) => (super.noSuchMethod( Invocation.method( #fetchBuildTxData, [utxosToUse], ), returnValue: - _i22.Future>.value(<_i30.SigningData>[]), - ) as _i22.Future>); + _i23.Future>.value(<_i31.SigningData>[]), + ) as _i23.Future>); @override - _i22.Future> buildTransaction({ - required List<_i30.SigningData>? utxoSigningData, + _i23.Future> buildTransaction({ + required List<_i31.SigningData>? utxoSigningData, required List? recipients, required List? satoshiAmounts, }) => @@ -1331,10 +1360,10 @@ class MockBitcoinWallet extends _i1.Mock implements _i28.BitcoinWallet { }, ), returnValue: - _i22.Future>.value({}), - ) as _i22.Future>); + _i23.Future>.value({}), + ) as _i23.Future>); @override - _i22.Future fullRescan( + _i23.Future fullRescan( int? maxUnusedAddressGap, int? maxNumberOfIndexesToCheck, ) => @@ -1346,12 +1375,12 @@ class MockBitcoinWallet extends _i1.Mock implements _i28.BitcoinWallet { maxNumberOfIndexesToCheck, ], ), - returnValue: _i22.Future.value(), - returnValueForMissingStub: _i22.Future.value(), - ) as _i22.Future); + returnValue: _i23.Future.value(), + returnValueForMissingStub: _i23.Future.value(), + ) as _i23.Future); @override - _i22.Future<_i14.Amount> estimateFeeFor( - _i14.Amount? amount, + _i23.Future<_i15.Amount> estimateFeeFor( + _i15.Amount? amount, int? feeRate, ) => (super.noSuchMethod( @@ -1362,7 +1391,7 @@ class MockBitcoinWallet extends _i1.Mock implements _i28.BitcoinWallet { feeRate, ], ), - returnValue: _i22.Future<_i14.Amount>.value(_FakeAmount_12( + returnValue: _i23.Future<_i15.Amount>.value(_FakeAmount_13( this, Invocation.method( #estimateFeeFor, @@ -1372,9 +1401,9 @@ class MockBitcoinWallet extends _i1.Mock implements _i28.BitcoinWallet { ], ), )), - ) as _i22.Future<_i14.Amount>); + ) as _i23.Future<_i15.Amount>); @override - _i14.Amount roughFeeEstimate( + _i15.Amount roughFeeEstimate( int? inputCount, int? outputCount, int? feeRatePerKB, @@ -1388,7 +1417,7 @@ class MockBitcoinWallet extends _i1.Mock implements _i28.BitcoinWallet { feeRatePerKB, ], ), - returnValue: _FakeAmount_12( + returnValue: _FakeAmount_13( this, Invocation.method( #roughFeeEstimate, @@ -1399,34 +1428,34 @@ class MockBitcoinWallet extends _i1.Mock implements _i28.BitcoinWallet { ], ), ), - ) as _i14.Amount); + ) as _i15.Amount); @override - _i22.Future<_i14.Amount> sweepAllEstimate(int? feeRate) => + _i23.Future<_i15.Amount> sweepAllEstimate(int? feeRate) => (super.noSuchMethod( Invocation.method( #sweepAllEstimate, [feeRate], ), - returnValue: _i22.Future<_i14.Amount>.value(_FakeAmount_12( + returnValue: _i23.Future<_i15.Amount>.value(_FakeAmount_13( this, Invocation.method( #sweepAllEstimate, [feeRate], ), )), - ) as _i22.Future<_i14.Amount>); + ) as _i23.Future<_i15.Amount>); @override - _i22.Future generateNewAddress() => (super.noSuchMethod( + _i23.Future generateNewAddress() => (super.noSuchMethod( Invocation.method( #generateNewAddress, [], ), - returnValue: _i22.Future.value(false), - ) as _i22.Future); + returnValue: _i23.Future.value(false), + ) as _i23.Future); @override void initCache( String? walletId, - _i21.Coin? coin, + _i22.Coin? coin, ) => super.noSuchMethod( Invocation.method( @@ -1439,14 +1468,14 @@ class MockBitcoinWallet extends _i1.Mock implements _i28.BitcoinWallet { returnValueForMissingStub: null, ); @override - _i22.Future updateCachedId(String? id) => (super.noSuchMethod( + _i23.Future updateCachedId(String? id) => (super.noSuchMethod( Invocation.method( #updateCachedId, [id], ), - returnValue: _i22.Future.value(), - returnValueForMissingStub: _i22.Future.value(), - ) as _i22.Future); + returnValue: _i23.Future.value(), + returnValueForMissingStub: _i23.Future.value(), + ) as _i23.Future); @override int getCachedChainHeight() => (super.noSuchMethod( Invocation.method( @@ -1456,14 +1485,14 @@ class MockBitcoinWallet extends _i1.Mock implements _i28.BitcoinWallet { returnValue: 0, ) as int); @override - _i22.Future updateCachedChainHeight(int? height) => (super.noSuchMethod( + _i23.Future updateCachedChainHeight(int? height) => (super.noSuchMethod( Invocation.method( #updateCachedChainHeight, [height], ), - returnValue: _i22.Future.value(), - returnValueForMissingStub: _i22.Future.value(), - ) as _i22.Future); + returnValue: _i23.Future.value(), + returnValueForMissingStub: _i23.Future.value(), + ) as _i23.Future); @override bool getCachedIsFavorite() => (super.noSuchMethod( Invocation.method( @@ -1473,63 +1502,63 @@ class MockBitcoinWallet extends _i1.Mock implements _i28.BitcoinWallet { returnValue: false, ) as bool); @override - _i22.Future updateCachedIsFavorite(bool? isFavorite) => + _i23.Future updateCachedIsFavorite(bool? isFavorite) => (super.noSuchMethod( Invocation.method( #updateCachedIsFavorite, [isFavorite], ), - returnValue: _i22.Future.value(), - returnValueForMissingStub: _i22.Future.value(), - ) as _i22.Future); + returnValue: _i23.Future.value(), + returnValueForMissingStub: _i23.Future.value(), + ) as _i23.Future); @override - _i12.Balance getCachedBalance() => (super.noSuchMethod( + _i13.Balance getCachedBalance() => (super.noSuchMethod( Invocation.method( #getCachedBalance, [], ), - returnValue: _FakeBalance_9( + returnValue: _FakeBalance_10( this, Invocation.method( #getCachedBalance, [], ), ), - ) as _i12.Balance); + ) as _i13.Balance); @override - _i22.Future updateCachedBalance(_i12.Balance? balance) => + _i23.Future updateCachedBalance(_i13.Balance? balance) => (super.noSuchMethod( Invocation.method( #updateCachedBalance, [balance], ), - returnValue: _i22.Future.value(), - returnValueForMissingStub: _i22.Future.value(), - ) as _i22.Future); + returnValue: _i23.Future.value(), + returnValueForMissingStub: _i23.Future.value(), + ) as _i23.Future); @override - _i12.Balance getCachedBalanceSecondary() => (super.noSuchMethod( + _i13.Balance getCachedBalanceSecondary() => (super.noSuchMethod( Invocation.method( #getCachedBalanceSecondary, [], ), - returnValue: _FakeBalance_9( + returnValue: _FakeBalance_10( this, Invocation.method( #getCachedBalanceSecondary, [], ), ), - ) as _i12.Balance); + ) as _i13.Balance); @override - _i22.Future updateCachedBalanceSecondary(_i12.Balance? balance) => + _i23.Future updateCachedBalanceSecondary(_i13.Balance? balance) => (super.noSuchMethod( Invocation.method( #updateCachedBalanceSecondary, [balance], ), - returnValue: _i22.Future.value(), - returnValueForMissingStub: _i22.Future.value(), - ) as _i22.Future); + returnValue: _i23.Future.value(), + returnValueForMissingStub: _i23.Future.value(), + ) as _i23.Future); @override List getWalletTokenContractAddresses() => (super.noSuchMethod( Invocation.method( @@ -1539,18 +1568,18 @@ class MockBitcoinWallet extends _i1.Mock implements _i28.BitcoinWallet { returnValue: [], ) as List); @override - _i22.Future updateWalletTokenContractAddresses( + _i23.Future updateWalletTokenContractAddresses( List? contractAddresses) => (super.noSuchMethod( Invocation.method( #updateWalletTokenContractAddresses, [contractAddresses], ), - returnValue: _i22.Future.value(), - returnValueForMissingStub: _i22.Future.value(), - ) as _i22.Future); + returnValue: _i23.Future.value(), + returnValueForMissingStub: _i23.Future.value(), + ) as _i23.Future); @override - void initWalletDB({_i7.MainDB? mockableOverride}) => super.noSuchMethod( + void initWalletDB({_i8.MainDB? mockableOverride}) => super.noSuchMethod( Invocation.method( #initWalletDB, [], @@ -1559,11 +1588,11 @@ class MockBitcoinWallet extends _i1.Mock implements _i28.BitcoinWallet { returnValueForMissingStub: null, ); @override - _i22.Future<_i15.Tuple2<_i17.Transaction, _i17.Address>> parseTransaction( + _i23.Future<_i16.Tuple2<_i18.Transaction, _i18.Address>> parseTransaction( Map? txData, dynamic electrumxClient, - List<_i17.Address>? myAddresses, - _i21.Coin? coin, + List<_i18.Address>? myAddresses, + _i22.Coin? coin, int? minConfirms, String? walletId, ) => @@ -1580,8 +1609,8 @@ class MockBitcoinWallet extends _i1.Mock implements _i28.BitcoinWallet { ], ), returnValue: - _i22.Future<_i15.Tuple2<_i17.Transaction, _i17.Address>>.value( - _FakeTuple2_13<_i17.Transaction, _i17.Address>( + _i23.Future<_i16.Tuple2<_i18.Transaction, _i18.Address>>.value( + _FakeTuple2_14<_i18.Transaction, _i18.Address>( this, Invocation.method( #parseTransaction, @@ -1595,37 +1624,37 @@ class MockBitcoinWallet extends _i1.Mock implements _i28.BitcoinWallet { ], ), )), - ) as _i22.Future<_i15.Tuple2<_i17.Transaction, _i17.Address>>); + ) as _i23.Future<_i16.Tuple2<_i18.Transaction, _i18.Address>>); @override void initPaynymWalletInterface({ required String? walletId, required String? walletName, - required _i13.NetworkType? network, - required _i21.Coin? coin, - required _i7.MainDB? db, - required _i10.ElectrumX? electrumXClient, - required _i31.SecureStorageInterface? secureStorage, + required _i14.NetworkType? network, + required _i22.Coin? coin, + required _i8.MainDB? db, + required _i11.ElectrumX? electrumXClient, + required _i32.SecureStorageInterface? secureStorage, required int? dustLimit, required int? dustLimitP2PKH, required int? minConfirms, - required _i22.Future Function()? getMnemonicString, - required _i22.Future Function()? getMnemonicPassphrase, - required _i22.Future Function()? getChainHeight, - required _i22.Future Function()? getCurrentChangeAddress, + required _i23.Future Function()? getMnemonicString, + required _i23.Future Function()? getMnemonicPassphrase, + required _i23.Future Function()? getChainHeight, + required _i23.Future Function()? getCurrentChangeAddress, required int Function({ required int feeRatePerKB, required int vSize, })? estimateTxFee, - required _i22.Future> Function({ + required _i23.Future> Function({ required String address, - required _i14.Amount amount, + required _i15.Amount amount, Map? args, })? prepareSend, - required _i22.Future Function({required String address})? getTxCount, - required _i22.Future> Function(List<_i17.UTXO>)? + required _i23.Future Function({required String address})? getTxCount, + required _i23.Future> Function(List<_i18.UTXO>)? fetchBuildTxData, - required _i22.Future Function()? refresh, - required _i22.Future Function()? checkChangeAddressForTransactions, + required _i23.Future Function()? refresh, + required _i23.Future Function()? checkChangeAddressForTransactions, }) => super.noSuchMethod( Invocation.method( @@ -1658,21 +1687,21 @@ class MockBitcoinWallet extends _i1.Mock implements _i28.BitcoinWallet { returnValueForMissingStub: null, ); @override - _i22.Future<_i16.BIP32> getBip47BaseNode() => (super.noSuchMethod( + _i23.Future<_i17.BIP32> getBip47BaseNode() => (super.noSuchMethod( Invocation.method( #getBip47BaseNode, [], ), - returnValue: _i22.Future<_i16.BIP32>.value(_FakeBIP32_14( + returnValue: _i23.Future<_i17.BIP32>.value(_FakeBIP32_15( this, Invocation.method( #getBip47BaseNode, [], ), )), - ) as _i22.Future<_i16.BIP32>); + ) as _i23.Future<_i17.BIP32>); @override - _i22.Future<_i27.Uint8List> getPrivateKeyForPaynymReceivingAddress({ + _i23.Future<_i28.Uint8List> getPrivateKeyForPaynymReceivingAddress({ required String? paymentCodeString, required int? index, }) => @@ -1685,11 +1714,11 @@ class MockBitcoinWallet extends _i1.Mock implements _i28.BitcoinWallet { #index: index, }, ), - returnValue: _i22.Future<_i27.Uint8List>.value(_i27.Uint8List(0)), - ) as _i22.Future<_i27.Uint8List>); + returnValue: _i23.Future<_i28.Uint8List>.value(_i28.Uint8List(0)), + ) as _i23.Future<_i28.Uint8List>); @override - _i22.Future<_i17.Address> currentReceivingPaynymAddress({ - required _i18.PaymentCode? sender, + _i23.Future<_i18.Address> currentReceivingPaynymAddress({ + required _i19.PaymentCode? sender, required bool? isSegwit, }) => (super.noSuchMethod( @@ -1701,7 +1730,7 @@ class MockBitcoinWallet extends _i1.Mock implements _i28.BitcoinWallet { #isSegwit: isSegwit, }, ), - returnValue: _i22.Future<_i17.Address>.value(_FakeAddress_15( + returnValue: _i23.Future<_i18.Address>.value(_FakeAddress_16( this, Invocation.method( #currentReceivingPaynymAddress, @@ -1712,10 +1741,10 @@ class MockBitcoinWallet extends _i1.Mock implements _i28.BitcoinWallet { }, ), )), - ) as _i22.Future<_i17.Address>); + ) as _i23.Future<_i18.Address>); @override - _i22.Future checkCurrentPaynymReceivingAddressForTransactions({ - required _i18.PaymentCode? sender, + _i23.Future checkCurrentPaynymReceivingAddressForTransactions({ + required _i19.PaymentCode? sender, required bool? isSegwit, }) => (super.noSuchMethod( @@ -1727,42 +1756,42 @@ class MockBitcoinWallet extends _i1.Mock implements _i28.BitcoinWallet { #isSegwit: isSegwit, }, ), - returnValue: _i22.Future.value(), - returnValueForMissingStub: _i22.Future.value(), - ) as _i22.Future); + returnValue: _i23.Future.value(), + returnValueForMissingStub: _i23.Future.value(), + ) as _i23.Future); @override - _i22.Future checkAllCurrentReceivingPaynymAddressesForTransactions() => + _i23.Future checkAllCurrentReceivingPaynymAddressesForTransactions() => (super.noSuchMethod( Invocation.method( #checkAllCurrentReceivingPaynymAddressesForTransactions, [], ), - returnValue: _i22.Future.value(), - returnValueForMissingStub: _i22.Future.value(), - ) as _i22.Future); + returnValue: _i23.Future.value(), + returnValueForMissingStub: _i23.Future.value(), + ) as _i23.Future); @override - _i22.Future<_i16.BIP32> deriveNotificationBip32Node() => (super.noSuchMethod( + _i23.Future<_i17.BIP32> deriveNotificationBip32Node() => (super.noSuchMethod( Invocation.method( #deriveNotificationBip32Node, [], ), - returnValue: _i22.Future<_i16.BIP32>.value(_FakeBIP32_14( + returnValue: _i23.Future<_i17.BIP32>.value(_FakeBIP32_15( this, Invocation.method( #deriveNotificationBip32Node, [], ), )), - ) as _i22.Future<_i16.BIP32>); + ) as _i23.Future<_i17.BIP32>); @override - _i22.Future<_i18.PaymentCode> getPaymentCode({required bool? isSegwit}) => + _i23.Future<_i19.PaymentCode> getPaymentCode({required bool? isSegwit}) => (super.noSuchMethod( Invocation.method( #getPaymentCode, [], {#isSegwit: isSegwit}, ), - returnValue: _i22.Future<_i18.PaymentCode>.value(_FakePaymentCode_16( + returnValue: _i23.Future<_i19.PaymentCode>.value(_FakePaymentCode_17( this, Invocation.method( #getPaymentCode, @@ -1770,30 +1799,30 @@ class MockBitcoinWallet extends _i1.Mock implements _i28.BitcoinWallet { {#isSegwit: isSegwit}, ), )), - ) as _i22.Future<_i18.PaymentCode>); + ) as _i23.Future<_i19.PaymentCode>); @override - _i22.Future<_i27.Uint8List> signWithNotificationKey(_i27.Uint8List? data) => + _i23.Future<_i28.Uint8List> signWithNotificationKey(_i28.Uint8List? data) => (super.noSuchMethod( Invocation.method( #signWithNotificationKey, [data], ), - returnValue: _i22.Future<_i27.Uint8List>.value(_i27.Uint8List(0)), - ) as _i22.Future<_i27.Uint8List>); + returnValue: _i23.Future<_i28.Uint8List>.value(_i28.Uint8List(0)), + ) as _i23.Future<_i28.Uint8List>); @override - _i22.Future signStringWithNotificationKey(String? data) => + _i23.Future signStringWithNotificationKey(String? data) => (super.noSuchMethod( Invocation.method( #signStringWithNotificationKey, [data], ), - returnValue: _i22.Future.value(''), - ) as _i22.Future); + returnValue: _i23.Future.value(''), + ) as _i23.Future); @override - _i22.Future> preparePaymentCodeSend({ - required _i18.PaymentCode? paymentCode, + _i23.Future> preparePaymentCodeSend({ + required _i19.PaymentCode? paymentCode, required bool? isSegwit, - required _i14.Amount? amount, + required _i15.Amount? amount, Map? args, }) => (super.noSuchMethod( @@ -1808,13 +1837,13 @@ class MockBitcoinWallet extends _i1.Mock implements _i28.BitcoinWallet { }, ), returnValue: - _i22.Future>.value({}), - ) as _i22.Future>); + _i23.Future>.value({}), + ) as _i23.Future>); @override - _i22.Future<_i17.Address> nextUnusedSendAddressFrom({ - required _i18.PaymentCode? pCode, + _i23.Future<_i18.Address> nextUnusedSendAddressFrom({ + required _i19.PaymentCode? pCode, required bool? isSegwit, - required _i16.BIP32? privateKeyNode, + required _i17.BIP32? privateKeyNode, int? startIndex = 0, }) => (super.noSuchMethod( @@ -1828,7 +1857,7 @@ class MockBitcoinWallet extends _i1.Mock implements _i28.BitcoinWallet { #startIndex: startIndex, }, ), - returnValue: _i22.Future<_i17.Address>.value(_FakeAddress_15( + returnValue: _i23.Future<_i18.Address>.value(_FakeAddress_16( this, Invocation.method( #nextUnusedSendAddressFrom, @@ -1841,13 +1870,13 @@ class MockBitcoinWallet extends _i1.Mock implements _i28.BitcoinWallet { }, ), )), - ) as _i22.Future<_i17.Address>); + ) as _i23.Future<_i18.Address>); @override - _i22.Future> prepareNotificationTx({ + _i23.Future> prepareNotificationTx({ required int? selectedTxFeeRate, required String? targetPaymentCodeString, int? additionalOutputs = 0, - List<_i17.UTXO>? utxos, + List<_i18.UTXO>? utxos, }) => (super.noSuchMethod( Invocation.method( @@ -1861,10 +1890,10 @@ class MockBitcoinWallet extends _i1.Mock implements _i28.BitcoinWallet { }, ), returnValue: - _i22.Future>.value({}), - ) as _i22.Future>); + _i23.Future>.value({}), + ) as _i23.Future>); @override - _i22.Future broadcastNotificationTx( + _i23.Future broadcastNotificationTx( {required Map? preparedTx}) => (super.noSuchMethod( Invocation.method( @@ -1872,62 +1901,62 @@ class MockBitcoinWallet extends _i1.Mock implements _i28.BitcoinWallet { [], {#preparedTx: preparedTx}, ), - returnValue: _i22.Future.value(''), - ) as _i22.Future); + returnValue: _i23.Future.value(''), + ) as _i23.Future); @override - _i22.Future hasConnected(String? paymentCodeString) => + _i23.Future hasConnected(String? paymentCodeString) => (super.noSuchMethod( Invocation.method( #hasConnected, [paymentCodeString], ), - returnValue: _i22.Future.value(false), - ) as _i22.Future); + returnValue: _i23.Future.value(false), + ) as _i23.Future); @override - _i22.Future<_i18.PaymentCode?> unBlindedPaymentCodeFromTransaction( - {required _i17.Transaction? transaction}) => + _i23.Future<_i19.PaymentCode?> unBlindedPaymentCodeFromTransaction( + {required _i18.Transaction? transaction}) => (super.noSuchMethod( Invocation.method( #unBlindedPaymentCodeFromTransaction, [], {#transaction: transaction}, ), - returnValue: _i22.Future<_i18.PaymentCode?>.value(), - ) as _i22.Future<_i18.PaymentCode?>); + returnValue: _i23.Future<_i19.PaymentCode?>.value(), + ) as _i23.Future<_i19.PaymentCode?>); @override - _i22.Future<_i18.PaymentCode?> unBlindedPaymentCodeFromTransactionBad( - {required _i17.Transaction? transaction}) => + _i23.Future<_i19.PaymentCode?> unBlindedPaymentCodeFromTransactionBad( + {required _i18.Transaction? transaction}) => (super.noSuchMethod( Invocation.method( #unBlindedPaymentCodeFromTransactionBad, [], {#transaction: transaction}, ), - returnValue: _i22.Future<_i18.PaymentCode?>.value(), - ) as _i22.Future<_i18.PaymentCode?>); + returnValue: _i23.Future<_i19.PaymentCode?>.value(), + ) as _i23.Future<_i19.PaymentCode?>); @override - _i22.Future> + _i23.Future> getAllPaymentCodesFromNotificationTransactions() => (super.noSuchMethod( Invocation.method( #getAllPaymentCodesFromNotificationTransactions, [], ), returnValue: - _i22.Future>.value(<_i18.PaymentCode>[]), - ) as _i22.Future>); + _i23.Future>.value(<_i19.PaymentCode>[]), + ) as _i23.Future>); @override - _i22.Future checkForNotificationTransactionsTo( + _i23.Future checkForNotificationTransactionsTo( Set? otherCodeStrings) => (super.noSuchMethod( Invocation.method( #checkForNotificationTransactionsTo, [otherCodeStrings], ), - returnValue: _i22.Future.value(), - returnValueForMissingStub: _i22.Future.value(), - ) as _i22.Future); + returnValue: _i23.Future.value(), + returnValueForMissingStub: _i23.Future.value(), + ) as _i23.Future); @override - _i22.Future restoreAllHistory({ + _i23.Future restoreAllHistory({ required int? maxUnusedAddressGap, required int? maxNumberOfIndexesToCheck, required Set? paymentCodeStrings, @@ -1942,12 +1971,12 @@ class MockBitcoinWallet extends _i1.Mock implements _i28.BitcoinWallet { #paymentCodeStrings: paymentCodeStrings, }, ), - returnValue: _i22.Future.value(), - returnValueForMissingStub: _i22.Future.value(), - ) as _i22.Future); + returnValue: _i23.Future.value(), + returnValueForMissingStub: _i23.Future.value(), + ) as _i23.Future); @override - _i22.Future restoreHistoryWith({ - required _i18.PaymentCode? other, + _i23.Future restoreHistoryWith({ + required _i19.PaymentCode? other, required bool? checkSegwitAsWell, required int? maxUnusedAddressGap, required int? maxNumberOfIndexesToCheck, @@ -1963,58 +1992,58 @@ class MockBitcoinWallet extends _i1.Mock implements _i28.BitcoinWallet { #maxNumberOfIndexesToCheck: maxNumberOfIndexesToCheck, }, ), - returnValue: _i22.Future.value(), - returnValueForMissingStub: _i22.Future.value(), - ) as _i22.Future); + returnValue: _i23.Future.value(), + returnValueForMissingStub: _i23.Future.value(), + ) as _i23.Future); @override - _i22.Future<_i17.Address> getMyNotificationAddress() => (super.noSuchMethod( + _i23.Future<_i18.Address> getMyNotificationAddress() => (super.noSuchMethod( Invocation.method( #getMyNotificationAddress, [], ), - returnValue: _i22.Future<_i17.Address>.value(_FakeAddress_15( + returnValue: _i23.Future<_i18.Address>.value(_FakeAddress_16( this, Invocation.method( #getMyNotificationAddress, [], ), )), - ) as _i22.Future<_i17.Address>); + ) as _i23.Future<_i18.Address>); @override - _i22.Future> lookupKey(String? paymentCodeString) => + _i23.Future> lookupKey(String? paymentCodeString) => (super.noSuchMethod( Invocation.method( #lookupKey, [paymentCodeString], ), - returnValue: _i22.Future>.value([]), - ) as _i22.Future>); + returnValue: _i23.Future>.value([]), + ) as _i23.Future>); @override - _i22.Future paymentCodeStringByKey(String? key) => + _i23.Future paymentCodeStringByKey(String? key) => (super.noSuchMethod( Invocation.method( #paymentCodeStringByKey, [key], ), - returnValue: _i22.Future.value(), - ) as _i22.Future); + returnValue: _i23.Future.value(), + ) as _i23.Future); @override - _i22.Future storeCode(String? paymentCodeString) => + _i23.Future storeCode(String? paymentCodeString) => (super.noSuchMethod( Invocation.method( #storeCode, [paymentCodeString], ), - returnValue: _i22.Future.value(''), - ) as _i22.Future); + returnValue: _i23.Future.value(''), + ) as _i23.Future); @override void initCoinControlInterface({ required String? walletId, required String? walletName, - required _i21.Coin? coin, - required _i7.MainDB? db, - required _i22.Future Function()? getChainHeight, - required _i22.Future Function(_i12.Balance)? refreshedBalanceCallback, + required _i22.Coin? coin, + required _i8.MainDB? db, + required _i23.Future Function()? getChainHeight, + required _i23.Future Function(_i13.Balance)? refreshedBalanceCallback, }) => super.noSuchMethod( Invocation.method( @@ -2032,16 +2061,16 @@ class MockBitcoinWallet extends _i1.Mock implements _i28.BitcoinWallet { returnValueForMissingStub: null, ); @override - _i22.Future refreshBalance({bool? notify = false}) => + _i23.Future refreshBalance({bool? notify = false}) => (super.noSuchMethod( Invocation.method( #refreshBalance, [], {#notify: notify}, ), - returnValue: _i22.Future.value(), - returnValueForMissingStub: _i22.Future.value(), - ) as _i22.Future); + returnValue: _i23.Future.value(), + returnValueForMissingStub: _i23.Future.value(), + ) as _i23.Future); } /// A class which mocks [Manager]. @@ -2062,23 +2091,23 @@ class MockManager extends _i1.Mock implements _i6.Manager { returnValueForMissingStub: null, ); @override - _i19.CoinServiceAPI get wallet => (super.noSuchMethod( + _i20.CoinServiceAPI get wallet => (super.noSuchMethod( Invocation.getter(#wallet), - returnValue: _FakeCoinServiceAPI_17( + returnValue: _FakeCoinServiceAPI_18( this, Invocation.getter(#wallet), ), - ) as _i19.CoinServiceAPI); + ) as _i20.CoinServiceAPI); @override bool get hasBackgroundRefreshListener => (super.noSuchMethod( Invocation.getter(#hasBackgroundRefreshListener), returnValue: false, ) as bool); @override - _i21.Coin get coin => (super.noSuchMethod( + _i22.Coin get coin => (super.noSuchMethod( Invocation.getter(#coin), - returnValue: _i21.Coin.bitcoin, - ) as _i21.Coin); + returnValue: _i22.Coin.bitcoin, + ) as _i22.Coin); @override bool get isRefreshing => (super.noSuchMethod( Invocation.getter(#isRefreshing), @@ -2111,42 +2140,42 @@ class MockManager extends _i1.Mock implements _i6.Manager { returnValueForMissingStub: null, ); @override - _i22.Future<_i9.FeeObject> get fees => (super.noSuchMethod( + _i23.Future<_i10.FeeObject> get fees => (super.noSuchMethod( Invocation.getter(#fees), - returnValue: _i22.Future<_i9.FeeObject>.value(_FakeFeeObject_6( + returnValue: _i23.Future<_i10.FeeObject>.value(_FakeFeeObject_7( this, Invocation.getter(#fees), )), - ) as _i22.Future<_i9.FeeObject>); + ) as _i23.Future<_i10.FeeObject>); @override - _i22.Future get maxFee => (super.noSuchMethod( + _i23.Future get maxFee => (super.noSuchMethod( Invocation.getter(#maxFee), - returnValue: _i22.Future.value(0), - ) as _i22.Future); + returnValue: _i23.Future.value(0), + ) as _i23.Future); @override - _i22.Future get currentReceivingAddress => (super.noSuchMethod( + _i23.Future get currentReceivingAddress => (super.noSuchMethod( Invocation.getter(#currentReceivingAddress), - returnValue: _i22.Future.value(''), - ) as _i22.Future); + returnValue: _i23.Future.value(''), + ) as _i23.Future); @override - _i12.Balance get balance => (super.noSuchMethod( + _i13.Balance get balance => (super.noSuchMethod( Invocation.getter(#balance), - returnValue: _FakeBalance_9( + returnValue: _FakeBalance_10( this, Invocation.getter(#balance), ), - ) as _i12.Balance); + ) as _i13.Balance); @override - _i22.Future> get transactions => (super.noSuchMethod( + _i23.Future> get transactions => (super.noSuchMethod( Invocation.getter(#transactions), returnValue: - _i22.Future>.value(<_i17.Transaction>[]), - ) as _i22.Future>); + _i23.Future>.value(<_i18.Transaction>[]), + ) as _i23.Future>); @override - _i22.Future> get utxos => (super.noSuchMethod( + _i23.Future> get utxos => (super.noSuchMethod( Invocation.getter(#utxos), - returnValue: _i22.Future>.value(<_i17.UTXO>[]), - ) as _i22.Future>); + returnValue: _i23.Future>.value(<_i18.UTXO>[]), + ) as _i23.Future>); @override set walletName(String? newName) => super.noSuchMethod( Invocation.setter( @@ -2166,15 +2195,15 @@ class MockManager extends _i1.Mock implements _i6.Manager { returnValue: '', ) as String); @override - _i22.Future> get mnemonic => (super.noSuchMethod( + _i23.Future> get mnemonic => (super.noSuchMethod( Invocation.getter(#mnemonic), - returnValue: _i22.Future>.value([]), - ) as _i22.Future>); + returnValue: _i23.Future>.value([]), + ) as _i23.Future>); @override - _i22.Future get mnemonicPassphrase => (super.noSuchMethod( + _i23.Future get mnemonicPassphrase => (super.noSuchMethod( Invocation.getter(#mnemonicPassphrase), - returnValue: _i22.Future.value(), - ) as _i22.Future); + returnValue: _i23.Future.value(), + ) as _i23.Future); @override bool get isConnected => (super.noSuchMethod( Invocation.getter(#isConnected), @@ -2221,24 +2250,24 @@ class MockManager extends _i1.Mock implements _i6.Manager { returnValue: false, ) as bool); @override - _i22.Future get xpub => (super.noSuchMethod( + _i23.Future get xpub => (super.noSuchMethod( Invocation.getter(#xpub), - returnValue: _i22.Future.value(''), - ) as _i22.Future); + returnValue: _i23.Future.value(''), + ) as _i23.Future); @override bool get hasListeners => (super.noSuchMethod( Invocation.getter(#hasListeners), returnValue: false, ) as bool); @override - _i22.Future updateNode(bool? shouldRefresh) => (super.noSuchMethod( + _i23.Future updateNode(bool? shouldRefresh) => (super.noSuchMethod( Invocation.method( #updateNode, [shouldRefresh], ), - returnValue: _i22.Future.value(), - returnValueForMissingStub: _i22.Future.value(), - ) as _i22.Future); + returnValue: _i23.Future.value(), + returnValueForMissingStub: _i23.Future.value(), + ) as _i23.Future); @override void dispose() => super.noSuchMethod( Invocation.method( @@ -2248,9 +2277,9 @@ class MockManager extends _i1.Mock implements _i6.Manager { returnValueForMissingStub: null, ); @override - _i22.Future> prepareSend({ + _i23.Future> prepareSend({ required String? address, - required _i14.Amount? amount, + required _i15.Amount? amount, Map? args, }) => (super.noSuchMethod( @@ -2264,27 +2293,27 @@ class MockManager extends _i1.Mock implements _i6.Manager { }, ), returnValue: - _i22.Future>.value({}), - ) as _i22.Future>); + _i23.Future>.value({}), + ) as _i23.Future>); @override - _i22.Future confirmSend({required Map? txData}) => + _i23.Future confirmSend({required Map? txData}) => (super.noSuchMethod( Invocation.method( #confirmSend, [], {#txData: txData}, ), - returnValue: _i22.Future.value(''), - ) as _i22.Future); + returnValue: _i23.Future.value(''), + ) as _i23.Future); @override - _i22.Future refresh() => (super.noSuchMethod( + _i23.Future refresh() => (super.noSuchMethod( Invocation.method( #refresh, [], ), - returnValue: _i22.Future.value(), - returnValueForMissingStub: _i22.Future.value(), - ) as _i22.Future); + returnValue: _i23.Future.value(), + returnValueForMissingStub: _i23.Future.value(), + ) as _i23.Future); @override bool validateAddress(String? address) => (super.noSuchMethod( Invocation.method( @@ -2294,33 +2323,35 @@ class MockManager extends _i1.Mock implements _i6.Manager { returnValue: false, ) as bool); @override - _i22.Future testNetworkConnection() => (super.noSuchMethod( + _i23.Future testNetworkConnection() => (super.noSuchMethod( Invocation.method( #testNetworkConnection, [], ), - returnValue: _i22.Future.value(false), - ) as _i22.Future); + returnValue: _i23.Future.value(false), + ) as _i23.Future); @override - _i22.Future initializeNew() => (super.noSuchMethod( + _i23.Future initializeNew( + ({String mnemonicPassphrase, int wordCount})? data) => + (super.noSuchMethod( Invocation.method( #initializeNew, - [], + [data], ), - returnValue: _i22.Future.value(), - returnValueForMissingStub: _i22.Future.value(), - ) as _i22.Future); + returnValue: _i23.Future.value(), + returnValueForMissingStub: _i23.Future.value(), + ) as _i23.Future); @override - _i22.Future initializeExisting() => (super.noSuchMethod( + _i23.Future initializeExisting() => (super.noSuchMethod( Invocation.method( #initializeExisting, [], ), - returnValue: _i22.Future.value(), - returnValueForMissingStub: _i22.Future.value(), - ) as _i22.Future); + returnValue: _i23.Future.value(), + returnValueForMissingStub: _i23.Future.value(), + ) as _i23.Future); @override - _i22.Future recoverFromMnemonic({ + _i23.Future recoverFromMnemonic({ required String? mnemonic, String? mnemonicPassphrase, required int? maxUnusedAddressGap, @@ -2339,20 +2370,20 @@ class MockManager extends _i1.Mock implements _i6.Manager { #height: height, }, ), - returnValue: _i22.Future.value(), - returnValueForMissingStub: _i22.Future.value(), - ) as _i22.Future); + returnValue: _i23.Future.value(), + returnValueForMissingStub: _i23.Future.value(), + ) as _i23.Future); @override - _i22.Future exitCurrentWallet() => (super.noSuchMethod( + _i23.Future exitCurrentWallet() => (super.noSuchMethod( Invocation.method( #exitCurrentWallet, [], ), - returnValue: _i22.Future.value(), - returnValueForMissingStub: _i22.Future.value(), - ) as _i22.Future); + returnValue: _i23.Future.value(), + returnValueForMissingStub: _i23.Future.value(), + ) as _i23.Future); @override - _i22.Future fullRescan( + _i23.Future fullRescan( int? maxUnusedAddressGap, int? maxNumberOfIndexesToCheck, ) => @@ -2364,12 +2395,12 @@ class MockManager extends _i1.Mock implements _i6.Manager { maxNumberOfIndexesToCheck, ], ), - returnValue: _i22.Future.value(), - returnValueForMissingStub: _i22.Future.value(), - ) as _i22.Future); + returnValue: _i23.Future.value(), + returnValueForMissingStub: _i23.Future.value(), + ) as _i23.Future); @override - _i22.Future<_i14.Amount> estimateFeeFor( - _i14.Amount? amount, + _i23.Future<_i15.Amount> estimateFeeFor( + _i15.Amount? amount, int? feeRate, ) => (super.noSuchMethod( @@ -2380,7 +2411,7 @@ class MockManager extends _i1.Mock implements _i6.Manager { feeRate, ], ), - returnValue: _i22.Future<_i14.Amount>.value(_FakeAmount_12( + returnValue: _i23.Future<_i15.Amount>.value(_FakeAmount_13( this, Invocation.method( #estimateFeeFor, @@ -2390,26 +2421,26 @@ class MockManager extends _i1.Mock implements _i6.Manager { ], ), )), - ) as _i22.Future<_i14.Amount>); + ) as _i23.Future<_i15.Amount>); @override - _i22.Future generateNewAddress() => (super.noSuchMethod( + _i23.Future generateNewAddress() => (super.noSuchMethod( Invocation.method( #generateNewAddress, [], ), - returnValue: _i22.Future.value(false), - ) as _i22.Future); + returnValue: _i23.Future.value(false), + ) as _i23.Future); @override - _i22.Future resetRescanOnOpen() => (super.noSuchMethod( + _i23.Future resetRescanOnOpen() => (super.noSuchMethod( Invocation.method( #resetRescanOnOpen, [], ), - returnValue: _i22.Future.value(), - returnValueForMissingStub: _i22.Future.value(), - ) as _i22.Future); + returnValue: _i23.Future.value(), + returnValueForMissingStub: _i23.Future.value(), + ) as _i23.Future); @override - void addListener(_i24.VoidCallback? listener) => super.noSuchMethod( + void addListener(_i25.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #addListener, [listener], @@ -2417,7 +2448,7 @@ class MockManager extends _i1.Mock implements _i6.Manager { returnValueForMissingStub: null, ); @override - void removeListener(_i24.VoidCallback? listener) => super.noSuchMethod( + void removeListener(_i25.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #removeListener, [listener], @@ -2437,7 +2468,7 @@ class MockManager extends _i1.Mock implements _i6.Manager { /// A class which mocks [CoinServiceAPI]. /// /// See the documentation for Mockito's code generation for more information. -class MockCoinServiceAPI extends _i1.Mock implements _i19.CoinServiceAPI { +class MockCoinServiceAPI extends _i1.Mock implements _i20.CoinServiceAPI { @override set onIsActiveWalletChanged(void Function(bool)? _onIsActiveWalletChanged) => super.noSuchMethod( @@ -2448,10 +2479,10 @@ class MockCoinServiceAPI extends _i1.Mock implements _i19.CoinServiceAPI { returnValueForMissingStub: null, ); @override - _i21.Coin get coin => (super.noSuchMethod( + _i22.Coin get coin => (super.noSuchMethod( Invocation.getter(#coin), - returnValue: _i21.Coin.bitcoin, - ) as _i21.Coin); + returnValue: _i22.Coin.bitcoin, + ) as _i22.Coin); @override bool get isRefreshing => (super.noSuchMethod( Invocation.getter(#isRefreshing), @@ -2484,42 +2515,42 @@ class MockCoinServiceAPI extends _i1.Mock implements _i19.CoinServiceAPI { returnValueForMissingStub: null, ); @override - _i22.Future<_i9.FeeObject> get fees => (super.noSuchMethod( + _i23.Future<_i10.FeeObject> get fees => (super.noSuchMethod( Invocation.getter(#fees), - returnValue: _i22.Future<_i9.FeeObject>.value(_FakeFeeObject_6( + returnValue: _i23.Future<_i10.FeeObject>.value(_FakeFeeObject_7( this, Invocation.getter(#fees), )), - ) as _i22.Future<_i9.FeeObject>); + ) as _i23.Future<_i10.FeeObject>); @override - _i22.Future get maxFee => (super.noSuchMethod( + _i23.Future get maxFee => (super.noSuchMethod( Invocation.getter(#maxFee), - returnValue: _i22.Future.value(0), - ) as _i22.Future); + returnValue: _i23.Future.value(0), + ) as _i23.Future); @override - _i22.Future get currentReceivingAddress => (super.noSuchMethod( + _i23.Future get currentReceivingAddress => (super.noSuchMethod( Invocation.getter(#currentReceivingAddress), - returnValue: _i22.Future.value(''), - ) as _i22.Future); + returnValue: _i23.Future.value(''), + ) as _i23.Future); @override - _i12.Balance get balance => (super.noSuchMethod( + _i13.Balance get balance => (super.noSuchMethod( Invocation.getter(#balance), - returnValue: _FakeBalance_9( + returnValue: _FakeBalance_10( this, Invocation.getter(#balance), ), - ) as _i12.Balance); + ) as _i13.Balance); @override - _i22.Future> get transactions => (super.noSuchMethod( + _i23.Future> get transactions => (super.noSuchMethod( Invocation.getter(#transactions), returnValue: - _i22.Future>.value(<_i17.Transaction>[]), - ) as _i22.Future>); + _i23.Future>.value(<_i18.Transaction>[]), + ) as _i23.Future>); @override - _i22.Future> get utxos => (super.noSuchMethod( + _i23.Future> get utxos => (super.noSuchMethod( Invocation.getter(#utxos), - returnValue: _i22.Future>.value(<_i17.UTXO>[]), - ) as _i22.Future>); + returnValue: _i23.Future>.value(<_i18.UTXO>[]), + ) as _i23.Future>); @override set walletName(String? newName) => super.noSuchMethod( Invocation.setter( @@ -2539,20 +2570,20 @@ class MockCoinServiceAPI extends _i1.Mock implements _i19.CoinServiceAPI { returnValue: '', ) as String); @override - _i22.Future> get mnemonic => (super.noSuchMethod( + _i23.Future> get mnemonic => (super.noSuchMethod( Invocation.getter(#mnemonic), - returnValue: _i22.Future>.value([]), - ) as _i22.Future>); + returnValue: _i23.Future>.value([]), + ) as _i23.Future>); @override - _i22.Future get mnemonicString => (super.noSuchMethod( + _i23.Future get mnemonicString => (super.noSuchMethod( Invocation.getter(#mnemonicString), - returnValue: _i22.Future.value(), - ) as _i22.Future); + returnValue: _i23.Future.value(), + ) as _i23.Future); @override - _i22.Future get mnemonicPassphrase => (super.noSuchMethod( + _i23.Future get mnemonicPassphrase => (super.noSuchMethod( Invocation.getter(#mnemonicPassphrase), - returnValue: _i22.Future.value(), - ) as _i22.Future); + returnValue: _i23.Future.value(), + ) as _i23.Future); @override bool get hasCalledExit => (super.noSuchMethod( Invocation.getter(#hasCalledExit), @@ -2569,9 +2600,9 @@ class MockCoinServiceAPI extends _i1.Mock implements _i19.CoinServiceAPI { returnValue: 0, ) as int); @override - _i22.Future> prepareSend({ + _i23.Future> prepareSend({ required String? address, - required _i14.Amount? amount, + required _i15.Amount? amount, Map? args, }) => (super.noSuchMethod( @@ -2585,36 +2616,36 @@ class MockCoinServiceAPI extends _i1.Mock implements _i19.CoinServiceAPI { }, ), returnValue: - _i22.Future>.value({}), - ) as _i22.Future>); + _i23.Future>.value({}), + ) as _i23.Future>); @override - _i22.Future confirmSend({required Map? txData}) => + _i23.Future confirmSend({required Map? txData}) => (super.noSuchMethod( Invocation.method( #confirmSend, [], {#txData: txData}, ), - returnValue: _i22.Future.value(''), - ) as _i22.Future); + returnValue: _i23.Future.value(''), + ) as _i23.Future); @override - _i22.Future refresh() => (super.noSuchMethod( + _i23.Future refresh() => (super.noSuchMethod( Invocation.method( #refresh, [], ), - returnValue: _i22.Future.value(), - returnValueForMissingStub: _i22.Future.value(), - ) as _i22.Future); + returnValue: _i23.Future.value(), + returnValueForMissingStub: _i23.Future.value(), + ) as _i23.Future); @override - _i22.Future updateNode(bool? shouldRefresh) => (super.noSuchMethod( + _i23.Future updateNode(bool? shouldRefresh) => (super.noSuchMethod( Invocation.method( #updateNode, [shouldRefresh], ), - returnValue: _i22.Future.value(), - returnValueForMissingStub: _i22.Future.value(), - ) as _i22.Future); + returnValue: _i23.Future.value(), + returnValueForMissingStub: _i23.Future.value(), + ) as _i23.Future); @override bool validateAddress(String? address) => (super.noSuchMethod( Invocation.method( @@ -2624,15 +2655,15 @@ class MockCoinServiceAPI extends _i1.Mock implements _i19.CoinServiceAPI { returnValue: false, ) as bool); @override - _i22.Future testNetworkConnection() => (super.noSuchMethod( + _i23.Future testNetworkConnection() => (super.noSuchMethod( Invocation.method( #testNetworkConnection, [], ), - returnValue: _i22.Future.value(false), - ) as _i22.Future); + returnValue: _i23.Future.value(false), + ) as _i23.Future); @override - _i22.Future recoverFromMnemonic({ + _i23.Future recoverFromMnemonic({ required String? mnemonic, String? mnemonicPassphrase, required int? maxUnusedAddressGap, @@ -2651,38 +2682,40 @@ class MockCoinServiceAPI extends _i1.Mock implements _i19.CoinServiceAPI { #height: height, }, ), - returnValue: _i22.Future.value(), - returnValueForMissingStub: _i22.Future.value(), - ) as _i22.Future); + returnValue: _i23.Future.value(), + returnValueForMissingStub: _i23.Future.value(), + ) as _i23.Future); @override - _i22.Future initializeNew() => (super.noSuchMethod( + _i23.Future initializeNew( + ({String mnemonicPassphrase, int wordCount})? data) => + (super.noSuchMethod( Invocation.method( #initializeNew, - [], + [data], ), - returnValue: _i22.Future.value(), - returnValueForMissingStub: _i22.Future.value(), - ) as _i22.Future); + returnValue: _i23.Future.value(), + returnValueForMissingStub: _i23.Future.value(), + ) as _i23.Future); @override - _i22.Future initializeExisting() => (super.noSuchMethod( + _i23.Future initializeExisting() => (super.noSuchMethod( Invocation.method( #initializeExisting, [], ), - returnValue: _i22.Future.value(), - returnValueForMissingStub: _i22.Future.value(), - ) as _i22.Future); + returnValue: _i23.Future.value(), + returnValueForMissingStub: _i23.Future.value(), + ) as _i23.Future); @override - _i22.Future exit() => (super.noSuchMethod( + _i23.Future exit() => (super.noSuchMethod( Invocation.method( #exit, [], ), - returnValue: _i22.Future.value(), - returnValueForMissingStub: _i22.Future.value(), - ) as _i22.Future); + returnValue: _i23.Future.value(), + returnValueForMissingStub: _i23.Future.value(), + ) as _i23.Future); @override - _i22.Future fullRescan( + _i23.Future fullRescan( int? maxUnusedAddressGap, int? maxNumberOfIndexesToCheck, ) => @@ -2694,12 +2727,12 @@ class MockCoinServiceAPI extends _i1.Mock implements _i19.CoinServiceAPI { maxNumberOfIndexesToCheck, ], ), - returnValue: _i22.Future.value(), - returnValueForMissingStub: _i22.Future.value(), - ) as _i22.Future); + returnValue: _i23.Future.value(), + returnValueForMissingStub: _i23.Future.value(), + ) as _i23.Future); @override - _i22.Future<_i14.Amount> estimateFeeFor( - _i14.Amount? amount, + _i23.Future<_i15.Amount> estimateFeeFor( + _i15.Amount? amount, int? feeRate, ) => (super.noSuchMethod( @@ -2710,7 +2743,7 @@ class MockCoinServiceAPI extends _i1.Mock implements _i19.CoinServiceAPI { feeRate, ], ), - returnValue: _i22.Future<_i14.Amount>.value(_FakeAmount_12( + returnValue: _i23.Future<_i15.Amount>.value(_FakeAmount_13( this, Invocation.method( #estimateFeeFor, @@ -2720,23 +2753,23 @@ class MockCoinServiceAPI extends _i1.Mock implements _i19.CoinServiceAPI { ], ), )), - ) as _i22.Future<_i14.Amount>); + ) as _i23.Future<_i15.Amount>); @override - _i22.Future generateNewAddress() => (super.noSuchMethod( + _i23.Future generateNewAddress() => (super.noSuchMethod( Invocation.method( #generateNewAddress, [], ), - returnValue: _i22.Future.value(false), - ) as _i22.Future); + returnValue: _i23.Future.value(false), + ) as _i23.Future); @override - _i22.Future updateSentCachedTxData(Map? txData) => + _i23.Future updateSentCachedTxData(Map? txData) => (super.noSuchMethod( Invocation.method( #updateSentCachedTxData, [txData], ), - returnValue: _i22.Future.value(), - returnValueForMissingStub: _i22.Future.value(), - ) as _i22.Future); + returnValue: _i23.Future.value(), + returnValueForMissingStub: _i23.Future.value(), + ) as _i23.Future); } diff --git a/test/widget_tests/trade_card_test.dart b/test/widget_tests/trade_card_test.dart index d42c00b85..d30c91560 100644 --- a/test/widget_tests/trade_card_test.dart +++ b/test/widget_tests/trade_card_test.dart @@ -1,3 +1,5 @@ +import 'dart:io'; + import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_test/flutter_test.dart'; @@ -5,7 +7,9 @@ import 'package:mockito/annotations.dart'; import 'package:mockito/mockito.dart'; import 'package:stackwallet/models/exchange/response_objects/trade.dart'; import 'package:stackwallet/models/isar/stack_theme.dart'; +import 'package:stackwallet/themes/coin_icon_provider.dart'; import 'package:stackwallet/themes/stack_colors.dart'; +import 'package:stackwallet/themes/theme_providers.dart'; import 'package:stackwallet/themes/theme_service.dart'; import 'package:stackwallet/widgets/trade_card.dart'; @@ -14,10 +18,17 @@ import 'trade_card_test.mocks.dart'; @GenerateMocks([ ThemeService, + IThemeAssets, ]) void main() { testWidgets("Test Trade card builds", (widgetTester) async { final mockThemeService = MockThemeService(); + final mockIThemeAssets = MockIThemeAssets(); + + when(mockIThemeAssets.txExchangeFailed).thenAnswer( + (_) => + "${Directory.current.path}/test/sample_data/light/assets/dummy.svg", + ); when(mockThemeService.getTheme(themeId: "light")).thenAnswer( (_) => StackTheme.fromJson( json: lightThemeJsonMap, @@ -51,6 +62,15 @@ void main() { ProviderScope( overrides: [ pThemeService.overrideWithValue(mockThemeService), + themeAssetsProvider.overrideWithProvider( + StateProvider( + (ref) => mockIThemeAssets, + ), + ), + coinIconProvider.overrideWithProvider( + (argument) => Provider((_) => + "${Directory.current.path}/test/sample_data/light/assets/dummy.svg"), + ), ], child: MaterialApp( theme: ThemeData( diff --git a/test/widget_tests/trade_card_test.mocks.dart b/test/widget_tests/trade_card_test.mocks.dart index 1bb236eb4..e8bb7f552 100644 --- a/test/widget_tests/trade_card_test.mocks.dart +++ b/test/widget_tests/trade_card_test.mocks.dart @@ -3,13 +3,14 @@ // Do not manually edit this file. // ignore_for_file: no_leading_underscores_for_library_prefixes -import 'dart:async' as _i5; -import 'dart:typed_data' as _i6; +import 'dart:async' as _i6; +import 'dart:typed_data' as _i7; import 'package:mockito/mockito.dart' as _i1; -import 'package:stackwallet/db/isar/main_db.dart' as _i2; -import 'package:stackwallet/models/isar/stack_theme.dart' as _i4; -import 'package:stackwallet/themes/theme_service.dart' as _i3; +import 'package:stackwallet/db/isar/main_db.dart' as _i3; +import 'package:stackwallet/models/isar/stack_theme.dart' as _i5; +import 'package:stackwallet/networking/http.dart' as _i2; +import 'package:stackwallet/themes/theme_service.dart' as _i4; // ignore_for_file: type=lint // ignore_for_file: avoid_redundant_argument_values @@ -22,8 +23,18 @@ import 'package:stackwallet/themes/theme_service.dart' as _i3; // ignore_for_file: camel_case_types // ignore_for_file: subtype_of_sealed_class -class _FakeMainDB_0 extends _i1.SmartFake implements _i2.MainDB { - _FakeMainDB_0( +class _FakeHTTP_0 extends _i1.SmartFake implements _i2.HTTP { + _FakeHTTP_0( + Object parent, + Invocation parentInvocation, + ) : super( + parent, + parentInvocation, + ); +} + +class _FakeMainDB_1 extends _i1.SmartFake implements _i3.MainDB { + _FakeMainDB_1( Object parent, Invocation parentInvocation, ) : super( @@ -35,26 +46,42 @@ class _FakeMainDB_0 extends _i1.SmartFake implements _i2.MainDB { /// A class which mocks [ThemeService]. /// /// See the documentation for Mockito's code generation for more information. -class MockThemeService extends _i1.Mock implements _i3.ThemeService { +class MockThemeService extends _i1.Mock implements _i4.ThemeService { MockThemeService() { _i1.throwOnMissingStub(this); } @override - _i2.MainDB get db => (super.noSuchMethod( + _i2.HTTP get client => (super.noSuchMethod( + Invocation.getter(#client), + returnValue: _FakeHTTP_0( + this, + Invocation.getter(#client), + ), + ) as _i2.HTTP); + @override + set client(_i2.HTTP? _client) => super.noSuchMethod( + Invocation.setter( + #client, + _client, + ), + returnValueForMissingStub: null, + ); + @override + _i3.MainDB get db => (super.noSuchMethod( Invocation.getter(#db), - returnValue: _FakeMainDB_0( + returnValue: _FakeMainDB_1( this, Invocation.getter(#db), ), - ) as _i2.MainDB); + ) as _i3.MainDB); @override - List<_i4.StackTheme> get installedThemes => (super.noSuchMethod( + List<_i5.StackTheme> get installedThemes => (super.noSuchMethod( Invocation.getter(#installedThemes), - returnValue: <_i4.StackTheme>[], - ) as List<_i4.StackTheme>); + returnValue: <_i5.StackTheme>[], + ) as List<_i5.StackTheme>); @override - void init(_i2.MainDB? db) => super.noSuchMethod( + void init(_i3.MainDB? db) => super.noSuchMethod( Invocation.method( #init, [db], @@ -62,70 +89,170 @@ class MockThemeService extends _i1.Mock implements _i3.ThemeService { returnValueForMissingStub: null, ); @override - _i5.Future install({required _i6.Uint8List? themeArchiveData}) => + _i6.Future install({required _i7.Uint8List? themeArchiveData}) => (super.noSuchMethod( Invocation.method( #install, [], {#themeArchiveData: themeArchiveData}, ), - returnValue: _i5.Future.value(), - returnValueForMissingStub: _i5.Future.value(), - ) as _i5.Future); + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); @override - _i5.Future remove({required String? themeId}) => (super.noSuchMethod( + _i6.Future remove({required String? themeId}) => (super.noSuchMethod( Invocation.method( #remove, [], {#themeId: themeId}, ), - returnValue: _i5.Future.value(), - returnValueForMissingStub: _i5.Future.value(), - ) as _i5.Future); + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); @override - _i5.Future checkDefaultThemesOnStartup() => (super.noSuchMethod( + _i6.Future checkDefaultThemesOnStartup() => (super.noSuchMethod( Invocation.method( #checkDefaultThemesOnStartup, [], ), - returnValue: _i5.Future.value(), - returnValueForMissingStub: _i5.Future.value(), - ) as _i5.Future); + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); @override - _i5.Future verifyInstalled({required String? themeId}) => + _i6.Future verifyInstalled({required String? themeId}) => (super.noSuchMethod( Invocation.method( #verifyInstalled, [], {#themeId: themeId}, ), - returnValue: _i5.Future.value(false), - ) as _i5.Future); + returnValue: _i6.Future.value(false), + ) as _i6.Future); @override - _i5.Future> fetchThemes() => (super.noSuchMethod( + _i6.Future> fetchThemes() => (super.noSuchMethod( Invocation.method( #fetchThemes, [], ), - returnValue: _i5.Future>.value( - <_i3.StackThemeMetaData>[]), - ) as _i5.Future>); + returnValue: _i6.Future>.value( + <_i4.StackThemeMetaData>[]), + ) as _i6.Future>); @override - _i5.Future<_i6.Uint8List> fetchTheme( - {required _i3.StackThemeMetaData? themeMetaData}) => + _i6.Future<_i7.Uint8List> fetchTheme( + {required _i4.StackThemeMetaData? themeMetaData}) => (super.noSuchMethod( Invocation.method( #fetchTheme, [], {#themeMetaData: themeMetaData}, ), - returnValue: _i5.Future<_i6.Uint8List>.value(_i6.Uint8List(0)), - ) as _i5.Future<_i6.Uint8List>); + returnValue: _i6.Future<_i7.Uint8List>.value(_i7.Uint8List(0)), + ) as _i6.Future<_i7.Uint8List>); @override - _i4.StackTheme? getTheme({required String? themeId}) => + _i5.StackTheme? getTheme({required String? themeId}) => (super.noSuchMethod(Invocation.method( #getTheme, [], {#themeId: themeId}, - )) as _i4.StackTheme?); + )) as _i5.StackTheme?); +} + +/// A class which mocks [IThemeAssets]. +/// +/// See the documentation for Mockito's code generation for more information. +class MockIThemeAssets extends _i1.Mock implements _i5.IThemeAssets { + MockIThemeAssets() { + _i1.throwOnMissingStub(this); + } + + @override + String get bellNew => (super.noSuchMethod( + Invocation.getter(#bellNew), + returnValue: '', + ) as String); + @override + String get buy => (super.noSuchMethod( + Invocation.getter(#buy), + returnValue: '', + ) as String); + @override + String get exchange => (super.noSuchMethod( + Invocation.getter(#exchange), + returnValue: '', + ) as String); + @override + String get personaIncognito => (super.noSuchMethod( + Invocation.getter(#personaIncognito), + returnValue: '', + ) as String); + @override + String get personaEasy => (super.noSuchMethod( + Invocation.getter(#personaEasy), + returnValue: '', + ) as String); + @override + String get stack => (super.noSuchMethod( + Invocation.getter(#stack), + returnValue: '', + ) as String); + @override + String get stackIcon => (super.noSuchMethod( + Invocation.getter(#stackIcon), + returnValue: '', + ) as String); + @override + String get receive => (super.noSuchMethod( + Invocation.getter(#receive), + returnValue: '', + ) as String); + @override + String get receivePending => (super.noSuchMethod( + Invocation.getter(#receivePending), + returnValue: '', + ) as String); + @override + String get receiveCancelled => (super.noSuchMethod( + Invocation.getter(#receiveCancelled), + returnValue: '', + ) as String); + @override + String get send => (super.noSuchMethod( + Invocation.getter(#send), + returnValue: '', + ) as String); + @override + String get sendPending => (super.noSuchMethod( + Invocation.getter(#sendPending), + returnValue: '', + ) as String); + @override + String get sendCancelled => (super.noSuchMethod( + Invocation.getter(#sendCancelled), + returnValue: '', + ) as String); + @override + String get themeSelector => (super.noSuchMethod( + Invocation.getter(#themeSelector), + returnValue: '', + ) as String); + @override + String get themePreview => (super.noSuchMethod( + Invocation.getter(#themePreview), + returnValue: '', + ) as String); + @override + String get txExchange => (super.noSuchMethod( + Invocation.getter(#txExchange), + returnValue: '', + ) as String); + @override + String get txExchangePending => (super.noSuchMethod( + Invocation.getter(#txExchangePending), + returnValue: '', + ) as String); + @override + String get txExchangeFailed => (super.noSuchMethod( + Invocation.getter(#txExchangeFailed), + returnValue: '', + ) as String); } diff --git a/test/widget_tests/transaction_card_test.dart b/test/widget_tests/transaction_card_test.dart index c4b89fb4a..755b367c1 100644 --- a/test/widget_tests/transaction_card_test.dart +++ b/test/widget_tests/transaction_card_test.dart @@ -1,3 +1,5 @@ +import 'dart:io'; + import 'package:decimal/decimal.dart'; import 'package:flutter/material.dart'; import 'package:flutter_feather_icons/flutter_feather_icons.dart'; @@ -22,7 +24,9 @@ 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/coin_icon_provider.dart'; import 'package:stackwallet/themes/stack_colors.dart'; +import 'package:stackwallet/themes/theme_providers.dart'; import 'package:stackwallet/themes/theme_service.dart'; import 'package:stackwallet/utilities/amount/amount.dart'; import 'package:stackwallet/utilities/amount/amount_unit.dart'; @@ -46,6 +50,7 @@ import 'transaction_card_test.mocks.dart'; NotesService, ThemeService, MainDB, + IThemeAssets, ], customMocks: []) void main() { TestWidgetsFlutterBinding.ensureInitialized(); @@ -57,6 +62,12 @@ void main() { final mockPriceService = MockPriceService(); final mockThemeService = MockThemeService(); final mockDB = MockMainDB(); + final mockIThemeAssets = MockIThemeAssets(); + + when(mockIThemeAssets.send).thenAnswer( + (_) => + "${Directory.current.path}/test/sample_data/light/assets/dummy.svg", + ); final tx = Transaction( txid: "some txid", @@ -130,6 +141,15 @@ void main() { prefsChangeNotifierProvider.overrideWithValue(mockPrefs), priceAnd24hChangeNotifierProvider.overrideWithValue(mockPriceService), mainDBProvider.overrideWithValue(mockDB), + coinIconProvider.overrideWithProvider( + (argument) => Provider((_) => + "${Directory.current.path}/test/sample_data/light/assets/dummy.svg"), + ), + themeAssetsProvider.overrideWithProvider( + StateProvider( + (ref) => mockIThemeAssets, + ), + ), ], child: MaterialApp( theme: ThemeData( @@ -186,6 +206,12 @@ void main() { final mockPriceService = MockPriceService(); final mockThemeService = MockThemeService(); final mockDB = MockMainDB(); + final mockIThemeAssets = MockIThemeAssets(); + + when(mockIThemeAssets.txExchangeFailed).thenAnswer( + (_) => + "${Directory.current.path}/test/sample_data/light/assets/dummy.svg", + ); final tx = Transaction( txid: "some txid", @@ -257,7 +283,16 @@ void main() { prefsChangeNotifierProvider.overrideWithValue(mockPrefs), pThemeService.overrideWithValue(mockThemeService), mainDBProvider.overrideWithValue(mockDB), - priceAnd24hChangeNotifierProvider.overrideWithValue(mockPriceService) + priceAnd24hChangeNotifierProvider.overrideWithValue(mockPriceService), + coinIconProvider.overrideWithProvider( + (argument) => Provider((_) => + "${Directory.current.path}/test/sample_data/light/assets/dummy.svg"), + ), + themeAssetsProvider.overrideWithProvider( + StateProvider( + (ref) => mockIThemeAssets, + ), + ), ], child: MaterialApp( theme: ThemeData( @@ -312,6 +347,12 @@ void main() { final mockPriceService = MockPriceService(); final mockThemeService = MockThemeService(); final mockDB = MockMainDB(); + final mockIThemeAssets = MockIThemeAssets(); + + when(mockIThemeAssets.receive).thenAnswer( + (_) => + "${Directory.current.path}/test/sample_data/light/assets/dummy.svg", + ); final tx = Transaction( txid: "some txid", @@ -384,7 +425,16 @@ void main() { prefsChangeNotifierProvider.overrideWithValue(mockPrefs), pThemeService.overrideWithValue(mockThemeService), mainDBProvider.overrideWithValue(mockDB), - priceAnd24hChangeNotifierProvider.overrideWithValue(mockPriceService) + priceAnd24hChangeNotifierProvider.overrideWithValue(mockPriceService), + coinIconProvider.overrideWithProvider( + (argument) => Provider((_) => + "${Directory.current.path}/test/sample_data/light/assets/dummy.svg"), + ), + themeAssetsProvider.overrideWithProvider( + StateProvider( + (ref) => mockIThemeAssets, + ), + ), ], child: MaterialApp( theme: ThemeData( @@ -432,6 +482,12 @@ void main() { final mockThemeService = MockThemeService(); final mockDB = MockMainDB(); final navigator = mockingjay.MockNavigator(); + final mockIThemeAssets = MockIThemeAssets(); + + when(mockIThemeAssets.send).thenAnswer( + (_) => + "${Directory.current.path}/test/sample_data/light/assets/dummy.svg", + ); final tx = Transaction( txid: "some txid", @@ -509,7 +565,16 @@ void main() { prefsChangeNotifierProvider.overrideWithValue(mockPrefs), pThemeService.overrideWithValue(mockThemeService), mainDBProvider.overrideWithValue(mockDB), - priceAnd24hChangeNotifierProvider.overrideWithValue(mockPriceService) + priceAnd24hChangeNotifierProvider.overrideWithValue(mockPriceService), + coinIconProvider.overrideWithProvider( + (argument) => Provider((_) => + "${Directory.current.path}/test/sample_data/light/assets/dummy.svg"), + ), + themeAssetsProvider.overrideWithProvider( + StateProvider( + (ref) => mockIThemeAssets, + ), + ), ], child: MaterialApp( theme: ThemeData( diff --git a/test/widget_tests/transaction_card_test.mocks.dart b/test/widget_tests/transaction_card_test.mocks.dart index 66bd37cf0..5ef7ef5a1 100644 --- a/test/widget_tests/transaction_card_test.mocks.dart +++ b/test/widget_tests/transaction_card_test.mocks.dart @@ -3,43 +3,44 @@ // Do not manually edit this file. // ignore_for_file: no_leading_underscores_for_library_prefixes -import 'dart:async' as _i19; -import 'dart:typed_data' as _i34; -import 'dart:ui' as _i21; +import 'dart:async' as _i20; +import 'dart:typed_data' as _i35; +import 'dart:ui' as _i22; -import 'package:decimal/decimal.dart' as _i30; +import 'package:decimal/decimal.dart' as _i31; 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:isar/isar.dart' as _i17; 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/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/isar/models/block_explorer.dart' as _i37; +import 'package:stackwallet/models/isar/models/contact_entry.dart' as _i36; +import 'package:stackwallet/models/isar/models/isar_models.dart' as _i23; +import 'package:stackwallet/models/isar/stack_theme.dart' as _i34; import 'package:stackwallet/models/models.dart' as _i8; -import 'package:stackwallet/models/signing_data.dart' as _i24; +import 'package:stackwallet/models/signing_data.dart' as _i25; +import 'package:stackwallet/networking/http.dart' as _i16; import 'package:stackwallet/services/coins/coin_service.dart' as _i7; -import 'package:stackwallet/services/coins/firo/firo_wallet.dart' as _i23; +import 'package:stackwallet/services/coins/firo/firo_wallet.dart' as _i24; import 'package:stackwallet/services/coins/manager.dart' as _i6; -import 'package:stackwallet/services/locale_service.dart' as _i25; +import 'package:stackwallet/services/locale_service.dart' as _i26; import 'package:stackwallet/services/node_service.dart' as _i3; -import 'package:stackwallet/services/notes_service.dart' as _i31; -import 'package:stackwallet/services/price_service.dart' as _i29; +import 'package:stackwallet/services/notes_service.dart' as _i32; +import 'package:stackwallet/services/price_service.dart' as _i30; import 'package:stackwallet/services/transaction_notification_tracker.dart' as _i11; -import 'package:stackwallet/services/wallets.dart' as _i17; +import 'package:stackwallet/services/wallets.dart' as _i18; import 'package:stackwallet/services/wallets_service.dart' as _i2; -import 'package:stackwallet/themes/theme_service.dart' as _i32; +import 'package:stackwallet/themes/theme_service.dart' as _i33; import 'package:stackwallet/utilities/amount/amount.dart' as _i10; -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:stackwallet/utilities/amount/amount_unit.dart' as _i29; +import 'package:stackwallet/utilities/enums/backup_frequency_type.dart' as _i28; +import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i19; +import 'package:stackwallet/utilities/enums/sync_type_enum.dart' as _i27; +import 'package:stackwallet/utilities/prefs.dart' as _i21; import 'package:tuple/tuple.dart' as _i15; // ignore_for_file: type=lint @@ -199,8 +200,8 @@ class _FakeTuple2_13 extends _i1.SmartFake ); } -class _FakeIsar_14 extends _i1.SmartFake implements _i16.Isar { - _FakeIsar_14( +class _FakeHTTP_14 extends _i1.SmartFake implements _i16.HTTP { + _FakeHTTP_14( Object parent, Invocation parentInvocation, ) : super( @@ -209,9 +210,19 @@ class _FakeIsar_14 extends _i1.SmartFake implements _i16.Isar { ); } -class _FakeQueryBuilder_15 extends _i1.SmartFake - implements _i16.QueryBuilder { - _FakeQueryBuilder_15( +class _FakeIsar_15 extends _i1.SmartFake implements _i17.Isar { + _FakeIsar_15( + Object parent, + Invocation parentInvocation, + ) : super( + parent, + parentInvocation, + ); +} + +class _FakeQueryBuilder_16 extends _i1.SmartFake + implements _i17.QueryBuilder { + _FakeQueryBuilder_16( Object parent, Invocation parentInvocation, ) : super( @@ -223,7 +234,7 @@ class _FakeQueryBuilder_15 extends _i1.SmartFake /// A class which mocks [Wallets]. /// /// See the documentation for Mockito's code generation for more information. -class MockWallets extends _i1.Mock implements _i17.Wallets { +class MockWallets extends _i1.Mock implements _i18.Wallets { MockWallets() { _i1.throwOnMissingStub(this); } @@ -290,7 +301,7 @@ class MockWallets extends _i1.Mock implements _i17.Wallets { returnValueForMissingStub: null, ); @override - List getWalletIdsFor({required _i18.Coin? coin}) => + List getWalletIdsFor({required _i19.Coin? coin}) => (super.noSuchMethod( Invocation.method( #getWalletIdsFor, @@ -300,20 +311,20 @@ class MockWallets extends _i1.Mock implements _i17.Wallets { returnValue: [], ) as List); @override - List<_i15.Tuple2<_i18.Coin, List<_i5.ChangeNotifierProvider<_i6.Manager>>>> + List<_i15.Tuple2<_i19.Coin, List<_i5.ChangeNotifierProvider<_i6.Manager>>>> getManagerProvidersByCoin() => (super.noSuchMethod( Invocation.method( #getManagerProvidersByCoin, [], ), - returnValue: <_i15.Tuple2<_i18.Coin, + returnValue: <_i15.Tuple2<_i19.Coin, List<_i5.ChangeNotifierProvider<_i6.Manager>>>>[], ) as List< - _i15.Tuple2<_i18.Coin, + _i15.Tuple2<_i19.Coin, List<_i5.ChangeNotifierProvider<_i6.Manager>>>>); @override List<_i5.ChangeNotifierProvider<_i6.Manager>> getManagerProvidersForCoin( - _i18.Coin? coin) => + _i19.Coin? coin) => (super.noSuchMethod( Invocation.method( #getManagerProvidersForCoin, @@ -377,17 +388,17 @@ class MockWallets extends _i1.Mock implements _i17.Wallets { returnValueForMissingStub: null, ); @override - _i19.Future load(_i20.Prefs? prefs) => (super.noSuchMethod( + _i20.Future load(_i21.Prefs? prefs) => (super.noSuchMethod( Invocation.method( #load, [prefs], ), - returnValue: _i19.Future.value(), - returnValueForMissingStub: _i19.Future.value(), - ) as _i19.Future); + returnValue: _i20.Future.value(), + returnValueForMissingStub: _i20.Future.value(), + ) as _i20.Future); @override - _i19.Future loadAfterStackRestore( - _i20.Prefs? prefs, + _i20.Future loadAfterStackRestore( + _i21.Prefs? prefs, List<_i6.Manager>? managers, ) => (super.noSuchMethod( @@ -398,11 +409,11 @@ class MockWallets extends _i1.Mock implements _i17.Wallets { managers, ], ), - returnValue: _i19.Future.value(), - returnValueForMissingStub: _i19.Future.value(), - ) as _i19.Future); + returnValue: _i20.Future.value(), + returnValueForMissingStub: _i20.Future.value(), + ) as _i20.Future); @override - void addListener(_i21.VoidCallback? listener) => super.noSuchMethod( + void addListener(_i22.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #addListener, [listener], @@ -410,7 +421,7 @@ class MockWallets extends _i1.Mock implements _i17.Wallets { returnValueForMissingStub: null, ); @override - void removeListener(_i21.VoidCallback? listener) => super.noSuchMethod( + void removeListener(_i22.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #removeListener, [listener], @@ -462,10 +473,10 @@ class MockManager extends _i1.Mock implements _i6.Manager { returnValue: false, ) as bool); @override - _i18.Coin get coin => (super.noSuchMethod( + _i19.Coin get coin => (super.noSuchMethod( Invocation.getter(#coin), - returnValue: _i18.Coin.bitcoin, - ) as _i18.Coin); + returnValue: _i19.Coin.bitcoin, + ) as _i19.Coin); @override bool get isRefreshing => (super.noSuchMethod( Invocation.getter(#isRefreshing), @@ -498,23 +509,23 @@ class MockManager extends _i1.Mock implements _i6.Manager { returnValueForMissingStub: null, ); @override - _i19.Future<_i8.FeeObject> get fees => (super.noSuchMethod( + _i20.Future<_i8.FeeObject> get fees => (super.noSuchMethod( Invocation.getter(#fees), - returnValue: _i19.Future<_i8.FeeObject>.value(_FakeFeeObject_5( + returnValue: _i20.Future<_i8.FeeObject>.value(_FakeFeeObject_5( this, Invocation.getter(#fees), )), - ) as _i19.Future<_i8.FeeObject>); + ) as _i20.Future<_i8.FeeObject>); @override - _i19.Future get maxFee => (super.noSuchMethod( + _i20.Future get maxFee => (super.noSuchMethod( Invocation.getter(#maxFee), - returnValue: _i19.Future.value(0), - ) as _i19.Future); + returnValue: _i20.Future.value(0), + ) as _i20.Future); @override - _i19.Future get currentReceivingAddress => (super.noSuchMethod( + _i20.Future get currentReceivingAddress => (super.noSuchMethod( Invocation.getter(#currentReceivingAddress), - returnValue: _i19.Future.value(''), - ) as _i19.Future); + returnValue: _i20.Future.value(''), + ) as _i20.Future); @override _i9.Balance get balance => (super.noSuchMethod( Invocation.getter(#balance), @@ -524,16 +535,16 @@ class MockManager extends _i1.Mock implements _i6.Manager { ), ) as _i9.Balance); @override - _i19.Future> get transactions => (super.noSuchMethod( + _i20.Future> get transactions => (super.noSuchMethod( Invocation.getter(#transactions), returnValue: - _i19.Future>.value(<_i22.Transaction>[]), - ) as _i19.Future>); + _i20.Future>.value(<_i23.Transaction>[]), + ) as _i20.Future>); @override - _i19.Future> get utxos => (super.noSuchMethod( + _i20.Future> get utxos => (super.noSuchMethod( Invocation.getter(#utxos), - returnValue: _i19.Future>.value(<_i22.UTXO>[]), - ) as _i19.Future>); + returnValue: _i20.Future>.value(<_i23.UTXO>[]), + ) as _i20.Future>); @override set walletName(String? newName) => super.noSuchMethod( Invocation.setter( @@ -553,15 +564,15 @@ class MockManager extends _i1.Mock implements _i6.Manager { returnValue: '', ) as String); @override - _i19.Future> get mnemonic => (super.noSuchMethod( + _i20.Future> get mnemonic => (super.noSuchMethod( Invocation.getter(#mnemonic), - returnValue: _i19.Future>.value([]), - ) as _i19.Future>); + returnValue: _i20.Future>.value([]), + ) as _i20.Future>); @override - _i19.Future get mnemonicPassphrase => (super.noSuchMethod( + _i20.Future get mnemonicPassphrase => (super.noSuchMethod( Invocation.getter(#mnemonicPassphrase), - returnValue: _i19.Future.value(), - ) as _i19.Future); + returnValue: _i20.Future.value(), + ) as _i20.Future); @override bool get isConnected => (super.noSuchMethod( Invocation.getter(#isConnected), @@ -608,24 +619,24 @@ class MockManager extends _i1.Mock implements _i6.Manager { returnValue: false, ) as bool); @override - _i19.Future get xpub => (super.noSuchMethod( + _i20.Future get xpub => (super.noSuchMethod( Invocation.getter(#xpub), - returnValue: _i19.Future.value(''), - ) as _i19.Future); + returnValue: _i20.Future.value(''), + ) as _i20.Future); @override bool get hasListeners => (super.noSuchMethod( Invocation.getter(#hasListeners), returnValue: false, ) as bool); @override - _i19.Future updateNode(bool? shouldRefresh) => (super.noSuchMethod( + _i20.Future updateNode(bool? shouldRefresh) => (super.noSuchMethod( Invocation.method( #updateNode, [shouldRefresh], ), - returnValue: _i19.Future.value(), - returnValueForMissingStub: _i19.Future.value(), - ) as _i19.Future); + returnValue: _i20.Future.value(), + returnValueForMissingStub: _i20.Future.value(), + ) as _i20.Future); @override void dispose() => super.noSuchMethod( Invocation.method( @@ -635,7 +646,7 @@ class MockManager extends _i1.Mock implements _i6.Manager { returnValueForMissingStub: null, ); @override - _i19.Future> prepareSend({ + _i20.Future> prepareSend({ required String? address, required _i10.Amount? amount, Map? args, @@ -651,27 +662,27 @@ class MockManager extends _i1.Mock implements _i6.Manager { }, ), returnValue: - _i19.Future>.value({}), - ) as _i19.Future>); + _i20.Future>.value({}), + ) as _i20.Future>); @override - _i19.Future confirmSend({required Map? txData}) => + _i20.Future confirmSend({required Map? txData}) => (super.noSuchMethod( Invocation.method( #confirmSend, [], {#txData: txData}, ), - returnValue: _i19.Future.value(''), - ) as _i19.Future); + returnValue: _i20.Future.value(''), + ) as _i20.Future); @override - _i19.Future refresh() => (super.noSuchMethod( + _i20.Future refresh() => (super.noSuchMethod( Invocation.method( #refresh, [], ), - returnValue: _i19.Future.value(), - returnValueForMissingStub: _i19.Future.value(), - ) as _i19.Future); + returnValue: _i20.Future.value(), + returnValueForMissingStub: _i20.Future.value(), + ) as _i20.Future); @override bool validateAddress(String? address) => (super.noSuchMethod( Invocation.method( @@ -681,33 +692,35 @@ class MockManager extends _i1.Mock implements _i6.Manager { returnValue: false, ) as bool); @override - _i19.Future testNetworkConnection() => (super.noSuchMethod( + _i20.Future testNetworkConnection() => (super.noSuchMethod( Invocation.method( #testNetworkConnection, [], ), - returnValue: _i19.Future.value(false), - ) as _i19.Future); + returnValue: _i20.Future.value(false), + ) as _i20.Future); @override - _i19.Future initializeNew() => (super.noSuchMethod( + _i20.Future initializeNew( + ({String mnemonicPassphrase, int wordCount})? data) => + (super.noSuchMethod( Invocation.method( #initializeNew, - [], + [data], ), - returnValue: _i19.Future.value(), - returnValueForMissingStub: _i19.Future.value(), - ) as _i19.Future); + returnValue: _i20.Future.value(), + returnValueForMissingStub: _i20.Future.value(), + ) as _i20.Future); @override - _i19.Future initializeExisting() => (super.noSuchMethod( + _i20.Future initializeExisting() => (super.noSuchMethod( Invocation.method( #initializeExisting, [], ), - returnValue: _i19.Future.value(), - returnValueForMissingStub: _i19.Future.value(), - ) as _i19.Future); + returnValue: _i20.Future.value(), + returnValueForMissingStub: _i20.Future.value(), + ) as _i20.Future); @override - _i19.Future recoverFromMnemonic({ + _i20.Future recoverFromMnemonic({ required String? mnemonic, String? mnemonicPassphrase, required int? maxUnusedAddressGap, @@ -726,20 +739,20 @@ class MockManager extends _i1.Mock implements _i6.Manager { #height: height, }, ), - returnValue: _i19.Future.value(), - returnValueForMissingStub: _i19.Future.value(), - ) as _i19.Future); + returnValue: _i20.Future.value(), + returnValueForMissingStub: _i20.Future.value(), + ) as _i20.Future); @override - _i19.Future exitCurrentWallet() => (super.noSuchMethod( + _i20.Future exitCurrentWallet() => (super.noSuchMethod( Invocation.method( #exitCurrentWallet, [], ), - returnValue: _i19.Future.value(), - returnValueForMissingStub: _i19.Future.value(), - ) as _i19.Future); + returnValue: _i20.Future.value(), + returnValueForMissingStub: _i20.Future.value(), + ) as _i20.Future); @override - _i19.Future fullRescan( + _i20.Future fullRescan( int? maxUnusedAddressGap, int? maxNumberOfIndexesToCheck, ) => @@ -751,11 +764,11 @@ class MockManager extends _i1.Mock implements _i6.Manager { maxNumberOfIndexesToCheck, ], ), - returnValue: _i19.Future.value(), - returnValueForMissingStub: _i19.Future.value(), - ) as _i19.Future); + returnValue: _i20.Future.value(), + returnValueForMissingStub: _i20.Future.value(), + ) as _i20.Future); @override - _i19.Future<_i10.Amount> estimateFeeFor( + _i20.Future<_i10.Amount> estimateFeeFor( _i10.Amount? amount, int? feeRate, ) => @@ -767,7 +780,7 @@ class MockManager extends _i1.Mock implements _i6.Manager { feeRate, ], ), - returnValue: _i19.Future<_i10.Amount>.value(_FakeAmount_7( + returnValue: _i20.Future<_i10.Amount>.value(_FakeAmount_7( this, Invocation.method( #estimateFeeFor, @@ -777,26 +790,26 @@ class MockManager extends _i1.Mock implements _i6.Manager { ], ), )), - ) as _i19.Future<_i10.Amount>); + ) as _i20.Future<_i10.Amount>); @override - _i19.Future generateNewAddress() => (super.noSuchMethod( + _i20.Future generateNewAddress() => (super.noSuchMethod( Invocation.method( #generateNewAddress, [], ), - returnValue: _i19.Future.value(false), - ) as _i19.Future); + returnValue: _i20.Future.value(false), + ) as _i20.Future); @override - _i19.Future resetRescanOnOpen() => (super.noSuchMethod( + _i20.Future resetRescanOnOpen() => (super.noSuchMethod( Invocation.method( #resetRescanOnOpen, [], ), - returnValue: _i19.Future.value(), - returnValueForMissingStub: _i19.Future.value(), - ) as _i19.Future); + returnValue: _i20.Future.value(), + returnValueForMissingStub: _i20.Future.value(), + ) as _i20.Future); @override - void addListener(_i21.VoidCallback? listener) => super.noSuchMethod( + void addListener(_i22.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #addListener, [listener], @@ -804,7 +817,7 @@ class MockManager extends _i1.Mock implements _i6.Manager { returnValueForMissingStub: null, ); @override - void removeListener(_i21.VoidCallback? listener) => super.noSuchMethod( + void removeListener(_i22.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #removeListener, [listener], @@ -839,10 +852,10 @@ class MockCoinServiceAPI extends _i1.Mock implements _i7.CoinServiceAPI { returnValueForMissingStub: null, ); @override - _i18.Coin get coin => (super.noSuchMethod( + _i19.Coin get coin => (super.noSuchMethod( Invocation.getter(#coin), - returnValue: _i18.Coin.bitcoin, - ) as _i18.Coin); + returnValue: _i19.Coin.bitcoin, + ) as _i19.Coin); @override bool get isRefreshing => (super.noSuchMethod( Invocation.getter(#isRefreshing), @@ -875,23 +888,23 @@ class MockCoinServiceAPI extends _i1.Mock implements _i7.CoinServiceAPI { returnValueForMissingStub: null, ); @override - _i19.Future<_i8.FeeObject> get fees => (super.noSuchMethod( + _i20.Future<_i8.FeeObject> get fees => (super.noSuchMethod( Invocation.getter(#fees), - returnValue: _i19.Future<_i8.FeeObject>.value(_FakeFeeObject_5( + returnValue: _i20.Future<_i8.FeeObject>.value(_FakeFeeObject_5( this, Invocation.getter(#fees), )), - ) as _i19.Future<_i8.FeeObject>); + ) as _i20.Future<_i8.FeeObject>); @override - _i19.Future get maxFee => (super.noSuchMethod( + _i20.Future get maxFee => (super.noSuchMethod( Invocation.getter(#maxFee), - returnValue: _i19.Future.value(0), - ) as _i19.Future); + returnValue: _i20.Future.value(0), + ) as _i20.Future); @override - _i19.Future get currentReceivingAddress => (super.noSuchMethod( + _i20.Future get currentReceivingAddress => (super.noSuchMethod( Invocation.getter(#currentReceivingAddress), - returnValue: _i19.Future.value(''), - ) as _i19.Future); + returnValue: _i20.Future.value(''), + ) as _i20.Future); @override _i9.Balance get balance => (super.noSuchMethod( Invocation.getter(#balance), @@ -901,16 +914,16 @@ class MockCoinServiceAPI extends _i1.Mock implements _i7.CoinServiceAPI { ), ) as _i9.Balance); @override - _i19.Future> get transactions => (super.noSuchMethod( + _i20.Future> get transactions => (super.noSuchMethod( Invocation.getter(#transactions), returnValue: - _i19.Future>.value(<_i22.Transaction>[]), - ) as _i19.Future>); + _i20.Future>.value(<_i23.Transaction>[]), + ) as _i20.Future>); @override - _i19.Future> get utxos => (super.noSuchMethod( + _i20.Future> get utxos => (super.noSuchMethod( Invocation.getter(#utxos), - returnValue: _i19.Future>.value(<_i22.UTXO>[]), - ) as _i19.Future>); + returnValue: _i20.Future>.value(<_i23.UTXO>[]), + ) as _i20.Future>); @override set walletName(String? newName) => super.noSuchMethod( Invocation.setter( @@ -930,20 +943,20 @@ class MockCoinServiceAPI extends _i1.Mock implements _i7.CoinServiceAPI { returnValue: '', ) as String); @override - _i19.Future> get mnemonic => (super.noSuchMethod( + _i20.Future> get mnemonic => (super.noSuchMethod( Invocation.getter(#mnemonic), - returnValue: _i19.Future>.value([]), - ) as _i19.Future>); + returnValue: _i20.Future>.value([]), + ) as _i20.Future>); @override - _i19.Future get mnemonicString => (super.noSuchMethod( + _i20.Future get mnemonicString => (super.noSuchMethod( Invocation.getter(#mnemonicString), - returnValue: _i19.Future.value(), - ) as _i19.Future); + returnValue: _i20.Future.value(), + ) as _i20.Future); @override - _i19.Future get mnemonicPassphrase => (super.noSuchMethod( + _i20.Future get mnemonicPassphrase => (super.noSuchMethod( Invocation.getter(#mnemonicPassphrase), - returnValue: _i19.Future.value(), - ) as _i19.Future); + returnValue: _i20.Future.value(), + ) as _i20.Future); @override bool get hasCalledExit => (super.noSuchMethod( Invocation.getter(#hasCalledExit), @@ -960,7 +973,7 @@ class MockCoinServiceAPI extends _i1.Mock implements _i7.CoinServiceAPI { returnValue: 0, ) as int); @override - _i19.Future> prepareSend({ + _i20.Future> prepareSend({ required String? address, required _i10.Amount? amount, Map? args, @@ -976,36 +989,36 @@ class MockCoinServiceAPI extends _i1.Mock implements _i7.CoinServiceAPI { }, ), returnValue: - _i19.Future>.value({}), - ) as _i19.Future>); + _i20.Future>.value({}), + ) as _i20.Future>); @override - _i19.Future confirmSend({required Map? txData}) => + _i20.Future confirmSend({required Map? txData}) => (super.noSuchMethod( Invocation.method( #confirmSend, [], {#txData: txData}, ), - returnValue: _i19.Future.value(''), - ) as _i19.Future); + returnValue: _i20.Future.value(''), + ) as _i20.Future); @override - _i19.Future refresh() => (super.noSuchMethod( + _i20.Future refresh() => (super.noSuchMethod( Invocation.method( #refresh, [], ), - returnValue: _i19.Future.value(), - returnValueForMissingStub: _i19.Future.value(), - ) as _i19.Future); + returnValue: _i20.Future.value(), + returnValueForMissingStub: _i20.Future.value(), + ) as _i20.Future); @override - _i19.Future updateNode(bool? shouldRefresh) => (super.noSuchMethod( + _i20.Future updateNode(bool? shouldRefresh) => (super.noSuchMethod( Invocation.method( #updateNode, [shouldRefresh], ), - returnValue: _i19.Future.value(), - returnValueForMissingStub: _i19.Future.value(), - ) as _i19.Future); + returnValue: _i20.Future.value(), + returnValueForMissingStub: _i20.Future.value(), + ) as _i20.Future); @override bool validateAddress(String? address) => (super.noSuchMethod( Invocation.method( @@ -1015,15 +1028,15 @@ class MockCoinServiceAPI extends _i1.Mock implements _i7.CoinServiceAPI { returnValue: false, ) as bool); @override - _i19.Future testNetworkConnection() => (super.noSuchMethod( + _i20.Future testNetworkConnection() => (super.noSuchMethod( Invocation.method( #testNetworkConnection, [], ), - returnValue: _i19.Future.value(false), - ) as _i19.Future); + returnValue: _i20.Future.value(false), + ) as _i20.Future); @override - _i19.Future recoverFromMnemonic({ + _i20.Future recoverFromMnemonic({ required String? mnemonic, String? mnemonicPassphrase, required int? maxUnusedAddressGap, @@ -1042,38 +1055,40 @@ class MockCoinServiceAPI extends _i1.Mock implements _i7.CoinServiceAPI { #height: height, }, ), - returnValue: _i19.Future.value(), - returnValueForMissingStub: _i19.Future.value(), - ) as _i19.Future); + returnValue: _i20.Future.value(), + returnValueForMissingStub: _i20.Future.value(), + ) as _i20.Future); @override - _i19.Future initializeNew() => (super.noSuchMethod( + _i20.Future initializeNew( + ({String mnemonicPassphrase, int wordCount})? data) => + (super.noSuchMethod( Invocation.method( #initializeNew, - [], + [data], ), - returnValue: _i19.Future.value(), - returnValueForMissingStub: _i19.Future.value(), - ) as _i19.Future); + returnValue: _i20.Future.value(), + returnValueForMissingStub: _i20.Future.value(), + ) as _i20.Future); @override - _i19.Future initializeExisting() => (super.noSuchMethod( + _i20.Future initializeExisting() => (super.noSuchMethod( Invocation.method( #initializeExisting, [], ), - returnValue: _i19.Future.value(), - returnValueForMissingStub: _i19.Future.value(), - ) as _i19.Future); + returnValue: _i20.Future.value(), + returnValueForMissingStub: _i20.Future.value(), + ) as _i20.Future); @override - _i19.Future exit() => (super.noSuchMethod( + _i20.Future exit() => (super.noSuchMethod( Invocation.method( #exit, [], ), - returnValue: _i19.Future.value(), - returnValueForMissingStub: _i19.Future.value(), - ) as _i19.Future); + returnValue: _i20.Future.value(), + returnValueForMissingStub: _i20.Future.value(), + ) as _i20.Future); @override - _i19.Future fullRescan( + _i20.Future fullRescan( int? maxUnusedAddressGap, int? maxNumberOfIndexesToCheck, ) => @@ -1085,11 +1100,11 @@ class MockCoinServiceAPI extends _i1.Mock implements _i7.CoinServiceAPI { maxNumberOfIndexesToCheck, ], ), - returnValue: _i19.Future.value(), - returnValueForMissingStub: _i19.Future.value(), - ) as _i19.Future); + returnValue: _i20.Future.value(), + returnValueForMissingStub: _i20.Future.value(), + ) as _i20.Future); @override - _i19.Future<_i10.Amount> estimateFeeFor( + _i20.Future<_i10.Amount> estimateFeeFor( _i10.Amount? amount, int? feeRate, ) => @@ -1101,7 +1116,7 @@ class MockCoinServiceAPI extends _i1.Mock implements _i7.CoinServiceAPI { feeRate, ], ), - returnValue: _i19.Future<_i10.Amount>.value(_FakeAmount_7( + returnValue: _i20.Future<_i10.Amount>.value(_FakeAmount_7( this, Invocation.method( #estimateFeeFor, @@ -1111,37 +1126,37 @@ class MockCoinServiceAPI extends _i1.Mock implements _i7.CoinServiceAPI { ], ), )), - ) as _i19.Future<_i10.Amount>); + ) as _i20.Future<_i10.Amount>); @override - _i19.Future generateNewAddress() => (super.noSuchMethod( + _i20.Future generateNewAddress() => (super.noSuchMethod( Invocation.method( #generateNewAddress, [], ), - returnValue: _i19.Future.value(false), - ) as _i19.Future); + returnValue: _i20.Future.value(false), + ) as _i20.Future); @override - _i19.Future updateSentCachedTxData(Map? txData) => + _i20.Future updateSentCachedTxData(Map? txData) => (super.noSuchMethod( Invocation.method( #updateSentCachedTxData, [txData], ), - returnValue: _i19.Future.value(), - returnValueForMissingStub: _i19.Future.value(), - ) as _i19.Future); + returnValue: _i20.Future.value(), + returnValueForMissingStub: _i20.Future.value(), + ) as _i20.Future); } /// A class which mocks [FiroWallet]. /// /// See the documentation for Mockito's code generation for more information. -class MockFiroWallet extends _i1.Mock implements _i23.FiroWallet { +class MockFiroWallet extends _i1.Mock implements _i24.FiroWallet { MockFiroWallet() { _i1.throwOnMissingStub(this); } @override - set timer(_i19.Timer? _timer) => super.noSuchMethod( + set timer(_i20.Timer? _timer) => super.noSuchMethod( Invocation.setter( #timer, _timer, @@ -1231,48 +1246,48 @@ class MockFiroWallet extends _i1.Mock implements _i23.FiroWallet { returnValue: false, ) as bool); @override - _i18.Coin get coin => (super.noSuchMethod( + _i19.Coin get coin => (super.noSuchMethod( Invocation.getter(#coin), - returnValue: _i18.Coin.bitcoin, - ) as _i18.Coin); + returnValue: _i19.Coin.bitcoin, + ) as _i19.Coin); @override - _i19.Future> get mnemonic => (super.noSuchMethod( + _i20.Future> get mnemonic => (super.noSuchMethod( Invocation.getter(#mnemonic), - returnValue: _i19.Future>.value([]), - ) as _i19.Future>); + returnValue: _i20.Future>.value([]), + ) as _i20.Future>); @override - _i19.Future get mnemonicString => (super.noSuchMethod( + _i20.Future get mnemonicString => (super.noSuchMethod( Invocation.getter(#mnemonicString), - returnValue: _i19.Future.value(), - ) as _i19.Future); + returnValue: _i20.Future.value(), + ) as _i20.Future); @override - _i19.Future get mnemonicPassphrase => (super.noSuchMethod( + _i20.Future get mnemonicPassphrase => (super.noSuchMethod( Invocation.getter(#mnemonicPassphrase), - returnValue: _i19.Future.value(), - ) as _i19.Future); + returnValue: _i20.Future.value(), + ) as _i20.Future); @override - _i19.Future get maxFee => (super.noSuchMethod( + _i20.Future get maxFee => (super.noSuchMethod( Invocation.getter(#maxFee), - returnValue: _i19.Future.value(0), - ) as _i19.Future); + returnValue: _i20.Future.value(0), + ) as _i20.Future); @override - _i19.Future<_i8.FeeObject> get fees => (super.noSuchMethod( + _i20.Future<_i8.FeeObject> get fees => (super.noSuchMethod( Invocation.getter(#fees), - returnValue: _i19.Future<_i8.FeeObject>.value(_FakeFeeObject_5( + returnValue: _i20.Future<_i8.FeeObject>.value(_FakeFeeObject_5( this, Invocation.getter(#fees), )), - ) as _i19.Future<_i8.FeeObject>); + ) as _i20.Future<_i8.FeeObject>); @override - _i19.Future get currentReceivingAddress => (super.noSuchMethod( + _i20.Future get currentReceivingAddress => (super.noSuchMethod( Invocation.getter(#currentReceivingAddress), - returnValue: _i19.Future.value(''), - ) as _i19.Future); + returnValue: _i20.Future.value(''), + ) as _i20.Future); @override - _i19.Future get currentChangeAddress => (super.noSuchMethod( + _i20.Future get currentChangeAddress => (super.noSuchMethod( Invocation.getter(#currentChangeAddress), - returnValue: _i19.Future.value(''), - ) as _i19.Future); + returnValue: _i20.Future.value(''), + ) as _i20.Future); @override String get walletName => (super.noSuchMethod( Invocation.getter(#walletName), @@ -1313,6 +1328,11 @@ class MockFiroWallet extends _i1.Mock implements _i23.FiroWallet { ), ) as _i13.CachedElectrumX); @override + bool get lelantusCoinIsarRescanRequired => (super.noSuchMethod( + Invocation.getter(#lelantusCoinIsarRescanRequired), + returnValue: false, + ) as bool); + @override bool get isRefreshing => (super.noSuchMethod( Invocation.getter(#isRefreshing), returnValue: false, @@ -1323,10 +1343,10 @@ class MockFiroWallet extends _i1.Mock implements _i23.FiroWallet { returnValue: false, ) as bool); @override - _i19.Future get chainHeight => (super.noSuchMethod( + _i20.Future get chainHeight => (super.noSuchMethod( Invocation.getter(#chainHeight), - returnValue: _i19.Future.value(0), - ) as _i19.Future); + returnValue: _i20.Future.value(0), + ) as _i20.Future); @override int get storedChainHeight => (super.noSuchMethod( Invocation.getter(#storedChainHeight), @@ -1349,21 +1369,21 @@ class MockFiroWallet extends _i1.Mock implements _i23.FiroWallet { ), ) as _i9.Balance); @override - _i19.Future> get utxos => (super.noSuchMethod( + _i20.Future> get utxos => (super.noSuchMethod( Invocation.getter(#utxos), - returnValue: _i19.Future>.value(<_i22.UTXO>[]), - ) as _i19.Future>); + returnValue: _i20.Future>.value(<_i23.UTXO>[]), + ) as _i20.Future>); @override - _i19.Future> get transactions => (super.noSuchMethod( + _i20.Future> get transactions => (super.noSuchMethod( Invocation.getter(#transactions), returnValue: - _i19.Future>.value(<_i22.Transaction>[]), - ) as _i19.Future>); + _i20.Future>.value(<_i23.Transaction>[]), + ) as _i20.Future>); @override - _i19.Future get xpub => (super.noSuchMethod( + _i20.Future get xpub => (super.noSuchMethod( Invocation.getter(#xpub), - returnValue: _i19.Future.value(''), - ) as _i19.Future); + returnValue: _i20.Future.value(''), + ) as _i20.Future); @override set onIsActiveWalletChanged(void Function(bool)? _onIsActiveWalletChanged) => super.noSuchMethod( @@ -1390,23 +1410,23 @@ class MockFiroWallet extends _i1.Mock implements _i23.FiroWallet { returnValue: false, ) as bool); @override - _i19.Future updateSentCachedTxData(Map? txData) => + _i20.Future updateSentCachedTxData(Map? txData) => (super.noSuchMethod( Invocation.method( #updateSentCachedTxData, [txData], ), - returnValue: _i19.Future.value(), - returnValueForMissingStub: _i19.Future.value(), - ) as _i19.Future); + returnValue: _i20.Future.value(), + returnValueForMissingStub: _i20.Future.value(), + ) as _i20.Future); @override - _i19.Future testNetworkConnection() => (super.noSuchMethod( + _i20.Future testNetworkConnection() => (super.noSuchMethod( Invocation.method( #testNetworkConnection, [], ), - returnValue: _i19.Future.value(false), - ) as _i19.Future); + returnValue: _i20.Future.value(false), + ) as _i20.Future); @override void startNetworkAlivePinging() => super.noSuchMethod( Invocation.method( @@ -1424,7 +1444,7 @@ class MockFiroWallet extends _i1.Mock implements _i23.FiroWallet { returnValueForMissingStub: null, ); @override - _i19.Future> prepareSendPublic({ + _i20.Future> prepareSendPublic({ required String? address, required _i10.Amount? amount, Map? args, @@ -1440,20 +1460,20 @@ class MockFiroWallet extends _i1.Mock implements _i23.FiroWallet { }, ), returnValue: - _i19.Future>.value({}), - ) as _i19.Future>); + _i20.Future>.value({}), + ) as _i20.Future>); @override - _i19.Future confirmSendPublic({dynamic txData}) => + _i20.Future confirmSendPublic({dynamic txData}) => (super.noSuchMethod( Invocation.method( #confirmSendPublic, [], {#txData: txData}, ), - returnValue: _i19.Future.value(''), - ) as _i19.Future); + returnValue: _i20.Future.value(''), + ) as _i20.Future); @override - _i19.Future> prepareSend({ + _i20.Future> prepareSend({ required String? address, required _i10.Amount? amount, Map? args, @@ -1469,18 +1489,18 @@ class MockFiroWallet extends _i1.Mock implements _i23.FiroWallet { }, ), returnValue: - _i19.Future>.value({}), - ) as _i19.Future>); + _i20.Future>.value({}), + ) as _i20.Future>); @override - _i19.Future confirmSend({required Map? txData}) => + _i20.Future confirmSend({required Map? txData}) => (super.noSuchMethod( Invocation.method( #confirmSend, [], {#txData: txData}, ), - returnValue: _i19.Future.value(''), - ) as _i19.Future); + returnValue: _i20.Future.value(''), + ) as _i20.Future); @override int estimateTxFee({ required int? vSize, @@ -1505,7 +1525,7 @@ class MockFiroWallet extends _i1.Mock implements _i23.FiroWallet { bool? isSendAll, { int? satsPerVByte, int? additionalOutputs = 0, - List<_i22.UTXO>? utxos, + List<_i23.UTXO>? utxos, }) => super.noSuchMethod(Invocation.method( #coinSelection, @@ -1522,19 +1542,19 @@ class MockFiroWallet extends _i1.Mock implements _i23.FiroWallet { }, )); @override - _i19.Future> fetchBuildTxData( - List<_i22.UTXO>? utxosToUse) => + _i20.Future> fetchBuildTxData( + List<_i23.UTXO>? utxosToUse) => (super.noSuchMethod( Invocation.method( #fetchBuildTxData, [utxosToUse], ), returnValue: - _i19.Future>.value(<_i24.SigningData>[]), - ) as _i19.Future>); + _i20.Future>.value(<_i25.SigningData>[]), + ) as _i20.Future>); @override - _i19.Future> buildTransaction({ - required List<_i24.SigningData>? utxoSigningData, + _i20.Future> buildTransaction({ + required List<_i25.SigningData>? utxoSigningData, required List? recipients, required List? satoshiAmounts, }) => @@ -1549,91 +1569,111 @@ class MockFiroWallet extends _i1.Mock implements _i23.FiroWallet { }, ), returnValue: - _i19.Future>.value({}), - ) as _i19.Future>); + _i20.Future>.value({}), + ) as _i20.Future>); @override - _i19.Future updateNode(bool? shouldRefresh) => (super.noSuchMethod( + _i20.Future updateNode(bool? shouldRefresh) => (super.noSuchMethod( Invocation.method( #updateNode, [shouldRefresh], ), - returnValue: _i19.Future.value(), - returnValueForMissingStub: _i19.Future.value(), - ) as _i19.Future); + returnValue: _i20.Future.value(), + returnValueForMissingStub: _i20.Future.value(), + ) as _i20.Future); @override - _i19.Future initializeNew() => (super.noSuchMethod( + _i20.Future initializeNew( + ({String mnemonicPassphrase, int wordCount})? data) => + (super.noSuchMethod( Invocation.method( #initializeNew, + [data], + ), + returnValue: _i20.Future.value(), + returnValueForMissingStub: _i20.Future.value(), + ) as _i20.Future); + @override + _i20.Future setLelantusCoinIsarRescanRequiredDone() => + (super.noSuchMethod( + Invocation.method( + #setLelantusCoinIsarRescanRequiredDone, [], ), - returnValue: _i19.Future.value(), - returnValueForMissingStub: _i19.Future.value(), - ) as _i19.Future); + returnValue: _i20.Future.value(), + returnValueForMissingStub: _i20.Future.value(), + ) as _i20.Future); @override - _i19.Future initializeExisting() => (super.noSuchMethod( + _i20.Future firoRescanRecovery() => (super.noSuchMethod( + Invocation.method( + #firoRescanRecovery, + [], + ), + returnValue: _i20.Future.value(false), + ) as _i20.Future); + @override + _i20.Future initializeExisting() => (super.noSuchMethod( Invocation.method( #initializeExisting, [], ), - returnValue: _i19.Future.value(), - returnValueForMissingStub: _i19.Future.value(), - ) as _i19.Future); + returnValue: _i20.Future.value(), + returnValueForMissingStub: _i20.Future.value(), + ) as _i20.Future); @override - _i19.Future refreshIfThereIsNewData() => (super.noSuchMethod( + _i20.Future refreshIfThereIsNewData() => (super.noSuchMethod( Invocation.method( #refreshIfThereIsNewData, [], ), - returnValue: _i19.Future.value(false), - ) as _i19.Future); + returnValue: _i20.Future.value(false), + ) as _i20.Future); @override - _i19.Future getAllTxsToWatch() => (super.noSuchMethod( + _i20.Future getAllTxsToWatch() => (super.noSuchMethod( Invocation.method( #getAllTxsToWatch, [], ), - returnValue: _i19.Future.value(), - returnValueForMissingStub: _i19.Future.value(), - ) as _i19.Future); + returnValue: _i20.Future.value(), + returnValueForMissingStub: _i20.Future.value(), + ) as _i20.Future); @override - _i19.Future refresh() => (super.noSuchMethod( + _i20.Future refresh() => (super.noSuchMethod( Invocation.method( #refresh, [], ), - returnValue: _i19.Future.value(), - returnValueForMissingStub: _i19.Future.value(), - ) as _i19.Future); + returnValue: _i20.Future.value(), + returnValueForMissingStub: _i20.Future.value(), + ) as _i20.Future); @override - _i19.Future anonymizeAllPublicFunds() => (super.noSuchMethod( + _i20.Future anonymizeAllPublicFunds() => (super.noSuchMethod( Invocation.method( #anonymizeAllPublicFunds, [], ), - returnValue: _i19.Future.value(), - returnValueForMissingStub: _i19.Future.value(), - ) as _i19.Future); + returnValue: _i20.Future.value(), + returnValueForMissingStub: _i20.Future.value(), + ) as _i20.Future); @override - _i19.Future>> createMintsFromAmount(int? total) => + _i20.Future>> createMintsFromAmount(int? total) => (super.noSuchMethod( Invocation.method( #createMintsFromAmount, [total], ), - returnValue: _i19.Future>>.value( + returnValue: _i20.Future>>.value( >[]), - ) as _i19.Future>>); + ) as _i20.Future>>); @override - _i19.Future submitHexToNetwork(String? hex) => (super.noSuchMethod( + _i20.Future submitHexToNetwork(String? hex) => (super.noSuchMethod( Invocation.method( #submitHexToNetwork, [hex], ), - returnValue: _i19.Future.value(''), - ) as _i19.Future); + returnValue: _i20.Future.value(''), + ) as _i20.Future); @override - _i19.Future> buildMintTransaction( - List<_i22.UTXO>? utxosToUse, + _i20.Future> buildMintTransaction( + List<_i23.UTXO>? utxosToUse, int? satoshisPerRecipient, List>? mintsMap, ) => @@ -1647,29 +1687,29 @@ class MockFiroWallet extends _i1.Mock implements _i23.FiroWallet { ], ), returnValue: - _i19.Future>.value({}), - ) as _i19.Future>); + _i20.Future>.value({}), + ) as _i20.Future>); @override - _i19.Future checkReceivingAddressForTransactions() => + _i20.Future checkReceivingAddressForTransactions() => (super.noSuchMethod( Invocation.method( #checkReceivingAddressForTransactions, [], ), - returnValue: _i19.Future.value(), - returnValueForMissingStub: _i19.Future.value(), - ) as _i19.Future); + returnValue: _i20.Future.value(), + returnValueForMissingStub: _i20.Future.value(), + ) as _i20.Future); @override - _i19.Future checkChangeAddressForTransactions() => (super.noSuchMethod( + _i20.Future checkChangeAddressForTransactions() => (super.noSuchMethod( Invocation.method( #checkChangeAddressForTransactions, [], ), - returnValue: _i19.Future.value(), - returnValueForMissingStub: _i19.Future.value(), - ) as _i19.Future); + returnValue: _i20.Future.value(), + returnValueForMissingStub: _i20.Future.value(), + ) as _i20.Future); @override - _i19.Future fullRescan( + _i20.Future fullRescan( int? maxUnusedAddressGap, int? maxNumberOfIndexesToCheck, ) => @@ -1681,11 +1721,11 @@ class MockFiroWallet extends _i1.Mock implements _i23.FiroWallet { maxNumberOfIndexesToCheck, ], ), - returnValue: _i19.Future.value(), - returnValueForMissingStub: _i19.Future.value(), - ) as _i19.Future); + returnValue: _i20.Future.value(), + returnValueForMissingStub: _i20.Future.value(), + ) as _i20.Future); @override - _i19.Future recoverFromMnemonic({ + _i20.Future recoverFromMnemonic({ required String? mnemonic, String? mnemonicPassphrase, required int? maxUnusedAddressGap, @@ -1704,74 +1744,74 @@ class MockFiroWallet extends _i1.Mock implements _i23.FiroWallet { #height: height, }, ), - returnValue: _i19.Future.value(), - returnValueForMissingStub: _i19.Future.value(), - ) as _i19.Future); + returnValue: _i20.Future.value(), + returnValueForMissingStub: _i20.Future.value(), + ) as _i20.Future); @override - _i19.Future> getSetDataMap(int? latestSetId) => + _i20.Future> getSetDataMap(int? latestSetId) => (super.noSuchMethod( Invocation.method( #getSetDataMap, [latestSetId], ), - returnValue: _i19.Future>.value({}), - ) as _i19.Future>); + returnValue: _i20.Future>.value({}), + ) as _i20.Future>); @override - _i19.Future getTransactionCacheEarly(List? allAddresses) => + _i20.Future getTransactionCacheEarly(List? allAddresses) => (super.noSuchMethod( Invocation.method( #getTransactionCacheEarly, [allAddresses], ), - returnValue: _i19.Future.value(), - returnValueForMissingStub: _i19.Future.value(), - ) as _i19.Future); + returnValue: _i20.Future.value(), + returnValueForMissingStub: _i20.Future.value(), + ) as _i20.Future); @override - _i19.Future>> fetchAnonymitySets() => + _i20.Future>> fetchAnonymitySets() => (super.noSuchMethod( Invocation.method( #fetchAnonymitySets, [], ), - returnValue: _i19.Future>>.value( + returnValue: _i20.Future>>.value( >[]), - ) as _i19.Future>>); + ) as _i20.Future>>); @override - _i19.Future getLatestSetId() => (super.noSuchMethod( + _i20.Future getLatestSetId() => (super.noSuchMethod( Invocation.method( #getLatestSetId, [], ), - returnValue: _i19.Future.value(0), - ) as _i19.Future); + returnValue: _i20.Future.value(0), + ) as _i20.Future); @override - _i19.Future> getUsedCoinSerials() => (super.noSuchMethod( + _i20.Future> getUsedCoinSerials() => (super.noSuchMethod( Invocation.method( #getUsedCoinSerials, [], ), - returnValue: _i19.Future>.value([]), - ) as _i19.Future>); + returnValue: _i20.Future>.value([]), + ) as _i20.Future>); @override - _i19.Future exit() => (super.noSuchMethod( + _i20.Future exit() => (super.noSuchMethod( Invocation.method( #exit, [], ), - returnValue: _i19.Future.value(), - returnValueForMissingStub: _i19.Future.value(), - ) as _i19.Future); + returnValue: _i20.Future.value(), + returnValueForMissingStub: _i20.Future.value(), + ) as _i20.Future); @override - _i19.Future estimateJoinSplitFee(int? spendAmount) => + _i20.Future estimateJoinSplitFee(int? spendAmount) => (super.noSuchMethod( Invocation.method( #estimateJoinSplitFee, [spendAmount], ), - returnValue: _i19.Future.value(0), - ) as _i19.Future); + returnValue: _i20.Future.value(0), + ) as _i20.Future); @override - _i19.Future<_i10.Amount> estimateFeeFor( + _i20.Future<_i10.Amount> estimateFeeFor( _i10.Amount? amount, int? feeRate, ) => @@ -1783,7 +1823,7 @@ class MockFiroWallet extends _i1.Mock implements _i23.FiroWallet { feeRate, ], ), - returnValue: _i19.Future<_i10.Amount>.value(_FakeAmount_7( + returnValue: _i20.Future<_i10.Amount>.value(_FakeAmount_7( this, Invocation.method( #estimateFeeFor, @@ -1793,9 +1833,9 @@ class MockFiroWallet extends _i1.Mock implements _i23.FiroWallet { ], ), )), - ) as _i19.Future<_i10.Amount>); + ) as _i20.Future<_i10.Amount>); @override - _i19.Future<_i10.Amount> estimateFeeForPublic( + _i20.Future<_i10.Amount> estimateFeeForPublic( _i10.Amount? amount, int? feeRate, ) => @@ -1807,7 +1847,7 @@ class MockFiroWallet extends _i1.Mock implements _i23.FiroWallet { feeRate, ], ), - returnValue: _i19.Future<_i10.Amount>.value(_FakeAmount_7( + returnValue: _i20.Future<_i10.Amount>.value(_FakeAmount_7( this, Invocation.method( #estimateFeeForPublic, @@ -1817,7 +1857,7 @@ class MockFiroWallet extends _i1.Mock implements _i23.FiroWallet { ], ), )), - ) as _i19.Future<_i10.Amount>); + ) as _i20.Future<_i10.Amount>); @override _i10.Amount roughFeeEstimate( int? inputCount, @@ -1846,36 +1886,36 @@ class MockFiroWallet extends _i1.Mock implements _i23.FiroWallet { ), ) as _i10.Amount); @override - _i19.Future<_i10.Amount> sweepAllEstimate(int? feeRate) => + _i20.Future<_i10.Amount> sweepAllEstimate(int? feeRate) => (super.noSuchMethod( Invocation.method( #sweepAllEstimate, [feeRate], ), - returnValue: _i19.Future<_i10.Amount>.value(_FakeAmount_7( + returnValue: _i20.Future<_i10.Amount>.value(_FakeAmount_7( this, Invocation.method( #sweepAllEstimate, [feeRate], ), )), - ) as _i19.Future<_i10.Amount>); + ) as _i20.Future<_i10.Amount>); @override - _i19.Future>> fastFetch( + _i20.Future>> fastFetch( List? allTxHashes) => (super.noSuchMethod( Invocation.method( #fastFetch, [allTxHashes], ), - returnValue: _i19.Future>>.value( + returnValue: _i20.Future>>.value( >[]), - ) as _i19.Future>>); + ) as _i20.Future>>); @override - _i19.Future> getJMintTransactions( + _i20.Future> getJMintTransactions( _i13.CachedElectrumX? cachedClient, List? transactions, - _i18.Coin? coin, + _i19.Coin? coin, ) => (super.noSuchMethod( Invocation.method( @@ -1886,17 +1926,17 @@ class MockFiroWallet extends _i1.Mock implements _i23.FiroWallet { coin, ], ), - returnValue: _i19.Future>.value( - <_i22.Address, _i22.Transaction>{}), - ) as _i19.Future>); + returnValue: _i20.Future>.value( + <_i23.Address, _i23.Transaction>{}), + ) as _i20.Future>); @override - _i19.Future generateNewAddress() => (super.noSuchMethod( + _i20.Future generateNewAddress() => (super.noSuchMethod( Invocation.method( #generateNewAddress, [], ), - returnValue: _i19.Future.value(false), - ) as _i19.Future); + returnValue: _i20.Future.value(false), + ) as _i20.Future); @override _i10.Amount availablePrivateBalance() => (super.noSuchMethod( Invocation.method( @@ -1928,7 +1968,7 @@ class MockFiroWallet extends _i1.Mock implements _i23.FiroWallet { @override void initCache( String? walletId, - _i18.Coin? coin, + _i19.Coin? coin, ) => super.noSuchMethod( Invocation.method( @@ -1941,14 +1981,14 @@ class MockFiroWallet extends _i1.Mock implements _i23.FiroWallet { returnValueForMissingStub: null, ); @override - _i19.Future updateCachedId(String? id) => (super.noSuchMethod( + _i20.Future updateCachedId(String? id) => (super.noSuchMethod( Invocation.method( #updateCachedId, [id], ), - returnValue: _i19.Future.value(), - returnValueForMissingStub: _i19.Future.value(), - ) as _i19.Future); + returnValue: _i20.Future.value(), + returnValueForMissingStub: _i20.Future.value(), + ) as _i20.Future); @override int getCachedChainHeight() => (super.noSuchMethod( Invocation.method( @@ -1958,14 +1998,14 @@ class MockFiroWallet extends _i1.Mock implements _i23.FiroWallet { returnValue: 0, ) as int); @override - _i19.Future updateCachedChainHeight(int? height) => (super.noSuchMethod( + _i20.Future updateCachedChainHeight(int? height) => (super.noSuchMethod( Invocation.method( #updateCachedChainHeight, [height], ), - returnValue: _i19.Future.value(), - returnValueForMissingStub: _i19.Future.value(), - ) as _i19.Future); + returnValue: _i20.Future.value(), + returnValueForMissingStub: _i20.Future.value(), + ) as _i20.Future); @override bool getCachedIsFavorite() => (super.noSuchMethod( Invocation.method( @@ -1975,15 +2015,15 @@ class MockFiroWallet extends _i1.Mock implements _i23.FiroWallet { returnValue: false, ) as bool); @override - _i19.Future updateCachedIsFavorite(bool? isFavorite) => + _i20.Future updateCachedIsFavorite(bool? isFavorite) => (super.noSuchMethod( Invocation.method( #updateCachedIsFavorite, [isFavorite], ), - returnValue: _i19.Future.value(), - returnValueForMissingStub: _i19.Future.value(), - ) as _i19.Future); + returnValue: _i20.Future.value(), + returnValueForMissingStub: _i20.Future.value(), + ) as _i20.Future); @override _i9.Balance getCachedBalance() => (super.noSuchMethod( Invocation.method( @@ -1999,15 +2039,15 @@ class MockFiroWallet extends _i1.Mock implements _i23.FiroWallet { ), ) as _i9.Balance); @override - _i19.Future updateCachedBalance(_i9.Balance? balance) => + _i20.Future updateCachedBalance(_i9.Balance? balance) => (super.noSuchMethod( Invocation.method( #updateCachedBalance, [balance], ), - returnValue: _i19.Future.value(), - returnValueForMissingStub: _i19.Future.value(), - ) as _i19.Future); + returnValue: _i20.Future.value(), + returnValueForMissingStub: _i20.Future.value(), + ) as _i20.Future); @override _i9.Balance getCachedBalanceSecondary() => (super.noSuchMethod( Invocation.method( @@ -2023,15 +2063,15 @@ class MockFiroWallet extends _i1.Mock implements _i23.FiroWallet { ), ) as _i9.Balance); @override - _i19.Future updateCachedBalanceSecondary(_i9.Balance? balance) => + _i20.Future updateCachedBalanceSecondary(_i9.Balance? balance) => (super.noSuchMethod( Invocation.method( #updateCachedBalanceSecondary, [balance], ), - returnValue: _i19.Future.value(), - returnValueForMissingStub: _i19.Future.value(), - ) as _i19.Future); + returnValue: _i20.Future.value(), + returnValueForMissingStub: _i20.Future.value(), + ) as _i20.Future); @override List getWalletTokenContractAddresses() => (super.noSuchMethod( Invocation.method( @@ -2041,16 +2081,16 @@ class MockFiroWallet extends _i1.Mock implements _i23.FiroWallet { returnValue: [], ) as List); @override - _i19.Future updateWalletTokenContractAddresses( + _i20.Future updateWalletTokenContractAddresses( List? contractAddresses) => (super.noSuchMethod( Invocation.method( #updateWalletTokenContractAddresses, [contractAddresses], ), - returnValue: _i19.Future.value(), - returnValueForMissingStub: _i19.Future.value(), - ) as _i19.Future); + returnValue: _i20.Future.value(), + returnValueForMissingStub: _i20.Future.value(), + ) as _i20.Future); @override void initWalletDB({_i14.MainDB? mockableOverride}) => super.noSuchMethod( Invocation.method( @@ -2065,7 +2105,7 @@ class MockFiroWallet extends _i1.Mock implements _i23.FiroWallet { /// A class which mocks [LocaleService]. /// /// See the documentation for Mockito's code generation for more information. -class MockLocaleService extends _i1.Mock implements _i25.LocaleService { +class MockLocaleService extends _i1.Mock implements _i26.LocaleService { MockLocaleService() { _i1.throwOnMissingStub(this); } @@ -2081,17 +2121,17 @@ class MockLocaleService extends _i1.Mock implements _i25.LocaleService { returnValue: false, ) as bool); @override - _i19.Future loadLocale({bool? notify = true}) => (super.noSuchMethod( + _i20.Future loadLocale({bool? notify = true}) => (super.noSuchMethod( Invocation.method( #loadLocale, [], {#notify: notify}, ), - returnValue: _i19.Future.value(), - returnValueForMissingStub: _i19.Future.value(), - ) as _i19.Future); + returnValue: _i20.Future.value(), + returnValueForMissingStub: _i20.Future.value(), + ) as _i20.Future); @override - void addListener(_i21.VoidCallback? listener) => super.noSuchMethod( + void addListener(_i22.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #addListener, [listener], @@ -2099,7 +2139,7 @@ class MockLocaleService extends _i1.Mock implements _i25.LocaleService { returnValueForMissingStub: null, ); @override - void removeListener(_i21.VoidCallback? listener) => super.noSuchMethod( + void removeListener(_i22.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #removeListener, [listener], @@ -2127,7 +2167,7 @@ class MockLocaleService extends _i1.Mock implements _i25.LocaleService { /// A class which mocks [Prefs]. /// /// See the documentation for Mockito's code generation for more information. -class MockPrefs extends _i1.Mock implements _i20.Prefs { +class MockPrefs extends _i1.Mock implements _i21.Prefs { MockPrefs() { _i1.throwOnMissingStub(this); } @@ -2183,12 +2223,12 @@ class MockPrefs extends _i1.Mock implements _i20.Prefs { returnValueForMissingStub: null, ); @override - _i26.SyncingType get syncType => (super.noSuchMethod( + _i27.SyncingType get syncType => (super.noSuchMethod( Invocation.getter(#syncType), - returnValue: _i26.SyncingType.currentWalletOnly, - ) as _i26.SyncingType); + returnValue: _i27.SyncingType.currentWalletOnly, + ) as _i27.SyncingType); @override - set syncType(_i26.SyncingType? syncType) => super.noSuchMethod( + set syncType(_i27.SyncingType? syncType) => super.noSuchMethod( Invocation.setter( #syncType, syncType, @@ -2300,6 +2340,19 @@ class MockPrefs extends _i1.Mock implements _i20.Prefs { returnValueForMissingStub: null, ); @override + bool get torKillSwitch => (super.noSuchMethod( + Invocation.getter(#torKillSwitch), + returnValue: false, + ) as bool); + @override + set torKillSwitch(bool? torKillswitch) => super.noSuchMethod( + Invocation.setter( + #torKillSwitch, + torKillswitch, + ), + returnValueForMissingStub: null, + ); + @override bool get showTestNetCoins => (super.noSuchMethod( Invocation.getter(#showTestNetCoins), returnValue: false, @@ -2334,12 +2387,12 @@ class MockPrefs extends _i1.Mock implements _i20.Prefs { returnValueForMissingStub: null, ); @override - _i27.BackupFrequencyType get backupFrequencyType => (super.noSuchMethod( + _i28.BackupFrequencyType get backupFrequencyType => (super.noSuchMethod( Invocation.getter(#backupFrequencyType), - returnValue: _i27.BackupFrequencyType.everyTenMinutes, - ) as _i27.BackupFrequencyType); + returnValue: _i28.BackupFrequencyType.everyTenMinutes, + ) as _i28.BackupFrequencyType); @override - set backupFrequencyType(_i27.BackupFrequencyType? backupFrequencyType) => + set backupFrequencyType(_i28.BackupFrequencyType? backupFrequencyType) => super.noSuchMethod( Invocation.setter( #backupFrequencyType, @@ -2472,66 +2525,79 @@ class MockPrefs extends _i1.Mock implements _i20.Prefs { returnValueForMissingStub: null, ); @override + bool get useTor => (super.noSuchMethod( + Invocation.getter(#useTor), + returnValue: false, + ) as bool); + @override + set useTor(bool? useTor) => super.noSuchMethod( + Invocation.setter( + #useTor, + useTor, + ), + returnValueForMissingStub: null, + ); + @override bool get hasListeners => (super.noSuchMethod( Invocation.getter(#hasListeners), returnValue: false, ) as bool); @override - _i19.Future init() => (super.noSuchMethod( + _i20.Future init() => (super.noSuchMethod( Invocation.method( #init, [], ), - returnValue: _i19.Future.value(), - returnValueForMissingStub: _i19.Future.value(), - ) as _i19.Future); + returnValue: _i20.Future.value(), + returnValueForMissingStub: _i20.Future.value(), + ) as _i20.Future); @override - _i19.Future incrementCurrentNotificationIndex() => (super.noSuchMethod( + _i20.Future incrementCurrentNotificationIndex() => (super.noSuchMethod( Invocation.method( #incrementCurrentNotificationIndex, [], ), - returnValue: _i19.Future.value(), - returnValueForMissingStub: _i19.Future.value(), - ) as _i19.Future); + returnValue: _i20.Future.value(), + returnValueForMissingStub: _i20.Future.value(), + ) as _i20.Future); @override - _i19.Future isExternalCallsSet() => (super.noSuchMethod( + _i20.Future isExternalCallsSet() => (super.noSuchMethod( Invocation.method( #isExternalCallsSet, [], ), - returnValue: _i19.Future.value(false), - ) as _i19.Future); + returnValue: _i20.Future.value(false), + ) as _i20.Future); @override - _i19.Future saveUserID(String? userId) => (super.noSuchMethod( + _i20.Future saveUserID(String? userId) => (super.noSuchMethod( Invocation.method( #saveUserID, [userId], ), - returnValue: _i19.Future.value(), - returnValueForMissingStub: _i19.Future.value(), - ) as _i19.Future); + returnValue: _i20.Future.value(), + returnValueForMissingStub: _i20.Future.value(), + ) as _i20.Future); @override - _i19.Future saveSignupEpoch(int? signupEpoch) => (super.noSuchMethod( + _i20.Future saveSignupEpoch(int? signupEpoch) => (super.noSuchMethod( Invocation.method( #saveSignupEpoch, [signupEpoch], ), - returnValue: _i19.Future.value(), - returnValueForMissingStub: _i19.Future.value(), - ) as _i19.Future); + returnValue: _i20.Future.value(), + returnValueForMissingStub: _i20.Future.value(), + ) as _i20.Future); @override - _i28.AmountUnit amountUnit(_i18.Coin? coin) => (super.noSuchMethod( + _i29.AmountUnit amountUnit(_i19.Coin? coin) => (super.noSuchMethod( Invocation.method( #amountUnit, [coin], ), - returnValue: _i28.AmountUnit.normal, - ) as _i28.AmountUnit); + returnValue: _i29.AmountUnit.normal, + ) as _i29.AmountUnit); @override void updateAmountUnit({ - required _i18.Coin? coin, - required _i28.AmountUnit? amountUnit, + required _i19.Coin? coin, + required _i29.AmountUnit? amountUnit, }) => super.noSuchMethod( Invocation.method( @@ -2545,7 +2611,7 @@ class MockPrefs extends _i1.Mock implements _i20.Prefs { returnValueForMissingStub: null, ); @override - int maxDecimals(_i18.Coin? coin) => (super.noSuchMethod( + int maxDecimals(_i19.Coin? coin) => (super.noSuchMethod( Invocation.method( #maxDecimals, [coin], @@ -2554,7 +2620,7 @@ class MockPrefs extends _i1.Mock implements _i20.Prefs { ) as int); @override void updateMaxDecimals({ - required _i18.Coin? coin, + required _i19.Coin? coin, required int? maxDecimals, }) => super.noSuchMethod( @@ -2569,7 +2635,7 @@ class MockPrefs extends _i1.Mock implements _i20.Prefs { returnValueForMissingStub: null, ); @override - void addListener(_i21.VoidCallback? listener) => super.noSuchMethod( + void addListener(_i22.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #addListener, [listener], @@ -2577,7 +2643,7 @@ class MockPrefs extends _i1.Mock implements _i20.Prefs { returnValueForMissingStub: null, ); @override - void removeListener(_i21.VoidCallback? listener) => super.noSuchMethod( + void removeListener(_i22.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #removeListener, [listener], @@ -2605,7 +2671,7 @@ class MockPrefs extends _i1.Mock implements _i20.Prefs { /// A class which mocks [PriceService]. /// /// See the documentation for Mockito's code generation for more information. -class MockPriceService extends _i1.Mock implements _i29.PriceService { +class MockPriceService extends _i1.Mock implements _i30.PriceService { MockPriceService() { _i1.throwOnMissingStub(this); } @@ -2642,44 +2708,44 @@ class MockPriceService extends _i1.Mock implements _i29.PriceService { returnValue: false, ) as bool); @override - _i15.Tuple2<_i30.Decimal, double> getPrice(_i18.Coin? coin) => + _i15.Tuple2<_i31.Decimal, double> getPrice(_i19.Coin? coin) => (super.noSuchMethod( Invocation.method( #getPrice, [coin], ), - returnValue: _FakeTuple2_13<_i30.Decimal, double>( + returnValue: _FakeTuple2_13<_i31.Decimal, double>( this, Invocation.method( #getPrice, [coin], ), ), - ) as _i15.Tuple2<_i30.Decimal, double>); + ) as _i15.Tuple2<_i31.Decimal, double>); @override - _i15.Tuple2<_i30.Decimal, double> getTokenPrice(String? contractAddress) => + _i15.Tuple2<_i31.Decimal, double> getTokenPrice(String? contractAddress) => (super.noSuchMethod( Invocation.method( #getTokenPrice, [contractAddress], ), - returnValue: _FakeTuple2_13<_i30.Decimal, double>( + returnValue: _FakeTuple2_13<_i31.Decimal, double>( this, Invocation.method( #getTokenPrice, [contractAddress], ), ), - ) as _i15.Tuple2<_i30.Decimal, double>); + ) as _i15.Tuple2<_i31.Decimal, double>); @override - _i19.Future updatePrice() => (super.noSuchMethod( + _i20.Future updatePrice() => (super.noSuchMethod( Invocation.method( #updatePrice, [], ), - returnValue: _i19.Future.value(), - returnValueForMissingStub: _i19.Future.value(), - ) as _i19.Future); + returnValue: _i20.Future.value(), + returnValueForMissingStub: _i20.Future.value(), + ) as _i20.Future); @override void cancel() => super.noSuchMethod( Invocation.method( @@ -2705,7 +2771,7 @@ class MockPriceService extends _i1.Mock implements _i29.PriceService { returnValueForMissingStub: null, ); @override - void addListener(_i21.VoidCallback? listener) => super.noSuchMethod( + void addListener(_i22.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #addListener, [listener], @@ -2713,7 +2779,7 @@ class MockPriceService extends _i1.Mock implements _i29.PriceService { returnValueForMissingStub: null, ); @override - void removeListener(_i21.VoidCallback? listener) => super.noSuchMethod( + void removeListener(_i22.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #removeListener, [listener], @@ -2733,7 +2799,7 @@ class MockPriceService extends _i1.Mock implements _i29.PriceService { /// A class which mocks [NotesService]. /// /// See the documentation for Mockito's code generation for more information. -class MockNotesService extends _i1.Mock implements _i31.NotesService { +class MockNotesService extends _i1.Mock implements _i32.NotesService { MockNotesService() { _i1.throwOnMissingStub(this); } @@ -2749,35 +2815,35 @@ class MockNotesService extends _i1.Mock implements _i31.NotesService { returnValue: {}, ) as Map); @override - _i19.Future> get notes => (super.noSuchMethod( + _i20.Future> get notes => (super.noSuchMethod( Invocation.getter(#notes), - returnValue: _i19.Future>.value({}), - ) as _i19.Future>); + returnValue: _i20.Future>.value({}), + ) as _i20.Future>); @override bool get hasListeners => (super.noSuchMethod( Invocation.getter(#hasListeners), returnValue: false, ) as bool); @override - _i19.Future> search(String? text) => (super.noSuchMethod( + _i20.Future> search(String? text) => (super.noSuchMethod( Invocation.method( #search, [text], ), - returnValue: _i19.Future>.value({}), - ) as _i19.Future>); + returnValue: _i20.Future>.value({}), + ) as _i20.Future>); @override - _i19.Future getNoteFor({required String? txid}) => + _i20.Future getNoteFor({required String? txid}) => (super.noSuchMethod( Invocation.method( #getNoteFor, [], {#txid: txid}, ), - returnValue: _i19.Future.value(''), - ) as _i19.Future); + returnValue: _i20.Future.value(''), + ) as _i20.Future); @override - _i19.Future editOrAddNote({ + _i20.Future editOrAddNote({ required String? txid, required String? note, }) => @@ -2790,21 +2856,21 @@ class MockNotesService extends _i1.Mock implements _i31.NotesService { #note: note, }, ), - returnValue: _i19.Future.value(), - returnValueForMissingStub: _i19.Future.value(), - ) as _i19.Future); + returnValue: _i20.Future.value(), + returnValueForMissingStub: _i20.Future.value(), + ) as _i20.Future); @override - _i19.Future deleteNote({required String? txid}) => (super.noSuchMethod( + _i20.Future deleteNote({required String? txid}) => (super.noSuchMethod( Invocation.method( #deleteNote, [], {#txid: txid}, ), - returnValue: _i19.Future.value(), - returnValueForMissingStub: _i19.Future.value(), - ) as _i19.Future); + returnValue: _i20.Future.value(), + returnValueForMissingStub: _i20.Future.value(), + ) as _i20.Future); @override - void addListener(_i21.VoidCallback? listener) => super.noSuchMethod( + void addListener(_i22.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #addListener, [listener], @@ -2812,7 +2878,7 @@ class MockNotesService extends _i1.Mock implements _i31.NotesService { returnValueForMissingStub: null, ); @override - void removeListener(_i21.VoidCallback? listener) => super.noSuchMethod( + void removeListener(_i22.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #removeListener, [listener], @@ -2840,11 +2906,27 @@ class MockNotesService extends _i1.Mock implements _i31.NotesService { /// A class which mocks [ThemeService]. /// /// See the documentation for Mockito's code generation for more information. -class MockThemeService extends _i1.Mock implements _i32.ThemeService { +class MockThemeService extends _i1.Mock implements _i33.ThemeService { MockThemeService() { _i1.throwOnMissingStub(this); } + @override + _i16.HTTP get client => (super.noSuchMethod( + Invocation.getter(#client), + returnValue: _FakeHTTP_14( + this, + Invocation.getter(#client), + ), + ) as _i16.HTTP); + @override + set client(_i16.HTTP? _client) => super.noSuchMethod( + Invocation.setter( + #client, + _client, + ), + returnValueForMissingStub: null, + ); @override _i14.MainDB get db => (super.noSuchMethod( Invocation.getter(#db), @@ -2854,10 +2936,10 @@ class MockThemeService extends _i1.Mock implements _i32.ThemeService { ), ) as _i14.MainDB); @override - List<_i33.StackTheme> get installedThemes => (super.noSuchMethod( + List<_i34.StackTheme> get installedThemes => (super.noSuchMethod( Invocation.getter(#installedThemes), - returnValue: <_i33.StackTheme>[], - ) as List<_i33.StackTheme>); + returnValue: <_i34.StackTheme>[], + ) as List<_i34.StackTheme>); @override void init(_i14.MainDB? db) => super.noSuchMethod( Invocation.method( @@ -2867,73 +2949,73 @@ class MockThemeService extends _i1.Mock implements _i32.ThemeService { returnValueForMissingStub: null, ); @override - _i19.Future install({required _i34.Uint8List? themeArchiveData}) => + _i20.Future install({required _i35.Uint8List? themeArchiveData}) => (super.noSuchMethod( Invocation.method( #install, [], {#themeArchiveData: themeArchiveData}, ), - returnValue: _i19.Future.value(), - returnValueForMissingStub: _i19.Future.value(), - ) as _i19.Future); + returnValue: _i20.Future.value(), + returnValueForMissingStub: _i20.Future.value(), + ) as _i20.Future); @override - _i19.Future remove({required String? themeId}) => (super.noSuchMethod( + _i20.Future remove({required String? themeId}) => (super.noSuchMethod( Invocation.method( #remove, [], {#themeId: themeId}, ), - returnValue: _i19.Future.value(), - returnValueForMissingStub: _i19.Future.value(), - ) as _i19.Future); + returnValue: _i20.Future.value(), + returnValueForMissingStub: _i20.Future.value(), + ) as _i20.Future); @override - _i19.Future checkDefaultThemesOnStartup() => (super.noSuchMethod( + _i20.Future checkDefaultThemesOnStartup() => (super.noSuchMethod( Invocation.method( #checkDefaultThemesOnStartup, [], ), - returnValue: _i19.Future.value(), - returnValueForMissingStub: _i19.Future.value(), - ) as _i19.Future); + returnValue: _i20.Future.value(), + returnValueForMissingStub: _i20.Future.value(), + ) as _i20.Future); @override - _i19.Future verifyInstalled({required String? themeId}) => + _i20.Future verifyInstalled({required String? themeId}) => (super.noSuchMethod( Invocation.method( #verifyInstalled, [], {#themeId: themeId}, ), - returnValue: _i19.Future.value(false), - ) as _i19.Future); + returnValue: _i20.Future.value(false), + ) as _i20.Future); @override - _i19.Future> fetchThemes() => + _i20.Future> fetchThemes() => (super.noSuchMethod( Invocation.method( #fetchThemes, [], ), - returnValue: _i19.Future>.value( - <_i32.StackThemeMetaData>[]), - ) as _i19.Future>); + returnValue: _i20.Future>.value( + <_i33.StackThemeMetaData>[]), + ) as _i20.Future>); @override - _i19.Future<_i34.Uint8List> fetchTheme( - {required _i32.StackThemeMetaData? themeMetaData}) => + _i20.Future<_i35.Uint8List> fetchTheme( + {required _i33.StackThemeMetaData? themeMetaData}) => (super.noSuchMethod( Invocation.method( #fetchTheme, [], {#themeMetaData: themeMetaData}, ), - returnValue: _i19.Future<_i34.Uint8List>.value(_i34.Uint8List(0)), - ) as _i19.Future<_i34.Uint8List>); + returnValue: _i20.Future<_i35.Uint8List>.value(_i35.Uint8List(0)), + ) as _i20.Future<_i35.Uint8List>); @override - _i33.StackTheme? getTheme({required String? themeId}) => + _i34.StackTheme? getTheme({required String? themeId}) => (super.noSuchMethod(Invocation.method( #getTheme, [], {#themeId: themeId}, - )) as _i33.StackTheme?); + )) as _i34.StackTheme?); } /// A class which mocks [MainDB]. @@ -2945,131 +3027,131 @@ class MockMainDB extends _i1.Mock implements _i14.MainDB { } @override - _i16.Isar get isar => (super.noSuchMethod( + _i17.Isar get isar => (super.noSuchMethod( Invocation.getter(#isar), - returnValue: _FakeIsar_14( + returnValue: _FakeIsar_15( this, Invocation.getter(#isar), ), - ) as _i16.Isar); + ) as _i17.Isar); @override - _i19.Future initMainDB({_i16.Isar? mock}) => (super.noSuchMethod( + _i20.Future initMainDB({_i17.Isar? mock}) => (super.noSuchMethod( Invocation.method( #initMainDB, [], {#mock: mock}, ), - returnValue: _i19.Future.value(false), - ) as _i19.Future); + returnValue: _i20.Future.value(false), + ) as _i20.Future); @override - List<_i35.ContactEntry> getContactEntries() => (super.noSuchMethod( + List<_i36.ContactEntry> getContactEntries() => (super.noSuchMethod( Invocation.method( #getContactEntries, [], ), - returnValue: <_i35.ContactEntry>[], - ) as List<_i35.ContactEntry>); + returnValue: <_i36.ContactEntry>[], + ) as List<_i36.ContactEntry>); @override - _i19.Future deleteContactEntry({required String? id}) => + _i20.Future deleteContactEntry({required String? id}) => (super.noSuchMethod( Invocation.method( #deleteContactEntry, [], {#id: id}, ), - returnValue: _i19.Future.value(false), - ) as _i19.Future); + returnValue: _i20.Future.value(false), + ) as _i20.Future); @override - _i19.Future isContactEntryExists({required String? id}) => + _i20.Future isContactEntryExists({required String? id}) => (super.noSuchMethod( Invocation.method( #isContactEntryExists, [], {#id: id}, ), - returnValue: _i19.Future.value(false), - ) as _i19.Future); + returnValue: _i20.Future.value(false), + ) as _i20.Future); @override - _i35.ContactEntry? getContactEntry({required String? id}) => + _i36.ContactEntry? getContactEntry({required String? id}) => (super.noSuchMethod(Invocation.method( #getContactEntry, [], {#id: id}, - )) as _i35.ContactEntry?); + )) as _i36.ContactEntry?); @override - _i19.Future putContactEntry( - {required _i35.ContactEntry? contactEntry}) => + _i20.Future putContactEntry( + {required _i36.ContactEntry? contactEntry}) => (super.noSuchMethod( Invocation.method( #putContactEntry, [], {#contactEntry: contactEntry}, ), - returnValue: _i19.Future.value(false), - ) as _i19.Future); + returnValue: _i20.Future.value(false), + ) as _i20.Future); @override - _i36.TransactionBlockExplorer? getTransactionBlockExplorer( - {required _i18.Coin? coin}) => + _i37.TransactionBlockExplorer? getTransactionBlockExplorer( + {required _i19.Coin? coin}) => (super.noSuchMethod(Invocation.method( #getTransactionBlockExplorer, [], {#coin: coin}, - )) as _i36.TransactionBlockExplorer?); + )) as _i37.TransactionBlockExplorer?); @override - _i19.Future putTransactionBlockExplorer( - _i36.TransactionBlockExplorer? explorer) => + _i20.Future putTransactionBlockExplorer( + _i37.TransactionBlockExplorer? explorer) => (super.noSuchMethod( Invocation.method( #putTransactionBlockExplorer, [explorer], ), - returnValue: _i19.Future.value(0), - ) as _i19.Future); + returnValue: _i20.Future.value(0), + ) as _i20.Future); @override - _i16.QueryBuilder<_i22.Address, _i22.Address, _i16.QAfterWhereClause> + _i17.QueryBuilder<_i23.Address, _i23.Address, _i17.QAfterWhereClause> getAddresses(String? walletId) => (super.noSuchMethod( Invocation.method( #getAddresses, [walletId], ), - returnValue: _FakeQueryBuilder_15<_i22.Address, _i22.Address, - _i16.QAfterWhereClause>( + returnValue: _FakeQueryBuilder_16<_i23.Address, _i23.Address, + _i17.QAfterWhereClause>( this, Invocation.method( #getAddresses, [walletId], ), ), - ) as _i16.QueryBuilder<_i22.Address, _i22.Address, - _i16.QAfterWhereClause>); + ) as _i17.QueryBuilder<_i23.Address, _i23.Address, + _i17.QAfterWhereClause>); @override - _i19.Future putAddress(_i22.Address? address) => (super.noSuchMethod( + _i20.Future putAddress(_i23.Address? address) => (super.noSuchMethod( Invocation.method( #putAddress, [address], ), - returnValue: _i19.Future.value(0), - ) as _i19.Future); + returnValue: _i20.Future.value(0), + ) as _i20.Future); @override - _i19.Future> putAddresses(List<_i22.Address>? addresses) => + _i20.Future> putAddresses(List<_i23.Address>? addresses) => (super.noSuchMethod( Invocation.method( #putAddresses, [addresses], ), - returnValue: _i19.Future>.value([]), - ) as _i19.Future>); + returnValue: _i20.Future>.value([]), + ) as _i20.Future>); @override - _i19.Future> updateOrPutAddresses(List<_i22.Address>? addresses) => + _i20.Future> updateOrPutAddresses(List<_i23.Address>? addresses) => (super.noSuchMethod( Invocation.method( #updateOrPutAddresses, [addresses], ), - returnValue: _i19.Future>.value([]), - ) as _i19.Future>); + returnValue: _i20.Future>.value([]), + ) as _i20.Future>); @override - _i19.Future<_i22.Address?> getAddress( + _i20.Future<_i23.Address?> getAddress( String? walletId, String? address, ) => @@ -3081,12 +3163,12 @@ class MockMainDB extends _i1.Mock implements _i14.MainDB { address, ], ), - returnValue: _i19.Future<_i22.Address?>.value(), - ) as _i19.Future<_i22.Address?>); + returnValue: _i20.Future<_i23.Address?>.value(), + ) as _i20.Future<_i23.Address?>); @override - _i19.Future updateAddress( - _i22.Address? oldAddress, - _i22.Address? newAddress, + _i20.Future updateAddress( + _i23.Address? oldAddress, + _i23.Address? newAddress, ) => (super.noSuchMethod( Invocation.method( @@ -3096,46 +3178,46 @@ class MockMainDB extends _i1.Mock implements _i14.MainDB { newAddress, ], ), - returnValue: _i19.Future.value(0), - ) as _i19.Future); + returnValue: _i20.Future.value(0), + ) as _i20.Future); @override - _i16.QueryBuilder<_i22.Transaction, _i22.Transaction, _i16.QAfterWhereClause> + _i17.QueryBuilder<_i23.Transaction, _i23.Transaction, _i17.QAfterWhereClause> getTransactions(String? walletId) => (super.noSuchMethod( Invocation.method( #getTransactions, [walletId], ), - returnValue: _FakeQueryBuilder_15<_i22.Transaction, - _i22.Transaction, _i16.QAfterWhereClause>( + returnValue: _FakeQueryBuilder_16<_i23.Transaction, + _i23.Transaction, _i17.QAfterWhereClause>( this, Invocation.method( #getTransactions, [walletId], ), ), - ) as _i16.QueryBuilder<_i22.Transaction, _i22.Transaction, - _i16.QAfterWhereClause>); + ) as _i17.QueryBuilder<_i23.Transaction, _i23.Transaction, + _i17.QAfterWhereClause>); @override - _i19.Future putTransaction(_i22.Transaction? transaction) => + _i20.Future putTransaction(_i23.Transaction? transaction) => (super.noSuchMethod( Invocation.method( #putTransaction, [transaction], ), - returnValue: _i19.Future.value(0), - ) as _i19.Future); + returnValue: _i20.Future.value(0), + ) as _i20.Future); @override - _i19.Future> putTransactions( - List<_i22.Transaction>? transactions) => + _i20.Future> putTransactions( + List<_i23.Transaction>? transactions) => (super.noSuchMethod( Invocation.method( #putTransactions, [transactions], ), - returnValue: _i19.Future>.value([]), - ) as _i19.Future>); + returnValue: _i20.Future>.value([]), + ) as _i20.Future>); @override - _i19.Future<_i22.Transaction?> getTransaction( + _i20.Future<_i23.Transaction?> getTransaction( String? walletId, String? txid, ) => @@ -3147,10 +3229,10 @@ class MockMainDB extends _i1.Mock implements _i14.MainDB { txid, ], ), - returnValue: _i19.Future<_i22.Transaction?>.value(), - ) as _i19.Future<_i22.Transaction?>); + returnValue: _i20.Future<_i23.Transaction?>.value(), + ) as _i20.Future<_i23.Transaction?>); @override - _i19.Stream<_i22.Transaction?> watchTransaction({ + _i20.Stream<_i23.Transaction?> watchTransaction({ required int? id, bool? fireImmediately = false, }) => @@ -3163,10 +3245,10 @@ class MockMainDB extends _i1.Mock implements _i14.MainDB { #fireImmediately: fireImmediately, }, ), - returnValue: _i19.Stream<_i22.Transaction?>.empty(), - ) as _i19.Stream<_i22.Transaction?>); + returnValue: _i20.Stream<_i23.Transaction?>.empty(), + ) as _i20.Stream<_i23.Transaction?>); @override - _i16.QueryBuilder<_i22.UTXO, _i22.UTXO, _i16.QAfterWhereClause> getUTXOs( + _i17.QueryBuilder<_i23.UTXO, _i23.UTXO, _i17.QAfterWhereClause> getUTXOs( String? walletId) => (super.noSuchMethod( Invocation.method( @@ -3174,36 +3256,36 @@ class MockMainDB extends _i1.Mock implements _i14.MainDB { [walletId], ), returnValue: - _FakeQueryBuilder_15<_i22.UTXO, _i22.UTXO, _i16.QAfterWhereClause>( + _FakeQueryBuilder_16<_i23.UTXO, _i23.UTXO, _i17.QAfterWhereClause>( this, Invocation.method( #getUTXOs, [walletId], ), ), - ) as _i16.QueryBuilder<_i22.UTXO, _i22.UTXO, _i16.QAfterWhereClause>); + ) as _i17.QueryBuilder<_i23.UTXO, _i23.UTXO, _i17.QAfterWhereClause>); @override - _i19.Future putUTXO(_i22.UTXO? utxo) => (super.noSuchMethod( + _i20.Future putUTXO(_i23.UTXO? utxo) => (super.noSuchMethod( Invocation.method( #putUTXO, [utxo], ), - returnValue: _i19.Future.value(), - returnValueForMissingStub: _i19.Future.value(), - ) as _i19.Future); + returnValue: _i20.Future.value(), + returnValueForMissingStub: _i20.Future.value(), + ) as _i20.Future); @override - _i19.Future putUTXOs(List<_i22.UTXO>? utxos) => (super.noSuchMethod( + _i20.Future putUTXOs(List<_i23.UTXO>? utxos) => (super.noSuchMethod( Invocation.method( #putUTXOs, [utxos], ), - returnValue: _i19.Future.value(), - returnValueForMissingStub: _i19.Future.value(), - ) as _i19.Future); + returnValue: _i20.Future.value(), + returnValueForMissingStub: _i20.Future.value(), + ) as _i20.Future); @override - _i19.Future updateUTXOs( + _i20.Future updateUTXOs( String? walletId, - List<_i22.UTXO>? utxos, + List<_i23.UTXO>? utxos, ) => (super.noSuchMethod( Invocation.method( @@ -3213,10 +3295,10 @@ class MockMainDB extends _i1.Mock implements _i14.MainDB { utxos, ], ), - returnValue: _i19.Future.value(false), - ) as _i19.Future); + returnValue: _i20.Future.value(false), + ) as _i20.Future); @override - _i19.Stream<_i22.UTXO?> watchUTXO({ + _i20.Stream<_i23.UTXO?> watchUTXO({ required int? id, bool? fireImmediately = false, }) => @@ -3229,50 +3311,50 @@ class MockMainDB extends _i1.Mock implements _i14.MainDB { #fireImmediately: fireImmediately, }, ), - returnValue: _i19.Stream<_i22.UTXO?>.empty(), - ) as _i19.Stream<_i22.UTXO?>); + returnValue: _i20.Stream<_i23.UTXO?>.empty(), + ) as _i20.Stream<_i23.UTXO?>); @override - _i16.QueryBuilder<_i22.TransactionNote, _i22.TransactionNote, - _i16.QAfterWhereClause> getTransactionNotes( + _i17.QueryBuilder<_i23.TransactionNote, _i23.TransactionNote, + _i17.QAfterWhereClause> getTransactionNotes( String? walletId) => (super.noSuchMethod( Invocation.method( #getTransactionNotes, [walletId], ), - returnValue: _FakeQueryBuilder_15<_i22.TransactionNote, - _i22.TransactionNote, _i16.QAfterWhereClause>( + returnValue: _FakeQueryBuilder_16<_i23.TransactionNote, + _i23.TransactionNote, _i17.QAfterWhereClause>( this, Invocation.method( #getTransactionNotes, [walletId], ), ), - ) as _i16.QueryBuilder<_i22.TransactionNote, _i22.TransactionNote, - _i16.QAfterWhereClause>); + ) as _i17.QueryBuilder<_i23.TransactionNote, _i23.TransactionNote, + _i17.QAfterWhereClause>); @override - _i19.Future putTransactionNote(_i22.TransactionNote? transactionNote) => + _i20.Future putTransactionNote(_i23.TransactionNote? transactionNote) => (super.noSuchMethod( Invocation.method( #putTransactionNote, [transactionNote], ), - returnValue: _i19.Future.value(), - returnValueForMissingStub: _i19.Future.value(), - ) as _i19.Future); + returnValue: _i20.Future.value(), + returnValueForMissingStub: _i20.Future.value(), + ) as _i20.Future); @override - _i19.Future putTransactionNotes( - List<_i22.TransactionNote>? transactionNotes) => + _i20.Future putTransactionNotes( + List<_i23.TransactionNote>? transactionNotes) => (super.noSuchMethod( Invocation.method( #putTransactionNotes, [transactionNotes], ), - returnValue: _i19.Future.value(), - returnValueForMissingStub: _i19.Future.value(), - ) as _i19.Future); + returnValue: _i20.Future.value(), + returnValueForMissingStub: _i20.Future.value(), + ) as _i20.Future); @override - _i19.Future<_i22.TransactionNote?> getTransactionNote( + _i20.Future<_i23.TransactionNote?> getTransactionNote( String? walletId, String? txid, ) => @@ -3284,10 +3366,10 @@ class MockMainDB extends _i1.Mock implements _i14.MainDB { txid, ], ), - returnValue: _i19.Future<_i22.TransactionNote?>.value(), - ) as _i19.Future<_i22.TransactionNote?>); + returnValue: _i20.Future<_i23.TransactionNote?>.value(), + ) as _i20.Future<_i23.TransactionNote?>); @override - _i19.Stream<_i22.TransactionNote?> watchTransactionNote({ + _i20.Stream<_i23.TransactionNote?> watchTransactionNote({ required int? id, bool? fireImmediately = false, }) => @@ -3300,38 +3382,38 @@ class MockMainDB extends _i1.Mock implements _i14.MainDB { #fireImmediately: fireImmediately, }, ), - returnValue: _i19.Stream<_i22.TransactionNote?>.empty(), - ) as _i19.Stream<_i22.TransactionNote?>); + returnValue: _i20.Stream<_i23.TransactionNote?>.empty(), + ) as _i20.Stream<_i23.TransactionNote?>); @override - _i16.QueryBuilder<_i22.AddressLabel, _i22.AddressLabel, - _i16.QAfterWhereClause> getAddressLabels( + _i17.QueryBuilder<_i23.AddressLabel, _i23.AddressLabel, + _i17.QAfterWhereClause> getAddressLabels( String? walletId) => (super.noSuchMethod( Invocation.method( #getAddressLabels, [walletId], ), - returnValue: _FakeQueryBuilder_15<_i22.AddressLabel, _i22.AddressLabel, - _i16.QAfterWhereClause>( + returnValue: _FakeQueryBuilder_16<_i23.AddressLabel, _i23.AddressLabel, + _i17.QAfterWhereClause>( this, Invocation.method( #getAddressLabels, [walletId], ), ), - ) as _i16.QueryBuilder<_i22.AddressLabel, _i22.AddressLabel, - _i16.QAfterWhereClause>); + ) as _i17.QueryBuilder<_i23.AddressLabel, _i23.AddressLabel, + _i17.QAfterWhereClause>); @override - _i19.Future putAddressLabel(_i22.AddressLabel? addressLabel) => + _i20.Future putAddressLabel(_i23.AddressLabel? addressLabel) => (super.noSuchMethod( Invocation.method( #putAddressLabel, [addressLabel], ), - returnValue: _i19.Future.value(0), - ) as _i19.Future); + returnValue: _i20.Future.value(0), + ) as _i20.Future); @override - int putAddressLabelSync(_i22.AddressLabel? addressLabel) => + int putAddressLabelSync(_i23.AddressLabel? addressLabel) => (super.noSuchMethod( Invocation.method( #putAddressLabelSync, @@ -3340,17 +3422,17 @@ class MockMainDB extends _i1.Mock implements _i14.MainDB { returnValue: 0, ) as int); @override - _i19.Future putAddressLabels(List<_i22.AddressLabel>? addressLabels) => + _i20.Future putAddressLabels(List<_i23.AddressLabel>? addressLabels) => (super.noSuchMethod( Invocation.method( #putAddressLabels, [addressLabels], ), - returnValue: _i19.Future.value(), - returnValueForMissingStub: _i19.Future.value(), - ) as _i19.Future); + returnValue: _i20.Future.value(), + returnValueForMissingStub: _i20.Future.value(), + ) as _i20.Future); @override - _i19.Future<_i22.AddressLabel?> getAddressLabel( + _i20.Future<_i23.AddressLabel?> getAddressLabel( String? walletId, String? addressString, ) => @@ -3362,10 +3444,10 @@ class MockMainDB extends _i1.Mock implements _i14.MainDB { addressString, ], ), - returnValue: _i19.Future<_i22.AddressLabel?>.value(), - ) as _i19.Future<_i22.AddressLabel?>); + returnValue: _i20.Future<_i23.AddressLabel?>.value(), + ) as _i20.Future<_i23.AddressLabel?>); @override - _i22.AddressLabel? getAddressLabelSync( + _i23.AddressLabel? getAddressLabelSync( String? walletId, String? addressString, ) => @@ -3375,9 +3457,9 @@ class MockMainDB extends _i1.Mock implements _i14.MainDB { walletId, addressString, ], - )) as _i22.AddressLabel?); + )) as _i23.AddressLabel?); @override - _i19.Stream<_i22.AddressLabel?> watchAddressLabel({ + _i20.Stream<_i23.AddressLabel?> watchAddressLabel({ required int? id, bool? fireImmediately = false, }) => @@ -3390,50 +3472,50 @@ class MockMainDB extends _i1.Mock implements _i14.MainDB { #fireImmediately: fireImmediately, }, ), - returnValue: _i19.Stream<_i22.AddressLabel?>.empty(), - ) as _i19.Stream<_i22.AddressLabel?>); + returnValue: _i20.Stream<_i23.AddressLabel?>.empty(), + ) as _i20.Stream<_i23.AddressLabel?>); @override - _i19.Future updateAddressLabel(_i22.AddressLabel? addressLabel) => + _i20.Future updateAddressLabel(_i23.AddressLabel? addressLabel) => (super.noSuchMethod( Invocation.method( #updateAddressLabel, [addressLabel], ), - returnValue: _i19.Future.value(0), - ) as _i19.Future); + returnValue: _i20.Future.value(0), + ) as _i20.Future); @override - _i19.Future deleteWalletBlockchainData(String? walletId) => + _i20.Future deleteWalletBlockchainData(String? walletId) => (super.noSuchMethod( Invocation.method( #deleteWalletBlockchainData, [walletId], ), - returnValue: _i19.Future.value(), - returnValueForMissingStub: _i19.Future.value(), - ) as _i19.Future); + returnValue: _i20.Future.value(), + returnValueForMissingStub: _i20.Future.value(), + ) as _i20.Future); @override - _i19.Future deleteAddressLabels(String? walletId) => + _i20.Future deleteAddressLabels(String? walletId) => (super.noSuchMethod( Invocation.method( #deleteAddressLabels, [walletId], ), - returnValue: _i19.Future.value(), - returnValueForMissingStub: _i19.Future.value(), - ) as _i19.Future); + returnValue: _i20.Future.value(), + returnValueForMissingStub: _i20.Future.value(), + ) as _i20.Future); @override - _i19.Future deleteTransactionNotes(String? walletId) => + _i20.Future deleteTransactionNotes(String? walletId) => (super.noSuchMethod( Invocation.method( #deleteTransactionNotes, [walletId], ), - returnValue: _i19.Future.value(), - returnValueForMissingStub: _i19.Future.value(), - ) as _i19.Future); + returnValue: _i20.Future.value(), + returnValueForMissingStub: _i20.Future.value(), + ) as _i20.Future); @override - _i19.Future addNewTransactionData( - List<_i15.Tuple2<_i22.Transaction, _i22.Address?>>? transactionsData, + _i20.Future addNewTransactionData( + List<_i15.Tuple2<_i23.Transaction, _i23.Address?>>? transactionsData, String? walletId, ) => (super.noSuchMethod( @@ -3444,68 +3526,168 @@ class MockMainDB extends _i1.Mock implements _i14.MainDB { walletId, ], ), - returnValue: _i19.Future.value(), - returnValueForMissingStub: _i19.Future.value(), - ) as _i19.Future); + returnValue: _i20.Future.value(), + returnValueForMissingStub: _i20.Future.value(), + ) as _i20.Future); @override - _i16.QueryBuilder<_i22.EthContract, _i22.EthContract, _i16.QWhere> + _i17.QueryBuilder<_i23.EthContract, _i23.EthContract, _i17.QWhere> getEthContracts() => (super.noSuchMethod( Invocation.method( #getEthContracts, [], ), - returnValue: _FakeQueryBuilder_15<_i22.EthContract, - _i22.EthContract, _i16.QWhere>( + returnValue: _FakeQueryBuilder_16<_i23.EthContract, + _i23.EthContract, _i17.QWhere>( this, Invocation.method( #getEthContracts, [], ), ), - ) as _i16 - .QueryBuilder<_i22.EthContract, _i22.EthContract, _i16.QWhere>); + ) as _i17 + .QueryBuilder<_i23.EthContract, _i23.EthContract, _i17.QWhere>); @override - _i19.Future<_i22.EthContract?> getEthContract(String? contractAddress) => + _i20.Future<_i23.EthContract?> getEthContract(String? contractAddress) => (super.noSuchMethod( Invocation.method( #getEthContract, [contractAddress], ), - returnValue: _i19.Future<_i22.EthContract?>.value(), - ) as _i19.Future<_i22.EthContract?>); + returnValue: _i20.Future<_i23.EthContract?>.value(), + ) as _i20.Future<_i23.EthContract?>); @override - _i22.EthContract? getEthContractSync(String? contractAddress) => + _i23.EthContract? getEthContractSync(String? contractAddress) => (super.noSuchMethod(Invocation.method( #getEthContractSync, [contractAddress], - )) as _i22.EthContract?); + )) as _i23.EthContract?); @override - _i19.Future putEthContract(_i22.EthContract? contract) => + _i20.Future putEthContract(_i23.EthContract? contract) => (super.noSuchMethod( Invocation.method( #putEthContract, [contract], ), - returnValue: _i19.Future.value(0), - ) as _i19.Future); + returnValue: _i20.Future.value(0), + ) as _i20.Future); @override - _i19.Future putEthContracts(List<_i22.EthContract>? contracts) => + _i20.Future putEthContracts(List<_i23.EthContract>? contracts) => (super.noSuchMethod( Invocation.method( #putEthContracts, [contracts], ), - returnValue: _i19.Future.value(), - returnValueForMissingStub: _i19.Future.value(), - ) as _i19.Future); + returnValue: _i20.Future.value(), + returnValueForMissingStub: _i20.Future.value(), + ) as _i20.Future); @override - _i19.Future getHighestUsedMintIndex({required String? walletId}) => + _i20.Future getHighestUsedMintIndex({required String? walletId}) => (super.noSuchMethod( Invocation.method( #getHighestUsedMintIndex, [], {#walletId: walletId}, ), - returnValue: _i19.Future.value(), - ) as _i19.Future); + returnValue: _i20.Future.value(), + ) as _i20.Future); +} + +/// A class which mocks [IThemeAssets]. +/// +/// See the documentation for Mockito's code generation for more information. +class MockIThemeAssets extends _i1.Mock implements _i34.IThemeAssets { + MockIThemeAssets() { + _i1.throwOnMissingStub(this); + } + + @override + String get bellNew => (super.noSuchMethod( + Invocation.getter(#bellNew), + returnValue: '', + ) as String); + @override + String get buy => (super.noSuchMethod( + Invocation.getter(#buy), + returnValue: '', + ) as String); + @override + String get exchange => (super.noSuchMethod( + Invocation.getter(#exchange), + returnValue: '', + ) as String); + @override + String get personaIncognito => (super.noSuchMethod( + Invocation.getter(#personaIncognito), + returnValue: '', + ) as String); + @override + String get personaEasy => (super.noSuchMethod( + Invocation.getter(#personaEasy), + returnValue: '', + ) as String); + @override + String get stack => (super.noSuchMethod( + Invocation.getter(#stack), + returnValue: '', + ) as String); + @override + String get stackIcon => (super.noSuchMethod( + Invocation.getter(#stackIcon), + returnValue: '', + ) as String); + @override + String get receive => (super.noSuchMethod( + Invocation.getter(#receive), + returnValue: '', + ) as String); + @override + String get receivePending => (super.noSuchMethod( + Invocation.getter(#receivePending), + returnValue: '', + ) as String); + @override + String get receiveCancelled => (super.noSuchMethod( + Invocation.getter(#receiveCancelled), + returnValue: '', + ) as String); + @override + String get send => (super.noSuchMethod( + Invocation.getter(#send), + returnValue: '', + ) as String); + @override + String get sendPending => (super.noSuchMethod( + Invocation.getter(#sendPending), + returnValue: '', + ) as String); + @override + String get sendCancelled => (super.noSuchMethod( + Invocation.getter(#sendCancelled), + returnValue: '', + ) as String); + @override + String get themeSelector => (super.noSuchMethod( + Invocation.getter(#themeSelector), + returnValue: '', + ) as String); + @override + String get themePreview => (super.noSuchMethod( + Invocation.getter(#themePreview), + returnValue: '', + ) as String); + @override + String get txExchange => (super.noSuchMethod( + Invocation.getter(#txExchange), + returnValue: '', + ) as String); + @override + String get txExchangePending => (super.noSuchMethod( + Invocation.getter(#txExchangePending), + returnValue: '', + ) as String); + @override + String get txExchangeFailed => (super.noSuchMethod( + Invocation.getter(#txExchangeFailed), + returnValue: '', + ) as String); } diff --git a/test/widget_tests/wallet_card_test.dart b/test/widget_tests/wallet_card_test.dart index c2e77d012..b93bdbf20 100644 --- a/test/widget_tests/wallet_card_test.dart +++ b/test/widget_tests/wallet_card_test.dart @@ -1,3 +1,5 @@ +import 'dart:io'; + import 'package:decimal/decimal.dart'; import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; @@ -12,6 +14,7 @@ import 'package:stackwallet/services/coins/coin_service.dart'; import 'package:stackwallet/services/coins/manager.dart'; import 'package:stackwallet/services/locale_service.dart'; import 'package:stackwallet/services/wallets.dart'; +import 'package:stackwallet/themes/coin_icon_provider.dart'; import 'package:stackwallet/themes/stack_colors.dart'; import 'package:stackwallet/themes/theme_service.dart'; import 'package:stackwallet/utilities/amount/amount.dart'; @@ -73,6 +76,10 @@ void main() { overrides: [ walletsChangeNotifierProvider.overrideWithValue(wallets), pThemeService.overrideWithValue(mockThemeService), + coinIconProvider.overrideWithProvider( + (argument) => Provider((_) => + "${Directory.current.path}/test/sample_data/light/assets/dummy.svg"), + ), ], child: MaterialApp( theme: ThemeData( diff --git a/test/widget_tests/wallet_card_test.mocks.dart b/test/widget_tests/wallet_card_test.mocks.dart index f2d6e83b1..5ed295d28 100644 --- a/test/widget_tests/wallet_card_test.mocks.dart +++ b/test/widget_tests/wallet_card_test.mocks.dart @@ -3,9 +3,9 @@ // Do not manually edit this file. // ignore_for_file: no_leading_underscores_for_library_prefixes -import 'dart:async' as _i21; -import 'dart:typed_data' as _i28; -import 'dart:ui' as _i23; +import 'dart:async' as _i22; +import 'dart:typed_data' as _i29; +import 'dart:ui' as _i24; import 'package:bip32/bip32.dart' as _i16; import 'package:bip47/bip47.dart' as _i18; @@ -18,24 +18,25 @@ import 'package:stackwallet/electrumx_rpc/cached_electrumx.dart' as _i10; 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/isar/stack_theme.dart' as _i32; import 'package:stackwallet/models/paymint/fee_object_model.dart' as _i8; -import 'package:stackwallet/models/signing_data.dart' as _i26; -import 'package:stackwallet/services/coins/bitcoin/bitcoin_wallet.dart' as _i24; +import 'package:stackwallet/models/signing_data.dart' as _i27; +import 'package:stackwallet/networking/http.dart' as _i19; +import 'package:stackwallet/services/coins/bitcoin/bitcoin_wallet.dart' as _i25; import 'package:stackwallet/services/coins/manager.dart' as _i6; -import 'package:stackwallet/services/locale_service.dart' as _i29; +import 'package:stackwallet/services/locale_service.dart' as _i30; import 'package:stackwallet/services/node_service.dart' as _i3; import 'package:stackwallet/services/transaction_notification_tracker.dart' as _i7; -import 'package:stackwallet/services/wallets.dart' as _i19; +import 'package:stackwallet/services/wallets.dart' as _i20; import 'package:stackwallet/services/wallets_service.dart' as _i2; -import 'package:stackwallet/themes/theme_service.dart' as _i30; +import 'package:stackwallet/themes/theme_service.dart' as _i31; import 'package:stackwallet/utilities/amount/amount.dart' as _i14; -import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i20; -import 'package:stackwallet/utilities/enums/derive_path_type_enum.dart' as _i25; +import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i21; +import 'package:stackwallet/utilities/enums/derive_path_type_enum.dart' as _i26; import 'package:stackwallet/utilities/flutter_secure_storage_interface.dart' - as _i27; -import 'package:stackwallet/utilities/prefs.dart' as _i22; + as _i28; +import 'package:stackwallet/utilities/prefs.dart' as _i23; import 'package:tuple/tuple.dart' as _i15; // ignore_for_file: type=lint @@ -224,10 +225,20 @@ class _FakePaymentCode_16 extends _i1.SmartFake implements _i18.PaymentCode { ); } +class _FakeHTTP_17 extends _i1.SmartFake implements _i19.HTTP { + _FakeHTTP_17( + 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 _i19.Wallets { +class MockWallets extends _i1.Mock implements _i20.Wallets { MockWallets() { _i1.throwOnMissingStub(this); } @@ -294,7 +305,7 @@ class MockWallets extends _i1.Mock implements _i19.Wallets { returnValueForMissingStub: null, ); @override - List getWalletIdsFor({required _i20.Coin? coin}) => + List getWalletIdsFor({required _i21.Coin? coin}) => (super.noSuchMethod( Invocation.method( #getWalletIdsFor, @@ -304,20 +315,20 @@ class MockWallets extends _i1.Mock implements _i19.Wallets { returnValue: [], ) as List); @override - List<_i15.Tuple2<_i20.Coin, List<_i5.ChangeNotifierProvider<_i6.Manager>>>> + List<_i15.Tuple2<_i21.Coin, List<_i5.ChangeNotifierProvider<_i6.Manager>>>> getManagerProvidersByCoin() => (super.noSuchMethod( Invocation.method( #getManagerProvidersByCoin, [], ), - returnValue: <_i15.Tuple2<_i20.Coin, + returnValue: <_i15.Tuple2<_i21.Coin, List<_i5.ChangeNotifierProvider<_i6.Manager>>>>[], ) as List< - _i15.Tuple2<_i20.Coin, + _i15.Tuple2<_i21.Coin, List<_i5.ChangeNotifierProvider<_i6.Manager>>>>); @override List<_i5.ChangeNotifierProvider<_i6.Manager>> getManagerProvidersForCoin( - _i20.Coin? coin) => + _i21.Coin? coin) => (super.noSuchMethod( Invocation.method( #getManagerProvidersForCoin, @@ -381,17 +392,17 @@ class MockWallets extends _i1.Mock implements _i19.Wallets { returnValueForMissingStub: null, ); @override - _i21.Future load(_i22.Prefs? prefs) => (super.noSuchMethod( + _i22.Future load(_i23.Prefs? prefs) => (super.noSuchMethod( Invocation.method( #load, [prefs], ), - returnValue: _i21.Future.value(), - returnValueForMissingStub: _i21.Future.value(), - ) as _i21.Future); + returnValue: _i22.Future.value(), + returnValueForMissingStub: _i22.Future.value(), + ) as _i22.Future); @override - _i21.Future loadAfterStackRestore( - _i22.Prefs? prefs, + _i22.Future loadAfterStackRestore( + _i23.Prefs? prefs, List<_i6.Manager>? managers, ) => (super.noSuchMethod( @@ -402,11 +413,11 @@ class MockWallets extends _i1.Mock implements _i19.Wallets { managers, ], ), - returnValue: _i21.Future.value(), - returnValueForMissingStub: _i21.Future.value(), - ) as _i21.Future); + returnValue: _i22.Future.value(), + returnValueForMissingStub: _i22.Future.value(), + ) as _i22.Future); @override - void addListener(_i23.VoidCallback? listener) => super.noSuchMethod( + void addListener(_i24.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #addListener, [listener], @@ -414,7 +425,7 @@ class MockWallets extends _i1.Mock implements _i19.Wallets { returnValueForMissingStub: null, ); @override - void removeListener(_i23.VoidCallback? listener) => super.noSuchMethod( + void removeListener(_i24.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #removeListener, [listener], @@ -434,13 +445,13 @@ class MockWallets extends _i1.Mock implements _i19.Wallets { /// A class which mocks [BitcoinWallet]. /// /// See the documentation for Mockito's code generation for more information. -class MockBitcoinWallet extends _i1.Mock implements _i24.BitcoinWallet { +class MockBitcoinWallet extends _i1.Mock implements _i25.BitcoinWallet { MockBitcoinWallet() { _i1.throwOnMissingStub(this); } @override - set timer(_i21.Timer? _timer) => super.noSuchMethod( + set timer(_i22.Timer? _timer) => super.noSuchMethod( Invocation.setter( #timer, _timer, @@ -517,74 +528,74 @@ class MockBitcoinWallet extends _i1.Mock implements _i24.BitcoinWallet { returnValue: false, ) as bool); @override - _i20.Coin get coin => (super.noSuchMethod( + _i21.Coin get coin => (super.noSuchMethod( Invocation.getter(#coin), - returnValue: _i20.Coin.bitcoin, - ) as _i20.Coin); + returnValue: _i21.Coin.bitcoin, + ) as _i21.Coin); @override - _i21.Future> get utxos => (super.noSuchMethod( + _i22.Future> get utxos => (super.noSuchMethod( Invocation.getter(#utxos), - returnValue: _i21.Future>.value(<_i17.UTXO>[]), - ) as _i21.Future>); + returnValue: _i22.Future>.value(<_i17.UTXO>[]), + ) as _i22.Future>); @override - _i21.Future> get transactions => (super.noSuchMethod( + _i22.Future> get transactions => (super.noSuchMethod( Invocation.getter(#transactions), returnValue: - _i21.Future>.value(<_i17.Transaction>[]), - ) as _i21.Future>); + _i22.Future>.value(<_i17.Transaction>[]), + ) as _i22.Future>); @override - _i21.Future get currentReceivingAddress => (super.noSuchMethod( + _i22.Future get currentReceivingAddress => (super.noSuchMethod( Invocation.getter(#currentReceivingAddress), - returnValue: _i21.Future.value(''), - ) as _i21.Future); + returnValue: _i22.Future.value(''), + ) as _i22.Future); @override - _i21.Future get currentChangeAddress => (super.noSuchMethod( + _i22.Future get currentChangeAddress => (super.noSuchMethod( Invocation.getter(#currentChangeAddress), - returnValue: _i21.Future.value(''), - ) as _i21.Future); + returnValue: _i22.Future.value(''), + ) as _i22.Future); @override - _i21.Future get currentChangeAddressP2PKH => (super.noSuchMethod( + _i22.Future get currentChangeAddressP2PKH => (super.noSuchMethod( Invocation.getter(#currentChangeAddressP2PKH), - returnValue: _i21.Future.value(''), - ) as _i21.Future); + returnValue: _i22.Future.value(''), + ) as _i22.Future); @override bool get hasCalledExit => (super.noSuchMethod( Invocation.getter(#hasCalledExit), returnValue: false, ) as bool); @override - _i21.Future<_i8.FeeObject> get fees => (super.noSuchMethod( + _i22.Future<_i8.FeeObject> get fees => (super.noSuchMethod( Invocation.getter(#fees), - returnValue: _i21.Future<_i8.FeeObject>.value(_FakeFeeObject_5( + returnValue: _i22.Future<_i8.FeeObject>.value(_FakeFeeObject_5( this, Invocation.getter(#fees), )), - ) as _i21.Future<_i8.FeeObject>); + ) as _i22.Future<_i8.FeeObject>); @override - _i21.Future get maxFee => (super.noSuchMethod( + _i22.Future get maxFee => (super.noSuchMethod( Invocation.getter(#maxFee), - returnValue: _i21.Future.value(0), - ) as _i21.Future); + returnValue: _i22.Future.value(0), + ) as _i22.Future); @override - _i21.Future> get mnemonic => (super.noSuchMethod( + _i22.Future> get mnemonic => (super.noSuchMethod( Invocation.getter(#mnemonic), - returnValue: _i21.Future>.value([]), - ) as _i21.Future>); + returnValue: _i22.Future>.value([]), + ) as _i22.Future>); @override - _i21.Future get mnemonicString => (super.noSuchMethod( + _i22.Future get mnemonicString => (super.noSuchMethod( Invocation.getter(#mnemonicString), - returnValue: _i21.Future.value(), - ) as _i21.Future); + returnValue: _i22.Future.value(), + ) as _i22.Future); @override - _i21.Future get mnemonicPassphrase => (super.noSuchMethod( + _i22.Future get mnemonicPassphrase => (super.noSuchMethod( Invocation.getter(#mnemonicPassphrase), - returnValue: _i21.Future.value(), - ) as _i21.Future); + returnValue: _i22.Future.value(), + ) as _i22.Future); @override - _i21.Future get chainHeight => (super.noSuchMethod( + _i22.Future get chainHeight => (super.noSuchMethod( Invocation.getter(#chainHeight), - returnValue: _i21.Future.value(0), - ) as _i21.Future); + returnValue: _i22.Future.value(0), + ) as _i22.Future); @override int get storedChainHeight => (super.noSuchMethod( Invocation.getter(#storedChainHeight), @@ -656,10 +667,10 @@ class MockBitcoinWallet extends _i1.Mock implements _i24.BitcoinWallet { ), ) as _i11.Balance); @override - _i21.Future get xpub => (super.noSuchMethod( + _i22.Future get xpub => (super.noSuchMethod( Invocation.getter(#xpub), - returnValue: _i21.Future.value(''), - ) as _i21.Future); + returnValue: _i22.Future.value(''), + ) as _i22.Future); @override set onIsActiveWalletChanged(void Function(bool)? _onIsActiveWalletChanged) => super.noSuchMethod( @@ -686,26 +697,26 @@ class MockBitcoinWallet extends _i1.Mock implements _i24.BitcoinWallet { ), ) as _i13.NetworkType); @override - _i21.Future exit() => (super.noSuchMethod( + _i22.Future exit() => (super.noSuchMethod( Invocation.method( #exit, [], ), - returnValue: _i21.Future.value(), - returnValueForMissingStub: _i21.Future.value(), - ) as _i21.Future); + returnValue: _i22.Future.value(), + returnValueForMissingStub: _i22.Future.value(), + ) as _i22.Future); @override - _i25.DerivePathType addressType({required String? address}) => + _i26.DerivePathType addressType({required String? address}) => (super.noSuchMethod( Invocation.method( #addressType, [], {#address: address}, ), - returnValue: _i25.DerivePathType.bip44, - ) as _i25.DerivePathType); + returnValue: _i26.DerivePathType.bip44, + ) as _i26.DerivePathType); @override - _i21.Future recoverFromMnemonic({ + _i22.Future recoverFromMnemonic({ required String? mnemonic, String? mnemonicPassphrase, required int? maxUnusedAddressGap, @@ -724,47 +735,47 @@ class MockBitcoinWallet extends _i1.Mock implements _i24.BitcoinWallet { #height: height, }, ), - returnValue: _i21.Future.value(), - returnValueForMissingStub: _i21.Future.value(), - ) as _i21.Future); + returnValue: _i22.Future.value(), + returnValueForMissingStub: _i22.Future.value(), + ) as _i22.Future); @override - _i21.Future getTransactionCacheEarly(List? allAddresses) => + _i22.Future getTransactionCacheEarly(List? allAddresses) => (super.noSuchMethod( Invocation.method( #getTransactionCacheEarly, [allAddresses], ), - returnValue: _i21.Future.value(), - returnValueForMissingStub: _i21.Future.value(), - ) as _i21.Future); + returnValue: _i22.Future.value(), + returnValueForMissingStub: _i22.Future.value(), + ) as _i22.Future); @override - _i21.Future refreshIfThereIsNewData() => (super.noSuchMethod( + _i22.Future refreshIfThereIsNewData() => (super.noSuchMethod( Invocation.method( #refreshIfThereIsNewData, [], ), - returnValue: _i21.Future.value(false), - ) as _i21.Future); + returnValue: _i22.Future.value(false), + ) as _i22.Future); @override - _i21.Future getAllTxsToWatch() => (super.noSuchMethod( + _i22.Future getAllTxsToWatch() => (super.noSuchMethod( Invocation.method( #getAllTxsToWatch, [], ), - returnValue: _i21.Future.value(), - returnValueForMissingStub: _i21.Future.value(), - ) as _i21.Future); + returnValue: _i22.Future.value(), + returnValueForMissingStub: _i22.Future.value(), + ) as _i22.Future); @override - _i21.Future refresh() => (super.noSuchMethod( + _i22.Future refresh() => (super.noSuchMethod( Invocation.method( #refresh, [], ), - returnValue: _i21.Future.value(), - returnValueForMissingStub: _i21.Future.value(), - ) as _i21.Future); + returnValue: _i22.Future.value(), + returnValueForMissingStub: _i22.Future.value(), + ) as _i22.Future); @override - _i21.Future> prepareSend({ + _i22.Future> prepareSend({ required String? address, required _i14.Amount? amount, Map? args, @@ -780,26 +791,26 @@ class MockBitcoinWallet extends _i1.Mock implements _i24.BitcoinWallet { }, ), returnValue: - _i21.Future>.value({}), - ) as _i21.Future>); + _i22.Future>.value({}), + ) as _i22.Future>); @override - _i21.Future confirmSend({required Map? txData}) => + _i22.Future confirmSend({required Map? txData}) => (super.noSuchMethod( Invocation.method( #confirmSend, [], {#txData: txData}, ), - returnValue: _i21.Future.value(''), - ) as _i21.Future); + returnValue: _i22.Future.value(''), + ) as _i22.Future); @override - _i21.Future testNetworkConnection() => (super.noSuchMethod( + _i22.Future testNetworkConnection() => (super.noSuchMethod( Invocation.method( #testNetworkConnection, [], ), - returnValue: _i21.Future.value(false), - ) as _i21.Future); + returnValue: _i22.Future.value(false), + ) as _i22.Future); @override void startNetworkAlivePinging() => super.noSuchMethod( Invocation.method( @@ -817,33 +828,35 @@ class MockBitcoinWallet extends _i1.Mock implements _i24.BitcoinWallet { returnValueForMissingStub: null, ); @override - _i21.Future initializeNew() => (super.noSuchMethod( + _i22.Future initializeNew( + ({String mnemonicPassphrase, int wordCount})? data) => + (super.noSuchMethod( Invocation.method( #initializeNew, - [], + [data], ), - returnValue: _i21.Future.value(), - returnValueForMissingStub: _i21.Future.value(), - ) as _i21.Future); + returnValue: _i22.Future.value(), + returnValueForMissingStub: _i22.Future.value(), + ) as _i22.Future); @override - _i21.Future initializeExisting() => (super.noSuchMethod( + _i22.Future initializeExisting() => (super.noSuchMethod( Invocation.method( #initializeExisting, [], ), - returnValue: _i21.Future.value(), - returnValueForMissingStub: _i21.Future.value(), - ) as _i21.Future); + returnValue: _i22.Future.value(), + returnValueForMissingStub: _i22.Future.value(), + ) as _i22.Future); @override - _i21.Future updateSentCachedTxData(Map? txData) => + _i22.Future updateSentCachedTxData(Map? txData) => (super.noSuchMethod( Invocation.method( #updateSentCachedTxData, [txData], ), - returnValue: _i21.Future.value(), - returnValueForMissingStub: _i21.Future.value(), - ) as _i21.Future); + returnValue: _i22.Future.value(), + returnValueForMissingStub: _i22.Future.value(), + ) as _i22.Future); @override bool validateAddress(String? address) => (super.noSuchMethod( Invocation.method( @@ -853,69 +866,69 @@ class MockBitcoinWallet extends _i1.Mock implements _i24.BitcoinWallet { returnValue: false, ) as bool); @override - _i21.Future updateNode(bool? shouldRefresh) => (super.noSuchMethod( + _i22.Future updateNode(bool? shouldRefresh) => (super.noSuchMethod( Invocation.method( #updateNode, [shouldRefresh], ), - returnValue: _i21.Future.value(), - returnValueForMissingStub: _i21.Future.value(), - ) as _i21.Future); + returnValue: _i22.Future.value(), + returnValueForMissingStub: _i22.Future.value(), + ) as _i22.Future); @override - _i21.Future<_i9.ElectrumXNode> getCurrentNode() => (super.noSuchMethod( + _i22.Future<_i9.ElectrumXNode> getCurrentNode() => (super.noSuchMethod( Invocation.method( #getCurrentNode, [], ), - returnValue: _i21.Future<_i9.ElectrumXNode>.value(_FakeElectrumXNode_11( + returnValue: _i22.Future<_i9.ElectrumXNode>.value(_FakeElectrumXNode_11( this, Invocation.method( #getCurrentNode, [], ), )), - ) as _i21.Future<_i9.ElectrumXNode>); + ) as _i22.Future<_i9.ElectrumXNode>); @override - _i21.Future>> fastFetch( + _i22.Future>> fastFetch( List? allTxHashes) => (super.noSuchMethod( Invocation.method( #fastFetch, [allTxHashes], ), - returnValue: _i21.Future>>.value( + returnValue: _i22.Future>>.value( >[]), - ) as _i21.Future>>); + ) as _i22.Future>>); @override - _i21.Future getTxCount({required String? address}) => + _i22.Future getTxCount({required String? address}) => (super.noSuchMethod( Invocation.method( #getTxCount, [], {#address: address}, ), - returnValue: _i21.Future.value(0), - ) as _i21.Future); + returnValue: _i22.Future.value(0), + ) as _i22.Future); @override - _i21.Future checkCurrentReceivingAddressesForTransactions() => + _i22.Future checkCurrentReceivingAddressesForTransactions() => (super.noSuchMethod( Invocation.method( #checkCurrentReceivingAddressesForTransactions, [], ), - returnValue: _i21.Future.value(), - returnValueForMissingStub: _i21.Future.value(), - ) as _i21.Future); + returnValue: _i22.Future.value(), + returnValueForMissingStub: _i22.Future.value(), + ) as _i22.Future); @override - _i21.Future checkCurrentChangeAddressesForTransactions() => + _i22.Future checkCurrentChangeAddressesForTransactions() => (super.noSuchMethod( Invocation.method( #checkCurrentChangeAddressesForTransactions, [], ), - returnValue: _i21.Future.value(), - returnValueForMissingStub: _i21.Future.value(), - ) as _i21.Future); + returnValue: _i22.Future.value(), + returnValueForMissingStub: _i22.Future.value(), + ) as _i22.Future); @override int estimateTxFee({ required int? vSize, @@ -958,7 +971,7 @@ class MockBitcoinWallet extends _i1.Mock implements _i24.BitcoinWallet { }, )); @override - _i21.Future> fetchBuildTxData( + _i22.Future> fetchBuildTxData( List<_i17.UTXO>? utxosToUse) => (super.noSuchMethod( Invocation.method( @@ -966,11 +979,11 @@ class MockBitcoinWallet extends _i1.Mock implements _i24.BitcoinWallet { [utxosToUse], ), returnValue: - _i21.Future>.value(<_i26.SigningData>[]), - ) as _i21.Future>); + _i22.Future>.value(<_i27.SigningData>[]), + ) as _i22.Future>); @override - _i21.Future> buildTransaction({ - required List<_i26.SigningData>? utxoSigningData, + _i22.Future> buildTransaction({ + required List<_i27.SigningData>? utxoSigningData, required List? recipients, required List? satoshiAmounts, }) => @@ -985,10 +998,10 @@ class MockBitcoinWallet extends _i1.Mock implements _i24.BitcoinWallet { }, ), returnValue: - _i21.Future>.value({}), - ) as _i21.Future>); + _i22.Future>.value({}), + ) as _i22.Future>); @override - _i21.Future fullRescan( + _i22.Future fullRescan( int? maxUnusedAddressGap, int? maxNumberOfIndexesToCheck, ) => @@ -1000,11 +1013,11 @@ class MockBitcoinWallet extends _i1.Mock implements _i24.BitcoinWallet { maxNumberOfIndexesToCheck, ], ), - returnValue: _i21.Future.value(), - returnValueForMissingStub: _i21.Future.value(), - ) as _i21.Future); + returnValue: _i22.Future.value(), + returnValueForMissingStub: _i22.Future.value(), + ) as _i22.Future); @override - _i21.Future<_i14.Amount> estimateFeeFor( + _i22.Future<_i14.Amount> estimateFeeFor( _i14.Amount? amount, int? feeRate, ) => @@ -1016,7 +1029,7 @@ class MockBitcoinWallet extends _i1.Mock implements _i24.BitcoinWallet { feeRate, ], ), - returnValue: _i21.Future<_i14.Amount>.value(_FakeAmount_12( + returnValue: _i22.Future<_i14.Amount>.value(_FakeAmount_12( this, Invocation.method( #estimateFeeFor, @@ -1026,7 +1039,7 @@ class MockBitcoinWallet extends _i1.Mock implements _i24.BitcoinWallet { ], ), )), - ) as _i21.Future<_i14.Amount>); + ) as _i22.Future<_i14.Amount>); @override _i14.Amount roughFeeEstimate( int? inputCount, @@ -1055,32 +1068,32 @@ class MockBitcoinWallet extends _i1.Mock implements _i24.BitcoinWallet { ), ) as _i14.Amount); @override - _i21.Future<_i14.Amount> sweepAllEstimate(int? feeRate) => + _i22.Future<_i14.Amount> sweepAllEstimate(int? feeRate) => (super.noSuchMethod( Invocation.method( #sweepAllEstimate, [feeRate], ), - returnValue: _i21.Future<_i14.Amount>.value(_FakeAmount_12( + returnValue: _i22.Future<_i14.Amount>.value(_FakeAmount_12( this, Invocation.method( #sweepAllEstimate, [feeRate], ), )), - ) as _i21.Future<_i14.Amount>); + ) as _i22.Future<_i14.Amount>); @override - _i21.Future generateNewAddress() => (super.noSuchMethod( + _i22.Future generateNewAddress() => (super.noSuchMethod( Invocation.method( #generateNewAddress, [], ), - returnValue: _i21.Future.value(false), - ) as _i21.Future); + returnValue: _i22.Future.value(false), + ) as _i22.Future); @override void initCache( String? walletId, - _i20.Coin? coin, + _i21.Coin? coin, ) => super.noSuchMethod( Invocation.method( @@ -1093,14 +1106,14 @@ class MockBitcoinWallet extends _i1.Mock implements _i24.BitcoinWallet { returnValueForMissingStub: null, ); @override - _i21.Future updateCachedId(String? id) => (super.noSuchMethod( + _i22.Future updateCachedId(String? id) => (super.noSuchMethod( Invocation.method( #updateCachedId, [id], ), - returnValue: _i21.Future.value(), - returnValueForMissingStub: _i21.Future.value(), - ) as _i21.Future); + returnValue: _i22.Future.value(), + returnValueForMissingStub: _i22.Future.value(), + ) as _i22.Future); @override int getCachedChainHeight() => (super.noSuchMethod( Invocation.method( @@ -1110,14 +1123,14 @@ class MockBitcoinWallet extends _i1.Mock implements _i24.BitcoinWallet { returnValue: 0, ) as int); @override - _i21.Future updateCachedChainHeight(int? height) => (super.noSuchMethod( + _i22.Future updateCachedChainHeight(int? height) => (super.noSuchMethod( Invocation.method( #updateCachedChainHeight, [height], ), - returnValue: _i21.Future.value(), - returnValueForMissingStub: _i21.Future.value(), - ) as _i21.Future); + returnValue: _i22.Future.value(), + returnValueForMissingStub: _i22.Future.value(), + ) as _i22.Future); @override bool getCachedIsFavorite() => (super.noSuchMethod( Invocation.method( @@ -1127,15 +1140,15 @@ class MockBitcoinWallet extends _i1.Mock implements _i24.BitcoinWallet { returnValue: false, ) as bool); @override - _i21.Future updateCachedIsFavorite(bool? isFavorite) => + _i22.Future updateCachedIsFavorite(bool? isFavorite) => (super.noSuchMethod( Invocation.method( #updateCachedIsFavorite, [isFavorite], ), - returnValue: _i21.Future.value(), - returnValueForMissingStub: _i21.Future.value(), - ) as _i21.Future); + returnValue: _i22.Future.value(), + returnValueForMissingStub: _i22.Future.value(), + ) as _i22.Future); @override _i11.Balance getCachedBalance() => (super.noSuchMethod( Invocation.method( @@ -1151,15 +1164,15 @@ class MockBitcoinWallet extends _i1.Mock implements _i24.BitcoinWallet { ), ) as _i11.Balance); @override - _i21.Future updateCachedBalance(_i11.Balance? balance) => + _i22.Future updateCachedBalance(_i11.Balance? balance) => (super.noSuchMethod( Invocation.method( #updateCachedBalance, [balance], ), - returnValue: _i21.Future.value(), - returnValueForMissingStub: _i21.Future.value(), - ) as _i21.Future); + returnValue: _i22.Future.value(), + returnValueForMissingStub: _i22.Future.value(), + ) as _i22.Future); @override _i11.Balance getCachedBalanceSecondary() => (super.noSuchMethod( Invocation.method( @@ -1175,15 +1188,15 @@ class MockBitcoinWallet extends _i1.Mock implements _i24.BitcoinWallet { ), ) as _i11.Balance); @override - _i21.Future updateCachedBalanceSecondary(_i11.Balance? balance) => + _i22.Future updateCachedBalanceSecondary(_i11.Balance? balance) => (super.noSuchMethod( Invocation.method( #updateCachedBalanceSecondary, [balance], ), - returnValue: _i21.Future.value(), - returnValueForMissingStub: _i21.Future.value(), - ) as _i21.Future); + returnValue: _i22.Future.value(), + returnValueForMissingStub: _i22.Future.value(), + ) as _i22.Future); @override List getWalletTokenContractAddresses() => (super.noSuchMethod( Invocation.method( @@ -1193,16 +1206,16 @@ class MockBitcoinWallet extends _i1.Mock implements _i24.BitcoinWallet { returnValue: [], ) as List); @override - _i21.Future updateWalletTokenContractAddresses( + _i22.Future updateWalletTokenContractAddresses( List? contractAddresses) => (super.noSuchMethod( Invocation.method( #updateWalletTokenContractAddresses, [contractAddresses], ), - returnValue: _i21.Future.value(), - returnValueForMissingStub: _i21.Future.value(), - ) as _i21.Future); + returnValue: _i22.Future.value(), + returnValueForMissingStub: _i22.Future.value(), + ) as _i22.Future); @override void initWalletDB({_i12.MainDB? mockableOverride}) => super.noSuchMethod( Invocation.method( @@ -1213,11 +1226,11 @@ class MockBitcoinWallet extends _i1.Mock implements _i24.BitcoinWallet { returnValueForMissingStub: null, ); @override - _i21.Future<_i15.Tuple2<_i17.Transaction, _i17.Address>> parseTransaction( + _i22.Future<_i15.Tuple2<_i17.Transaction, _i17.Address>> parseTransaction( Map? txData, dynamic electrumxClient, List<_i17.Address>? myAddresses, - _i20.Coin? coin, + _i21.Coin? coin, int? minConfirms, String? walletId, ) => @@ -1234,7 +1247,7 @@ class MockBitcoinWallet extends _i1.Mock implements _i24.BitcoinWallet { ], ), returnValue: - _i21.Future<_i15.Tuple2<_i17.Transaction, _i17.Address>>.value( + _i22.Future<_i15.Tuple2<_i17.Transaction, _i17.Address>>.value( _FakeTuple2_13<_i17.Transaction, _i17.Address>( this, Invocation.method( @@ -1249,37 +1262,37 @@ class MockBitcoinWallet extends _i1.Mock implements _i24.BitcoinWallet { ], ), )), - ) as _i21.Future<_i15.Tuple2<_i17.Transaction, _i17.Address>>); + ) as _i22.Future<_i15.Tuple2<_i17.Transaction, _i17.Address>>); @override void initPaynymWalletInterface({ required String? walletId, required String? walletName, required _i13.NetworkType? network, - required _i20.Coin? coin, + required _i21.Coin? coin, required _i12.MainDB? db, required _i9.ElectrumX? electrumXClient, - required _i27.SecureStorageInterface? secureStorage, + required _i28.SecureStorageInterface? secureStorage, required int? dustLimit, required int? dustLimitP2PKH, required int? minConfirms, - required _i21.Future Function()? getMnemonicString, - required _i21.Future Function()? getMnemonicPassphrase, - required _i21.Future Function()? getChainHeight, - required _i21.Future Function()? getCurrentChangeAddress, + required _i22.Future Function()? getMnemonicString, + required _i22.Future Function()? getMnemonicPassphrase, + required _i22.Future Function()? getChainHeight, + required _i22.Future Function()? getCurrentChangeAddress, required int Function({ required int feeRatePerKB, required int vSize, })? estimateTxFee, - required _i21.Future> Function({ + required _i22.Future> Function({ required String address, required _i14.Amount amount, Map? args, })? prepareSend, - required _i21.Future Function({required String address})? getTxCount, - required _i21.Future> Function(List<_i17.UTXO>)? + required _i22.Future Function({required String address})? getTxCount, + required _i22.Future> Function(List<_i17.UTXO>)? fetchBuildTxData, - required _i21.Future Function()? refresh, - required _i21.Future Function()? checkChangeAddressForTransactions, + required _i22.Future Function()? refresh, + required _i22.Future Function()? checkChangeAddressForTransactions, }) => super.noSuchMethod( Invocation.method( @@ -1312,21 +1325,21 @@ class MockBitcoinWallet extends _i1.Mock implements _i24.BitcoinWallet { returnValueForMissingStub: null, ); @override - _i21.Future<_i16.BIP32> getBip47BaseNode() => (super.noSuchMethod( + _i22.Future<_i16.BIP32> getBip47BaseNode() => (super.noSuchMethod( Invocation.method( #getBip47BaseNode, [], ), - returnValue: _i21.Future<_i16.BIP32>.value(_FakeBIP32_14( + returnValue: _i22.Future<_i16.BIP32>.value(_FakeBIP32_14( this, Invocation.method( #getBip47BaseNode, [], ), )), - ) as _i21.Future<_i16.BIP32>); + ) as _i22.Future<_i16.BIP32>); @override - _i21.Future<_i28.Uint8List> getPrivateKeyForPaynymReceivingAddress({ + _i22.Future<_i29.Uint8List> getPrivateKeyForPaynymReceivingAddress({ required String? paymentCodeString, required int? index, }) => @@ -1339,10 +1352,10 @@ class MockBitcoinWallet extends _i1.Mock implements _i24.BitcoinWallet { #index: index, }, ), - returnValue: _i21.Future<_i28.Uint8List>.value(_i28.Uint8List(0)), - ) as _i21.Future<_i28.Uint8List>); + returnValue: _i22.Future<_i29.Uint8List>.value(_i29.Uint8List(0)), + ) as _i22.Future<_i29.Uint8List>); @override - _i21.Future<_i17.Address> currentReceivingPaynymAddress({ + _i22.Future<_i17.Address> currentReceivingPaynymAddress({ required _i18.PaymentCode? sender, required bool? isSegwit, }) => @@ -1355,7 +1368,7 @@ class MockBitcoinWallet extends _i1.Mock implements _i24.BitcoinWallet { #isSegwit: isSegwit, }, ), - returnValue: _i21.Future<_i17.Address>.value(_FakeAddress_15( + returnValue: _i22.Future<_i17.Address>.value(_FakeAddress_15( this, Invocation.method( #currentReceivingPaynymAddress, @@ -1366,9 +1379,9 @@ class MockBitcoinWallet extends _i1.Mock implements _i24.BitcoinWallet { }, ), )), - ) as _i21.Future<_i17.Address>); + ) as _i22.Future<_i17.Address>); @override - _i21.Future checkCurrentPaynymReceivingAddressForTransactions({ + _i22.Future checkCurrentPaynymReceivingAddressForTransactions({ required _i18.PaymentCode? sender, required bool? isSegwit, }) => @@ -1381,42 +1394,42 @@ class MockBitcoinWallet extends _i1.Mock implements _i24.BitcoinWallet { #isSegwit: isSegwit, }, ), - returnValue: _i21.Future.value(), - returnValueForMissingStub: _i21.Future.value(), - ) as _i21.Future); + returnValue: _i22.Future.value(), + returnValueForMissingStub: _i22.Future.value(), + ) as _i22.Future); @override - _i21.Future checkAllCurrentReceivingPaynymAddressesForTransactions() => + _i22.Future checkAllCurrentReceivingPaynymAddressesForTransactions() => (super.noSuchMethod( Invocation.method( #checkAllCurrentReceivingPaynymAddressesForTransactions, [], ), - returnValue: _i21.Future.value(), - returnValueForMissingStub: _i21.Future.value(), - ) as _i21.Future); + returnValue: _i22.Future.value(), + returnValueForMissingStub: _i22.Future.value(), + ) as _i22.Future); @override - _i21.Future<_i16.BIP32> deriveNotificationBip32Node() => (super.noSuchMethod( + _i22.Future<_i16.BIP32> deriveNotificationBip32Node() => (super.noSuchMethod( Invocation.method( #deriveNotificationBip32Node, [], ), - returnValue: _i21.Future<_i16.BIP32>.value(_FakeBIP32_14( + returnValue: _i22.Future<_i16.BIP32>.value(_FakeBIP32_14( this, Invocation.method( #deriveNotificationBip32Node, [], ), )), - ) as _i21.Future<_i16.BIP32>); + ) as _i22.Future<_i16.BIP32>); @override - _i21.Future<_i18.PaymentCode> getPaymentCode({required bool? isSegwit}) => + _i22.Future<_i18.PaymentCode> getPaymentCode({required bool? isSegwit}) => (super.noSuchMethod( Invocation.method( #getPaymentCode, [], {#isSegwit: isSegwit}, ), - returnValue: _i21.Future<_i18.PaymentCode>.value(_FakePaymentCode_16( + returnValue: _i22.Future<_i18.PaymentCode>.value(_FakePaymentCode_16( this, Invocation.method( #getPaymentCode, @@ -1424,27 +1437,27 @@ class MockBitcoinWallet extends _i1.Mock implements _i24.BitcoinWallet { {#isSegwit: isSegwit}, ), )), - ) as _i21.Future<_i18.PaymentCode>); + ) as _i22.Future<_i18.PaymentCode>); @override - _i21.Future<_i28.Uint8List> signWithNotificationKey(_i28.Uint8List? data) => + _i22.Future<_i29.Uint8List> signWithNotificationKey(_i29.Uint8List? data) => (super.noSuchMethod( Invocation.method( #signWithNotificationKey, [data], ), - returnValue: _i21.Future<_i28.Uint8List>.value(_i28.Uint8List(0)), - ) as _i21.Future<_i28.Uint8List>); + returnValue: _i22.Future<_i29.Uint8List>.value(_i29.Uint8List(0)), + ) as _i22.Future<_i29.Uint8List>); @override - _i21.Future signStringWithNotificationKey(String? data) => + _i22.Future signStringWithNotificationKey(String? data) => (super.noSuchMethod( Invocation.method( #signStringWithNotificationKey, [data], ), - returnValue: _i21.Future.value(''), - ) as _i21.Future); + returnValue: _i22.Future.value(''), + ) as _i22.Future); @override - _i21.Future> preparePaymentCodeSend({ + _i22.Future> preparePaymentCodeSend({ required _i18.PaymentCode? paymentCode, required bool? isSegwit, required _i14.Amount? amount, @@ -1462,10 +1475,10 @@ class MockBitcoinWallet extends _i1.Mock implements _i24.BitcoinWallet { }, ), returnValue: - _i21.Future>.value({}), - ) as _i21.Future>); + _i22.Future>.value({}), + ) as _i22.Future>); @override - _i21.Future<_i17.Address> nextUnusedSendAddressFrom({ + _i22.Future<_i17.Address> nextUnusedSendAddressFrom({ required _i18.PaymentCode? pCode, required bool? isSegwit, required _i16.BIP32? privateKeyNode, @@ -1482,7 +1495,7 @@ class MockBitcoinWallet extends _i1.Mock implements _i24.BitcoinWallet { #startIndex: startIndex, }, ), - returnValue: _i21.Future<_i17.Address>.value(_FakeAddress_15( + returnValue: _i22.Future<_i17.Address>.value(_FakeAddress_15( this, Invocation.method( #nextUnusedSendAddressFrom, @@ -1495,9 +1508,9 @@ class MockBitcoinWallet extends _i1.Mock implements _i24.BitcoinWallet { }, ), )), - ) as _i21.Future<_i17.Address>); + ) as _i22.Future<_i17.Address>); @override - _i21.Future> prepareNotificationTx({ + _i22.Future> prepareNotificationTx({ required int? selectedTxFeeRate, required String? targetPaymentCodeString, int? additionalOutputs = 0, @@ -1515,10 +1528,10 @@ class MockBitcoinWallet extends _i1.Mock implements _i24.BitcoinWallet { }, ), returnValue: - _i21.Future>.value({}), - ) as _i21.Future>); + _i22.Future>.value({}), + ) as _i22.Future>); @override - _i21.Future broadcastNotificationTx( + _i22.Future broadcastNotificationTx( {required Map? preparedTx}) => (super.noSuchMethod( Invocation.method( @@ -1526,19 +1539,19 @@ class MockBitcoinWallet extends _i1.Mock implements _i24.BitcoinWallet { [], {#preparedTx: preparedTx}, ), - returnValue: _i21.Future.value(''), - ) as _i21.Future); + returnValue: _i22.Future.value(''), + ) as _i22.Future); @override - _i21.Future hasConnected(String? paymentCodeString) => + _i22.Future hasConnected(String? paymentCodeString) => (super.noSuchMethod( Invocation.method( #hasConnected, [paymentCodeString], ), - returnValue: _i21.Future.value(false), - ) as _i21.Future); + returnValue: _i22.Future.value(false), + ) as _i22.Future); @override - _i21.Future<_i18.PaymentCode?> unBlindedPaymentCodeFromTransaction( + _i22.Future<_i18.PaymentCode?> unBlindedPaymentCodeFromTransaction( {required _i17.Transaction? transaction}) => (super.noSuchMethod( Invocation.method( @@ -1546,10 +1559,10 @@ class MockBitcoinWallet extends _i1.Mock implements _i24.BitcoinWallet { [], {#transaction: transaction}, ), - returnValue: _i21.Future<_i18.PaymentCode?>.value(), - ) as _i21.Future<_i18.PaymentCode?>); + returnValue: _i22.Future<_i18.PaymentCode?>.value(), + ) as _i22.Future<_i18.PaymentCode?>); @override - _i21.Future<_i18.PaymentCode?> unBlindedPaymentCodeFromTransactionBad( + _i22.Future<_i18.PaymentCode?> unBlindedPaymentCodeFromTransactionBad( {required _i17.Transaction? transaction}) => (super.noSuchMethod( Invocation.method( @@ -1557,31 +1570,31 @@ class MockBitcoinWallet extends _i1.Mock implements _i24.BitcoinWallet { [], {#transaction: transaction}, ), - returnValue: _i21.Future<_i18.PaymentCode?>.value(), - ) as _i21.Future<_i18.PaymentCode?>); + returnValue: _i22.Future<_i18.PaymentCode?>.value(), + ) as _i22.Future<_i18.PaymentCode?>); @override - _i21.Future> + _i22.Future> getAllPaymentCodesFromNotificationTransactions() => (super.noSuchMethod( Invocation.method( #getAllPaymentCodesFromNotificationTransactions, [], ), returnValue: - _i21.Future>.value(<_i18.PaymentCode>[]), - ) as _i21.Future>); + _i22.Future>.value(<_i18.PaymentCode>[]), + ) as _i22.Future>); @override - _i21.Future checkForNotificationTransactionsTo( + _i22.Future checkForNotificationTransactionsTo( Set? otherCodeStrings) => (super.noSuchMethod( Invocation.method( #checkForNotificationTransactionsTo, [otherCodeStrings], ), - returnValue: _i21.Future.value(), - returnValueForMissingStub: _i21.Future.value(), - ) as _i21.Future); + returnValue: _i22.Future.value(), + returnValueForMissingStub: _i22.Future.value(), + ) as _i22.Future); @override - _i21.Future restoreAllHistory({ + _i22.Future restoreAllHistory({ required int? maxUnusedAddressGap, required int? maxNumberOfIndexesToCheck, required Set? paymentCodeStrings, @@ -1596,11 +1609,11 @@ class MockBitcoinWallet extends _i1.Mock implements _i24.BitcoinWallet { #paymentCodeStrings: paymentCodeStrings, }, ), - returnValue: _i21.Future.value(), - returnValueForMissingStub: _i21.Future.value(), - ) as _i21.Future); + returnValue: _i22.Future.value(), + returnValueForMissingStub: _i22.Future.value(), + ) as _i22.Future); @override - _i21.Future restoreHistoryWith({ + _i22.Future restoreHistoryWith({ required _i18.PaymentCode? other, required bool? checkSegwitAsWell, required int? maxUnusedAddressGap, @@ -1617,58 +1630,58 @@ class MockBitcoinWallet extends _i1.Mock implements _i24.BitcoinWallet { #maxNumberOfIndexesToCheck: maxNumberOfIndexesToCheck, }, ), - returnValue: _i21.Future.value(), - returnValueForMissingStub: _i21.Future.value(), - ) as _i21.Future); + returnValue: _i22.Future.value(), + returnValueForMissingStub: _i22.Future.value(), + ) as _i22.Future); @override - _i21.Future<_i17.Address> getMyNotificationAddress() => (super.noSuchMethod( + _i22.Future<_i17.Address> getMyNotificationAddress() => (super.noSuchMethod( Invocation.method( #getMyNotificationAddress, [], ), - returnValue: _i21.Future<_i17.Address>.value(_FakeAddress_15( + returnValue: _i22.Future<_i17.Address>.value(_FakeAddress_15( this, Invocation.method( #getMyNotificationAddress, [], ), )), - ) as _i21.Future<_i17.Address>); + ) as _i22.Future<_i17.Address>); @override - _i21.Future> lookupKey(String? paymentCodeString) => + _i22.Future> lookupKey(String? paymentCodeString) => (super.noSuchMethod( Invocation.method( #lookupKey, [paymentCodeString], ), - returnValue: _i21.Future>.value([]), - ) as _i21.Future>); + returnValue: _i22.Future>.value([]), + ) as _i22.Future>); @override - _i21.Future paymentCodeStringByKey(String? key) => + _i22.Future paymentCodeStringByKey(String? key) => (super.noSuchMethod( Invocation.method( #paymentCodeStringByKey, [key], ), - returnValue: _i21.Future.value(), - ) as _i21.Future); + returnValue: _i22.Future.value(), + ) as _i22.Future); @override - _i21.Future storeCode(String? paymentCodeString) => + _i22.Future storeCode(String? paymentCodeString) => (super.noSuchMethod( Invocation.method( #storeCode, [paymentCodeString], ), - returnValue: _i21.Future.value(''), - ) as _i21.Future); + returnValue: _i22.Future.value(''), + ) as _i22.Future); @override void initCoinControlInterface({ required String? walletId, required String? walletName, - required _i20.Coin? coin, + required _i21.Coin? coin, required _i12.MainDB? db, - required _i21.Future Function()? getChainHeight, - required _i21.Future Function(_i11.Balance)? refreshedBalanceCallback, + required _i22.Future Function()? getChainHeight, + required _i22.Future Function(_i11.Balance)? refreshedBalanceCallback, }) => super.noSuchMethod( Invocation.method( @@ -1686,22 +1699,22 @@ class MockBitcoinWallet extends _i1.Mock implements _i24.BitcoinWallet { returnValueForMissingStub: null, ); @override - _i21.Future refreshBalance({bool? notify = false}) => + _i22.Future refreshBalance({bool? notify = false}) => (super.noSuchMethod( Invocation.method( #refreshBalance, [], {#notify: notify}, ), - returnValue: _i21.Future.value(), - returnValueForMissingStub: _i21.Future.value(), - ) as _i21.Future); + returnValue: _i22.Future.value(), + returnValueForMissingStub: _i22.Future.value(), + ) as _i22.Future); } /// A class which mocks [LocaleService]. /// /// See the documentation for Mockito's code generation for more information. -class MockLocaleService extends _i1.Mock implements _i29.LocaleService { +class MockLocaleService extends _i1.Mock implements _i30.LocaleService { MockLocaleService() { _i1.throwOnMissingStub(this); } @@ -1717,17 +1730,17 @@ class MockLocaleService extends _i1.Mock implements _i29.LocaleService { returnValue: false, ) as bool); @override - _i21.Future loadLocale({bool? notify = true}) => (super.noSuchMethod( + _i22.Future loadLocale({bool? notify = true}) => (super.noSuchMethod( Invocation.method( #loadLocale, [], {#notify: notify}, ), - returnValue: _i21.Future.value(), - returnValueForMissingStub: _i21.Future.value(), - ) as _i21.Future); + returnValue: _i22.Future.value(), + returnValueForMissingStub: _i22.Future.value(), + ) as _i22.Future); @override - void addListener(_i23.VoidCallback? listener) => super.noSuchMethod( + void addListener(_i24.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #addListener, [listener], @@ -1735,7 +1748,7 @@ class MockLocaleService extends _i1.Mock implements _i29.LocaleService { returnValueForMissingStub: null, ); @override - void removeListener(_i23.VoidCallback? listener) => super.noSuchMethod( + void removeListener(_i24.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #removeListener, [listener], @@ -1763,11 +1776,27 @@ class MockLocaleService extends _i1.Mock implements _i29.LocaleService { /// A class which mocks [ThemeService]. /// /// See the documentation for Mockito's code generation for more information. -class MockThemeService extends _i1.Mock implements _i30.ThemeService { +class MockThemeService extends _i1.Mock implements _i31.ThemeService { MockThemeService() { _i1.throwOnMissingStub(this); } + @override + _i19.HTTP get client => (super.noSuchMethod( + Invocation.getter(#client), + returnValue: _FakeHTTP_17( + this, + Invocation.getter(#client), + ), + ) as _i19.HTTP); + @override + set client(_i19.HTTP? _client) => super.noSuchMethod( + Invocation.setter( + #client, + _client, + ), + returnValueForMissingStub: null, + ); @override _i12.MainDB get db => (super.noSuchMethod( Invocation.getter(#db), @@ -1777,10 +1806,10 @@ class MockThemeService extends _i1.Mock implements _i30.ThemeService { ), ) as _i12.MainDB); @override - List<_i31.StackTheme> get installedThemes => (super.noSuchMethod( + List<_i32.StackTheme> get installedThemes => (super.noSuchMethod( Invocation.getter(#installedThemes), - returnValue: <_i31.StackTheme>[], - ) as List<_i31.StackTheme>); + returnValue: <_i32.StackTheme>[], + ) as List<_i32.StackTheme>); @override void init(_i12.MainDB? db) => super.noSuchMethod( Invocation.method( @@ -1790,71 +1819,71 @@ class MockThemeService extends _i1.Mock implements _i30.ThemeService { returnValueForMissingStub: null, ); @override - _i21.Future install({required _i28.Uint8List? themeArchiveData}) => + _i22.Future install({required _i29.Uint8List? themeArchiveData}) => (super.noSuchMethod( Invocation.method( #install, [], {#themeArchiveData: themeArchiveData}, ), - returnValue: _i21.Future.value(), - returnValueForMissingStub: _i21.Future.value(), - ) as _i21.Future); + returnValue: _i22.Future.value(), + returnValueForMissingStub: _i22.Future.value(), + ) as _i22.Future); @override - _i21.Future remove({required String? themeId}) => (super.noSuchMethod( + _i22.Future remove({required String? themeId}) => (super.noSuchMethod( Invocation.method( #remove, [], {#themeId: themeId}, ), - returnValue: _i21.Future.value(), - returnValueForMissingStub: _i21.Future.value(), - ) as _i21.Future); + returnValue: _i22.Future.value(), + returnValueForMissingStub: _i22.Future.value(), + ) as _i22.Future); @override - _i21.Future checkDefaultThemesOnStartup() => (super.noSuchMethod( + _i22.Future checkDefaultThemesOnStartup() => (super.noSuchMethod( Invocation.method( #checkDefaultThemesOnStartup, [], ), - returnValue: _i21.Future.value(), - returnValueForMissingStub: _i21.Future.value(), - ) as _i21.Future); + returnValue: _i22.Future.value(), + returnValueForMissingStub: _i22.Future.value(), + ) as _i22.Future); @override - _i21.Future verifyInstalled({required String? themeId}) => + _i22.Future verifyInstalled({required String? themeId}) => (super.noSuchMethod( Invocation.method( #verifyInstalled, [], {#themeId: themeId}, ), - returnValue: _i21.Future.value(false), - ) as _i21.Future); + returnValue: _i22.Future.value(false), + ) as _i22.Future); @override - _i21.Future> fetchThemes() => + _i22.Future> fetchThemes() => (super.noSuchMethod( Invocation.method( #fetchThemes, [], ), - returnValue: _i21.Future>.value( - <_i30.StackThemeMetaData>[]), - ) as _i21.Future>); + returnValue: _i22.Future>.value( + <_i31.StackThemeMetaData>[]), + ) as _i22.Future>); @override - _i21.Future<_i28.Uint8List> fetchTheme( - {required _i30.StackThemeMetaData? themeMetaData}) => + _i22.Future<_i29.Uint8List> fetchTheme( + {required _i31.StackThemeMetaData? themeMetaData}) => (super.noSuchMethod( Invocation.method( #fetchTheme, [], {#themeMetaData: themeMetaData}, ), - returnValue: _i21.Future<_i28.Uint8List>.value(_i28.Uint8List(0)), - ) as _i21.Future<_i28.Uint8List>); + returnValue: _i22.Future<_i29.Uint8List>.value(_i29.Uint8List(0)), + ) as _i22.Future<_i29.Uint8List>); @override - _i31.StackTheme? getTheme({required String? themeId}) => + _i32.StackTheme? getTheme({required String? themeId}) => (super.noSuchMethod(Invocation.method( #getTheme, [], {#themeId: themeId}, - )) as _i31.StackTheme?); + )) as _i32.StackTheme?); } 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 36d369769..ef519d4c9 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 @@ -1072,10 +1072,12 @@ class MockBitcoinWallet extends _i1.Mock implements _i26.BitcoinWallet { returnValueForMissingStub: null, ); @override - _i23.Future initializeNew() => (super.noSuchMethod( + _i23.Future initializeNew( + ({String mnemonicPassphrase, int wordCount})? data) => + (super.noSuchMethod( Invocation.method( #initializeNew, - [], + [data], ), returnValue: _i23.Future.value(), returnValueForMissingStub: _i23.Future.value(), @@ -2411,10 +2413,12 @@ class MockManager extends _i1.Mock implements _i6.Manager { returnValue: _i23.Future.value(false), ) as _i23.Future); @override - _i23.Future initializeNew() => (super.noSuchMethod( + _i23.Future initializeNew( + ({String mnemonicPassphrase, int wordCount})? data) => + (super.noSuchMethod( Invocation.method( #initializeNew, - [], + [data], ), returnValue: _i23.Future.value(), returnValueForMissingStub: _i23.Future.value(), @@ -2764,10 +2768,12 @@ class MockCoinServiceAPI extends _i1.Mock implements _i20.CoinServiceAPI { returnValueForMissingStub: _i23.Future.value(), ) as _i23.Future); @override - _i23.Future initializeNew() => (super.noSuchMethod( + _i23.Future initializeNew( + ({String mnemonicPassphrase, int wordCount})? data) => + (super.noSuchMethod( Invocation.method( #initializeNew, - [], + [data], ), returnValue: _i23.Future.value(), returnValueForMissingStub: _i23.Future.value(), diff --git a/test/widget_tests/wallet_info_row/wallet_info_row_test.dart b/test/widget_tests/wallet_info_row/wallet_info_row_test.dart index c3fb2eef5..db4966a50 100644 --- a/test/widget_tests/wallet_info_row/wallet_info_row_test.dart +++ b/test/widget_tests/wallet_info_row/wallet_info_row_test.dart @@ -1,3 +1,5 @@ +import 'dart:io'; + import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_test/flutter_test.dart'; @@ -12,6 +14,7 @@ import 'package:stackwallet/services/coins/manager.dart'; import 'package:stackwallet/services/node_service.dart'; import 'package:stackwallet/services/wallets.dart'; import 'package:stackwallet/services/wallets_service.dart'; +import 'package:stackwallet/themes/coin_icon_provider.dart'; import 'package:stackwallet/themes/stack_colors.dart'; import 'package:stackwallet/themes/theme_service.dart'; import 'package:stackwallet/utilities/amount/amount.dart'; @@ -65,6 +68,10 @@ void main() { overrides: [ walletsChangeNotifierProvider.overrideWithValue(wallets), pThemeService.overrideWithValue(mockThemeService), + coinIconProvider.overrideWithProvider( + (argument) => Provider((_) => + "${Directory.current.path}/test/sample_data/light/assets/dummy.svg"), + ), ], child: MaterialApp( theme: ThemeData( 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 357672d7a..7a14a4547 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 @@ -3,41 +3,42 @@ // Do not manually edit this file. // ignore_for_file: no_leading_underscores_for_library_prefixes -import 'dart:async' as _i23; -import 'dart:typed_data' as _i28; -import 'dart:ui' as _i25; +import 'dart:async' as _i24; +import 'dart:typed_data' as _i29; +import 'dart:ui' as _i26; -import 'package:bip32/bip32.dart' as _i16; -import 'package:bip47/bip47.dart' as _i18; -import 'package:bitcoindart/bitcoindart.dart' as _i13; +import 'package:bip32/bip32.dart' as _i17; +import 'package:bip47/bip47.dart' as _i19; +import 'package:bitcoindart/bitcoindart.dart' as _i14; import 'package:flutter/foundation.dart' as _i4; import 'package:flutter_riverpod/flutter_riverpod.dart' as _i5; import 'package:mockito/mockito.dart' as _i1; -import 'package:stackwallet/db/isar/main_db.dart' as _i7; -import 'package:stackwallet/electrumx_rpc/cached_electrumx.dart' as _i11; -import 'package:stackwallet/electrumx_rpc/electrumx.dart' as _i10; -import 'package:stackwallet/models/balance.dart' as _i12; -import 'package:stackwallet/models/isar/models/isar_models.dart' as _i17; -import 'package:stackwallet/models/isar/stack_theme.dart' as _i27; -import 'package:stackwallet/models/node_model.dart' as _i32; -import 'package:stackwallet/models/paymint/fee_object_model.dart' as _i9; -import 'package:stackwallet/models/signing_data.dart' as _i31; -import 'package:stackwallet/services/coins/bitcoin/bitcoin_wallet.dart' as _i29; -import 'package:stackwallet/services/coins/coin_service.dart' as _i20; +import 'package:stackwallet/db/isar/main_db.dart' as _i8; +import 'package:stackwallet/electrumx_rpc/cached_electrumx.dart' as _i12; +import 'package:stackwallet/electrumx_rpc/electrumx.dart' as _i11; +import 'package:stackwallet/models/balance.dart' as _i13; +import 'package:stackwallet/models/isar/models/isar_models.dart' as _i18; +import 'package:stackwallet/models/isar/stack_theme.dart' as _i28; +import 'package:stackwallet/models/node_model.dart' as _i33; +import 'package:stackwallet/models/paymint/fee_object_model.dart' as _i10; +import 'package:stackwallet/models/signing_data.dart' as _i32; +import 'package:stackwallet/networking/http.dart' as _i7; +import 'package:stackwallet/services/coins/bitcoin/bitcoin_wallet.dart' as _i30; +import 'package:stackwallet/services/coins/coin_service.dart' as _i21; import 'package:stackwallet/services/coins/manager.dart' as _i6; import 'package:stackwallet/services/node_service.dart' as _i3; import 'package:stackwallet/services/transaction_notification_tracker.dart' - as _i8; -import 'package:stackwallet/services/wallets.dart' as _i21; + as _i9; +import 'package:stackwallet/services/wallets.dart' as _i22; import 'package:stackwallet/services/wallets_service.dart' as _i2; -import 'package:stackwallet/themes/theme_service.dart' as _i26; -import 'package:stackwallet/utilities/amount/amount.dart' as _i14; -import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i22; -import 'package:stackwallet/utilities/enums/derive_path_type_enum.dart' as _i30; +import 'package:stackwallet/themes/theme_service.dart' as _i27; +import 'package:stackwallet/utilities/amount/amount.dart' as _i15; +import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i23; +import 'package:stackwallet/utilities/enums/derive_path_type_enum.dart' as _i31; import 'package:stackwallet/utilities/flutter_secure_storage_interface.dart' - as _i19; -import 'package:stackwallet/utilities/prefs.dart' as _i24; -import 'package:tuple/tuple.dart' as _i15; + as _i20; +import 'package:stackwallet/utilities/prefs.dart' as _i25; +import 'package:tuple/tuple.dart' as _i16; // ignore_for_file: type=lint // ignore_for_file: avoid_redundant_argument_values @@ -92,8 +93,8 @@ class _FakeManager_3 extends _i1.SmartFake implements _i6.Manager { ); } -class _FakeMainDB_4 extends _i1.SmartFake implements _i7.MainDB { - _FakeMainDB_4( +class _FakeHTTP_4 extends _i1.SmartFake implements _i7.HTTP { + _FakeHTTP_4( Object parent, Invocation parentInvocation, ) : super( @@ -102,9 +103,8 @@ class _FakeMainDB_4 extends _i1.SmartFake implements _i7.MainDB { ); } -class _FakeTransactionNotificationTracker_5 extends _i1.SmartFake - implements _i8.TransactionNotificationTracker { - _FakeTransactionNotificationTracker_5( +class _FakeMainDB_5 extends _i1.SmartFake implements _i8.MainDB { + _FakeMainDB_5( Object parent, Invocation parentInvocation, ) : super( @@ -113,8 +113,9 @@ class _FakeTransactionNotificationTracker_5 extends _i1.SmartFake ); } -class _FakeFeeObject_6 extends _i1.SmartFake implements _i9.FeeObject { - _FakeFeeObject_6( +class _FakeTransactionNotificationTracker_6 extends _i1.SmartFake + implements _i9.TransactionNotificationTracker { + _FakeTransactionNotificationTracker_6( Object parent, Invocation parentInvocation, ) : super( @@ -123,8 +124,8 @@ class _FakeFeeObject_6 extends _i1.SmartFake implements _i9.FeeObject { ); } -class _FakeElectrumX_7 extends _i1.SmartFake implements _i10.ElectrumX { - _FakeElectrumX_7( +class _FakeFeeObject_7 extends _i1.SmartFake implements _i10.FeeObject { + _FakeFeeObject_7( Object parent, Invocation parentInvocation, ) : super( @@ -133,9 +134,8 @@ class _FakeElectrumX_7 extends _i1.SmartFake implements _i10.ElectrumX { ); } -class _FakeCachedElectrumX_8 extends _i1.SmartFake - implements _i11.CachedElectrumX { - _FakeCachedElectrumX_8( +class _FakeElectrumX_8 extends _i1.SmartFake implements _i11.ElectrumX { + _FakeElectrumX_8( Object parent, Invocation parentInvocation, ) : super( @@ -144,8 +144,9 @@ class _FakeCachedElectrumX_8 extends _i1.SmartFake ); } -class _FakeBalance_9 extends _i1.SmartFake implements _i12.Balance { - _FakeBalance_9( +class _FakeCachedElectrumX_9 extends _i1.SmartFake + implements _i12.CachedElectrumX { + _FakeCachedElectrumX_9( Object parent, Invocation parentInvocation, ) : super( @@ -154,8 +155,8 @@ class _FakeBalance_9 extends _i1.SmartFake implements _i12.Balance { ); } -class _FakeNetworkType_10 extends _i1.SmartFake implements _i13.NetworkType { - _FakeNetworkType_10( +class _FakeBalance_10 extends _i1.SmartFake implements _i13.Balance { + _FakeBalance_10( Object parent, Invocation parentInvocation, ) : super( @@ -164,9 +165,8 @@ class _FakeNetworkType_10 extends _i1.SmartFake implements _i13.NetworkType { ); } -class _FakeElectrumXNode_11 extends _i1.SmartFake - implements _i10.ElectrumXNode { - _FakeElectrumXNode_11( +class _FakeNetworkType_11 extends _i1.SmartFake implements _i14.NetworkType { + _FakeNetworkType_11( Object parent, Invocation parentInvocation, ) : super( @@ -175,8 +175,9 @@ class _FakeElectrumXNode_11 extends _i1.SmartFake ); } -class _FakeAmount_12 extends _i1.SmartFake implements _i14.Amount { - _FakeAmount_12( +class _FakeElectrumXNode_12 extends _i1.SmartFake + implements _i11.ElectrumXNode { + _FakeElectrumXNode_12( Object parent, Invocation parentInvocation, ) : super( @@ -185,9 +186,8 @@ class _FakeAmount_12 extends _i1.SmartFake implements _i14.Amount { ); } -class _FakeTuple2_13 extends _i1.SmartFake - implements _i15.Tuple2 { - _FakeTuple2_13( +class _FakeAmount_13 extends _i1.SmartFake implements _i15.Amount { + _FakeAmount_13( Object parent, Invocation parentInvocation, ) : super( @@ -196,8 +196,9 @@ class _FakeTuple2_13 extends _i1.SmartFake ); } -class _FakeBIP32_14 extends _i1.SmartFake implements _i16.BIP32 { - _FakeBIP32_14( +class _FakeTuple2_14 extends _i1.SmartFake + implements _i16.Tuple2 { + _FakeTuple2_14( Object parent, Invocation parentInvocation, ) : super( @@ -206,8 +207,8 @@ class _FakeBIP32_14 extends _i1.SmartFake implements _i16.BIP32 { ); } -class _FakeAddress_15 extends _i1.SmartFake implements _i17.Address { - _FakeAddress_15( +class _FakeBIP32_15 extends _i1.SmartFake implements _i17.BIP32 { + _FakeBIP32_15( Object parent, Invocation parentInvocation, ) : super( @@ -216,8 +217,8 @@ class _FakeAddress_15 extends _i1.SmartFake implements _i17.Address { ); } -class _FakePaymentCode_16 extends _i1.SmartFake implements _i18.PaymentCode { - _FakePaymentCode_16( +class _FakeAddress_16 extends _i1.SmartFake implements _i18.Address { + _FakeAddress_16( Object parent, Invocation parentInvocation, ) : super( @@ -226,9 +227,8 @@ class _FakePaymentCode_16 extends _i1.SmartFake implements _i18.PaymentCode { ); } -class _FakeSecureStorageInterface_17 extends _i1.SmartFake - implements _i19.SecureStorageInterface { - _FakeSecureStorageInterface_17( +class _FakePaymentCode_17 extends _i1.SmartFake implements _i19.PaymentCode { + _FakePaymentCode_17( Object parent, Invocation parentInvocation, ) : super( @@ -237,9 +237,20 @@ class _FakeSecureStorageInterface_17 extends _i1.SmartFake ); } -class _FakeCoinServiceAPI_18 extends _i1.SmartFake - implements _i20.CoinServiceAPI { - _FakeCoinServiceAPI_18( +class _FakeSecureStorageInterface_18 extends _i1.SmartFake + implements _i20.SecureStorageInterface { + _FakeSecureStorageInterface_18( + Object parent, + Invocation parentInvocation, + ) : super( + parent, + parentInvocation, + ); +} + +class _FakeCoinServiceAPI_19 extends _i1.SmartFake + implements _i21.CoinServiceAPI { + _FakeCoinServiceAPI_19( Object parent, Invocation parentInvocation, ) : super( @@ -251,7 +262,7 @@ class _FakeCoinServiceAPI_18 extends _i1.SmartFake /// A class which mocks [Wallets]. /// /// See the documentation for Mockito's code generation for more information. -class MockWallets extends _i1.Mock implements _i21.Wallets { +class MockWallets extends _i1.Mock implements _i22.Wallets { MockWallets() { _i1.throwOnMissingStub(this); } @@ -318,7 +329,7 @@ class MockWallets extends _i1.Mock implements _i21.Wallets { returnValueForMissingStub: null, ); @override - List getWalletIdsFor({required _i22.Coin? coin}) => + List getWalletIdsFor({required _i23.Coin? coin}) => (super.noSuchMethod( Invocation.method( #getWalletIdsFor, @@ -328,20 +339,20 @@ class MockWallets extends _i1.Mock implements _i21.Wallets { returnValue: [], ) as List); @override - List<_i15.Tuple2<_i22.Coin, List<_i5.ChangeNotifierProvider<_i6.Manager>>>> + List<_i16.Tuple2<_i23.Coin, List<_i5.ChangeNotifierProvider<_i6.Manager>>>> getManagerProvidersByCoin() => (super.noSuchMethod( Invocation.method( #getManagerProvidersByCoin, [], ), - returnValue: <_i15.Tuple2<_i22.Coin, + returnValue: <_i16.Tuple2<_i23.Coin, List<_i5.ChangeNotifierProvider<_i6.Manager>>>>[], ) as List< - _i15.Tuple2<_i22.Coin, + _i16.Tuple2<_i23.Coin, List<_i5.ChangeNotifierProvider<_i6.Manager>>>>); @override List<_i5.ChangeNotifierProvider<_i6.Manager>> getManagerProvidersForCoin( - _i22.Coin? coin) => + _i23.Coin? coin) => (super.noSuchMethod( Invocation.method( #getManagerProvidersForCoin, @@ -405,17 +416,17 @@ class MockWallets extends _i1.Mock implements _i21.Wallets { returnValueForMissingStub: null, ); @override - _i23.Future load(_i24.Prefs? prefs) => (super.noSuchMethod( + _i24.Future load(_i25.Prefs? prefs) => (super.noSuchMethod( Invocation.method( #load, [prefs], ), - returnValue: _i23.Future.value(), - returnValueForMissingStub: _i23.Future.value(), - ) as _i23.Future); + returnValue: _i24.Future.value(), + returnValueForMissingStub: _i24.Future.value(), + ) as _i24.Future); @override - _i23.Future loadAfterStackRestore( - _i24.Prefs? prefs, + _i24.Future loadAfterStackRestore( + _i25.Prefs? prefs, List<_i6.Manager>? managers, ) => (super.noSuchMethod( @@ -426,11 +437,11 @@ class MockWallets extends _i1.Mock implements _i21.Wallets { managers, ], ), - returnValue: _i23.Future.value(), - returnValueForMissingStub: _i23.Future.value(), - ) as _i23.Future); + returnValue: _i24.Future.value(), + returnValueForMissingStub: _i24.Future.value(), + ) as _i24.Future); @override - void addListener(_i25.VoidCallback? listener) => super.noSuchMethod( + void addListener(_i26.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #addListener, [listener], @@ -438,7 +449,7 @@ class MockWallets extends _i1.Mock implements _i21.Wallets { returnValueForMissingStub: null, ); @override - void removeListener(_i25.VoidCallback? listener) => super.noSuchMethod( + void removeListener(_i26.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #removeListener, [listener], @@ -464,19 +475,19 @@ class MockWalletsService extends _i1.Mock implements _i2.WalletsService { } @override - _i23.Future> get walletNames => + _i24.Future> get walletNames => (super.noSuchMethod( Invocation.getter(#walletNames), - returnValue: _i23.Future>.value( + returnValue: _i24.Future>.value( {}), - ) as _i23.Future>); + ) as _i24.Future>); @override bool get hasListeners => (super.noSuchMethod( Invocation.getter(#hasListeners), returnValue: false, ) as bool); @override - _i23.Future renameWallet({ + _i24.Future renameWallet({ required String? from, required String? to, required bool? shouldNotifyListeners, @@ -491,8 +502,8 @@ class MockWalletsService extends _i1.Mock implements _i2.WalletsService { #shouldNotifyListeners: shouldNotifyListeners, }, ), - returnValue: _i23.Future.value(false), - ) as _i23.Future); + returnValue: _i24.Future.value(false), + ) as _i24.Future); @override Map fetchWalletsData() => (super.noSuchMethod( Invocation.method( @@ -502,10 +513,10 @@ class MockWalletsService extends _i1.Mock implements _i2.WalletsService { returnValue: {}, ) as Map); @override - _i23.Future addExistingStackWallet({ + _i24.Future addExistingStackWallet({ required String? name, required String? walletId, - required _i22.Coin? coin, + required _i23.Coin? coin, required bool? shouldNotifyListeners, }) => (super.noSuchMethod( @@ -519,13 +530,13 @@ class MockWalletsService extends _i1.Mock implements _i2.WalletsService { #shouldNotifyListeners: shouldNotifyListeners, }, ), - returnValue: _i23.Future.value(), - returnValueForMissingStub: _i23.Future.value(), - ) as _i23.Future); + returnValue: _i24.Future.value(), + returnValueForMissingStub: _i24.Future.value(), + ) as _i24.Future); @override - _i23.Future addNewWallet({ + _i24.Future addNewWallet({ required String? name, - required _i22.Coin? coin, + required _i23.Coin? coin, required bool? shouldNotifyListeners, }) => (super.noSuchMethod( @@ -538,46 +549,46 @@ class MockWalletsService extends _i1.Mock implements _i2.WalletsService { #shouldNotifyListeners: shouldNotifyListeners, }, ), - returnValue: _i23.Future.value(), - ) as _i23.Future); + returnValue: _i24.Future.value(), + ) as _i24.Future); @override - _i23.Future> getFavoriteWalletIds() => (super.noSuchMethod( + _i24.Future> getFavoriteWalletIds() => (super.noSuchMethod( Invocation.method( #getFavoriteWalletIds, [], ), - returnValue: _i23.Future>.value([]), - ) as _i23.Future>); + returnValue: _i24.Future>.value([]), + ) as _i24.Future>); @override - _i23.Future saveFavoriteWalletIds(List? walletIds) => + _i24.Future saveFavoriteWalletIds(List? walletIds) => (super.noSuchMethod( Invocation.method( #saveFavoriteWalletIds, [walletIds], ), - returnValue: _i23.Future.value(), - returnValueForMissingStub: _i23.Future.value(), - ) as _i23.Future); + returnValue: _i24.Future.value(), + returnValueForMissingStub: _i24.Future.value(), + ) as _i24.Future); @override - _i23.Future addFavorite(String? walletId) => (super.noSuchMethod( + _i24.Future addFavorite(String? walletId) => (super.noSuchMethod( Invocation.method( #addFavorite, [walletId], ), - returnValue: _i23.Future.value(), - returnValueForMissingStub: _i23.Future.value(), - ) as _i23.Future); + returnValue: _i24.Future.value(), + returnValueForMissingStub: _i24.Future.value(), + ) as _i24.Future); @override - _i23.Future removeFavorite(String? walletId) => (super.noSuchMethod( + _i24.Future removeFavorite(String? walletId) => (super.noSuchMethod( Invocation.method( #removeFavorite, [walletId], ), - returnValue: _i23.Future.value(), - returnValueForMissingStub: _i23.Future.value(), - ) as _i23.Future); + returnValue: _i24.Future.value(), + returnValueForMissingStub: _i24.Future.value(), + ) as _i24.Future); @override - _i23.Future moveFavorite({ + _i24.Future moveFavorite({ required int? fromIndex, required int? toIndex, }) => @@ -590,48 +601,48 @@ class MockWalletsService extends _i1.Mock implements _i2.WalletsService { #toIndex: toIndex, }, ), - returnValue: _i23.Future.value(), - returnValueForMissingStub: _i23.Future.value(), - ) as _i23.Future); + returnValue: _i24.Future.value(), + returnValueForMissingStub: _i24.Future.value(), + ) as _i24.Future); @override - _i23.Future checkForDuplicate(String? name) => (super.noSuchMethod( + _i24.Future checkForDuplicate(String? name) => (super.noSuchMethod( Invocation.method( #checkForDuplicate, [name], ), - returnValue: _i23.Future.value(false), - ) as _i23.Future); + returnValue: _i24.Future.value(false), + ) as _i24.Future); @override - _i23.Future getWalletId(String? walletName) => (super.noSuchMethod( + _i24.Future getWalletId(String? walletName) => (super.noSuchMethod( Invocation.method( #getWalletId, [walletName], ), - returnValue: _i23.Future.value(), - ) as _i23.Future); + returnValue: _i24.Future.value(), + ) as _i24.Future); @override - _i23.Future isMnemonicVerified({required String? walletId}) => + _i24.Future isMnemonicVerified({required String? walletId}) => (super.noSuchMethod( Invocation.method( #isMnemonicVerified, [], {#walletId: walletId}, ), - returnValue: _i23.Future.value(false), - ) as _i23.Future); + returnValue: _i24.Future.value(false), + ) as _i24.Future); @override - _i23.Future setMnemonicVerified({required String? walletId}) => + _i24.Future setMnemonicVerified({required String? walletId}) => (super.noSuchMethod( Invocation.method( #setMnemonicVerified, [], {#walletId: walletId}, ), - returnValue: _i23.Future.value(), - returnValueForMissingStub: _i23.Future.value(), - ) as _i23.Future); + returnValue: _i24.Future.value(), + returnValueForMissingStub: _i24.Future.value(), + ) as _i24.Future); @override - _i23.Future deleteWallet( + _i24.Future deleteWallet( String? name, bool? shouldNotifyListeners, ) => @@ -643,20 +654,20 @@ class MockWalletsService extends _i1.Mock implements _i2.WalletsService { shouldNotifyListeners, ], ), - returnValue: _i23.Future.value(0), - ) as _i23.Future); + returnValue: _i24.Future.value(0), + ) as _i24.Future); @override - _i23.Future refreshWallets(bool? shouldNotifyListeners) => + _i24.Future refreshWallets(bool? shouldNotifyListeners) => (super.noSuchMethod( Invocation.method( #refreshWallets, [shouldNotifyListeners], ), - returnValue: _i23.Future.value(), - returnValueForMissingStub: _i23.Future.value(), - ) as _i23.Future); + returnValue: _i24.Future.value(), + returnValueForMissingStub: _i24.Future.value(), + ) as _i24.Future); @override - void addListener(_i25.VoidCallback? listener) => super.noSuchMethod( + void addListener(_i26.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #addListener, [listener], @@ -664,7 +675,7 @@ class MockWalletsService extends _i1.Mock implements _i2.WalletsService { returnValueForMissingStub: null, ); @override - void removeListener(_i25.VoidCallback? listener) => super.noSuchMethod( + void removeListener(_i26.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #removeListener, [listener], @@ -692,26 +703,42 @@ class MockWalletsService extends _i1.Mock implements _i2.WalletsService { /// A class which mocks [ThemeService]. /// /// See the documentation for Mockito's code generation for more information. -class MockThemeService extends _i1.Mock implements _i26.ThemeService { +class MockThemeService extends _i1.Mock implements _i27.ThemeService { MockThemeService() { _i1.throwOnMissingStub(this); } @override - _i7.MainDB get db => (super.noSuchMethod( + _i7.HTTP get client => (super.noSuchMethod( + Invocation.getter(#client), + returnValue: _FakeHTTP_4( + this, + Invocation.getter(#client), + ), + ) as _i7.HTTP); + @override + set client(_i7.HTTP? _client) => super.noSuchMethod( + Invocation.setter( + #client, + _client, + ), + returnValueForMissingStub: null, + ); + @override + _i8.MainDB get db => (super.noSuchMethod( Invocation.getter(#db), - returnValue: _FakeMainDB_4( + returnValue: _FakeMainDB_5( this, Invocation.getter(#db), ), - ) as _i7.MainDB); + ) as _i8.MainDB); @override - List<_i27.StackTheme> get installedThemes => (super.noSuchMethod( + List<_i28.StackTheme> get installedThemes => (super.noSuchMethod( Invocation.getter(#installedThemes), - returnValue: <_i27.StackTheme>[], - ) as List<_i27.StackTheme>); + returnValue: <_i28.StackTheme>[], + ) as List<_i28.StackTheme>); @override - void init(_i7.MainDB? db) => super.noSuchMethod( + void init(_i8.MainDB? db) => super.noSuchMethod( Invocation.method( #init, [db], @@ -719,85 +746,85 @@ class MockThemeService extends _i1.Mock implements _i26.ThemeService { returnValueForMissingStub: null, ); @override - _i23.Future install({required _i28.Uint8List? themeArchiveData}) => + _i24.Future install({required _i29.Uint8List? themeArchiveData}) => (super.noSuchMethod( Invocation.method( #install, [], {#themeArchiveData: themeArchiveData}, ), - returnValue: _i23.Future.value(), - returnValueForMissingStub: _i23.Future.value(), - ) as _i23.Future); + returnValue: _i24.Future.value(), + returnValueForMissingStub: _i24.Future.value(), + ) as _i24.Future); @override - _i23.Future remove({required String? themeId}) => (super.noSuchMethod( + _i24.Future remove({required String? themeId}) => (super.noSuchMethod( Invocation.method( #remove, [], {#themeId: themeId}, ), - returnValue: _i23.Future.value(), - returnValueForMissingStub: _i23.Future.value(), - ) as _i23.Future); + returnValue: _i24.Future.value(), + returnValueForMissingStub: _i24.Future.value(), + ) as _i24.Future); @override - _i23.Future checkDefaultThemesOnStartup() => (super.noSuchMethod( + _i24.Future checkDefaultThemesOnStartup() => (super.noSuchMethod( Invocation.method( #checkDefaultThemesOnStartup, [], ), - returnValue: _i23.Future.value(), - returnValueForMissingStub: _i23.Future.value(), - ) as _i23.Future); + returnValue: _i24.Future.value(), + returnValueForMissingStub: _i24.Future.value(), + ) as _i24.Future); @override - _i23.Future verifyInstalled({required String? themeId}) => + _i24.Future verifyInstalled({required String? themeId}) => (super.noSuchMethod( Invocation.method( #verifyInstalled, [], {#themeId: themeId}, ), - returnValue: _i23.Future.value(false), - ) as _i23.Future); + returnValue: _i24.Future.value(false), + ) as _i24.Future); @override - _i23.Future> fetchThemes() => + _i24.Future> fetchThemes() => (super.noSuchMethod( Invocation.method( #fetchThemes, [], ), - returnValue: _i23.Future>.value( - <_i26.StackThemeMetaData>[]), - ) as _i23.Future>); + returnValue: _i24.Future>.value( + <_i27.StackThemeMetaData>[]), + ) as _i24.Future>); @override - _i23.Future<_i28.Uint8List> fetchTheme( - {required _i26.StackThemeMetaData? themeMetaData}) => + _i24.Future<_i29.Uint8List> fetchTheme( + {required _i27.StackThemeMetaData? themeMetaData}) => (super.noSuchMethod( Invocation.method( #fetchTheme, [], {#themeMetaData: themeMetaData}, ), - returnValue: _i23.Future<_i28.Uint8List>.value(_i28.Uint8List(0)), - ) as _i23.Future<_i28.Uint8List>); + returnValue: _i24.Future<_i29.Uint8List>.value(_i29.Uint8List(0)), + ) as _i24.Future<_i29.Uint8List>); @override - _i27.StackTheme? getTheme({required String? themeId}) => + _i28.StackTheme? getTheme({required String? themeId}) => (super.noSuchMethod(Invocation.method( #getTheme, [], {#themeId: themeId}, - )) as _i27.StackTheme?); + )) as _i28.StackTheme?); } /// A class which mocks [BitcoinWallet]. /// /// See the documentation for Mockito's code generation for more information. -class MockBitcoinWallet extends _i1.Mock implements _i29.BitcoinWallet { +class MockBitcoinWallet extends _i1.Mock implements _i30.BitcoinWallet { MockBitcoinWallet() { _i1.throwOnMissingStub(this); } @override - set timer(_i23.Timer? _timer) => super.noSuchMethod( + set timer(_i24.Timer? _timer) => super.noSuchMethod( Invocation.setter( #timer, _timer, @@ -805,15 +832,15 @@ class MockBitcoinWallet extends _i1.Mock implements _i29.BitcoinWallet { returnValueForMissingStub: null, ); @override - _i8.TransactionNotificationTracker get txTracker => (super.noSuchMethod( + _i9.TransactionNotificationTracker get txTracker => (super.noSuchMethod( Invocation.getter(#txTracker), - returnValue: _FakeTransactionNotificationTracker_5( + returnValue: _FakeTransactionNotificationTracker_6( this, Invocation.getter(#txTracker), ), - ) as _i8.TransactionNotificationTracker); + ) as _i9.TransactionNotificationTracker); @override - set txTracker(_i8.TransactionNotificationTracker? _txTracker) => + set txTracker(_i9.TransactionNotificationTracker? _txTracker) => super.noSuchMethod( Invocation.setter( #txTracker, @@ -874,74 +901,74 @@ class MockBitcoinWallet extends _i1.Mock implements _i29.BitcoinWallet { returnValue: false, ) as bool); @override - _i22.Coin get coin => (super.noSuchMethod( + _i23.Coin get coin => (super.noSuchMethod( Invocation.getter(#coin), - returnValue: _i22.Coin.bitcoin, - ) as _i22.Coin); + returnValue: _i23.Coin.bitcoin, + ) as _i23.Coin); @override - _i23.Future> get utxos => (super.noSuchMethod( + _i24.Future> get utxos => (super.noSuchMethod( Invocation.getter(#utxos), - returnValue: _i23.Future>.value(<_i17.UTXO>[]), - ) as _i23.Future>); + returnValue: _i24.Future>.value(<_i18.UTXO>[]), + ) as _i24.Future>); @override - _i23.Future> get transactions => (super.noSuchMethod( + _i24.Future> get transactions => (super.noSuchMethod( Invocation.getter(#transactions), returnValue: - _i23.Future>.value(<_i17.Transaction>[]), - ) as _i23.Future>); + _i24.Future>.value(<_i18.Transaction>[]), + ) as _i24.Future>); @override - _i23.Future get currentReceivingAddress => (super.noSuchMethod( + _i24.Future get currentReceivingAddress => (super.noSuchMethod( Invocation.getter(#currentReceivingAddress), - returnValue: _i23.Future.value(''), - ) as _i23.Future); + returnValue: _i24.Future.value(''), + ) as _i24.Future); @override - _i23.Future get currentChangeAddress => (super.noSuchMethod( + _i24.Future get currentChangeAddress => (super.noSuchMethod( Invocation.getter(#currentChangeAddress), - returnValue: _i23.Future.value(''), - ) as _i23.Future); + returnValue: _i24.Future.value(''), + ) as _i24.Future); @override - _i23.Future get currentChangeAddressP2PKH => (super.noSuchMethod( + _i24.Future get currentChangeAddressP2PKH => (super.noSuchMethod( Invocation.getter(#currentChangeAddressP2PKH), - returnValue: _i23.Future.value(''), - ) as _i23.Future); + returnValue: _i24.Future.value(''), + ) as _i24.Future); @override bool get hasCalledExit => (super.noSuchMethod( Invocation.getter(#hasCalledExit), returnValue: false, ) as bool); @override - _i23.Future<_i9.FeeObject> get fees => (super.noSuchMethod( + _i24.Future<_i10.FeeObject> get fees => (super.noSuchMethod( Invocation.getter(#fees), - returnValue: _i23.Future<_i9.FeeObject>.value(_FakeFeeObject_6( + returnValue: _i24.Future<_i10.FeeObject>.value(_FakeFeeObject_7( this, Invocation.getter(#fees), )), - ) as _i23.Future<_i9.FeeObject>); + ) as _i24.Future<_i10.FeeObject>); @override - _i23.Future get maxFee => (super.noSuchMethod( + _i24.Future get maxFee => (super.noSuchMethod( Invocation.getter(#maxFee), - returnValue: _i23.Future.value(0), - ) as _i23.Future); + returnValue: _i24.Future.value(0), + ) as _i24.Future); @override - _i23.Future> get mnemonic => (super.noSuchMethod( + _i24.Future> get mnemonic => (super.noSuchMethod( Invocation.getter(#mnemonic), - returnValue: _i23.Future>.value([]), - ) as _i23.Future>); + returnValue: _i24.Future>.value([]), + ) as _i24.Future>); @override - _i23.Future get mnemonicString => (super.noSuchMethod( + _i24.Future get mnemonicString => (super.noSuchMethod( Invocation.getter(#mnemonicString), - returnValue: _i23.Future.value(), - ) as _i23.Future); + returnValue: _i24.Future.value(), + ) as _i24.Future); @override - _i23.Future get mnemonicPassphrase => (super.noSuchMethod( + _i24.Future get mnemonicPassphrase => (super.noSuchMethod( Invocation.getter(#mnemonicPassphrase), - returnValue: _i23.Future.value(), - ) as _i23.Future); + returnValue: _i24.Future.value(), + ) as _i24.Future); @override - _i23.Future get chainHeight => (super.noSuchMethod( + _i24.Future get chainHeight => (super.noSuchMethod( Invocation.getter(#chainHeight), - returnValue: _i23.Future.value(0), - ) as _i23.Future); + returnValue: _i24.Future.value(0), + ) as _i24.Future); @override int get storedChainHeight => (super.noSuchMethod( Invocation.getter(#storedChainHeight), @@ -989,34 +1016,34 @@ class MockBitcoinWallet extends _i1.Mock implements _i29.BitcoinWallet { returnValueForMissingStub: null, ); @override - _i10.ElectrumX get electrumXClient => (super.noSuchMethod( + _i11.ElectrumX get electrumXClient => (super.noSuchMethod( Invocation.getter(#electrumXClient), - returnValue: _FakeElectrumX_7( + returnValue: _FakeElectrumX_8( this, Invocation.getter(#electrumXClient), ), - ) as _i10.ElectrumX); + ) as _i11.ElectrumX); @override - _i11.CachedElectrumX get cachedElectrumXClient => (super.noSuchMethod( + _i12.CachedElectrumX get cachedElectrumXClient => (super.noSuchMethod( Invocation.getter(#cachedElectrumXClient), - returnValue: _FakeCachedElectrumX_8( + returnValue: _FakeCachedElectrumX_9( this, Invocation.getter(#cachedElectrumXClient), ), - ) as _i11.CachedElectrumX); + ) as _i12.CachedElectrumX); @override - _i12.Balance get balance => (super.noSuchMethod( + _i13.Balance get balance => (super.noSuchMethod( Invocation.getter(#balance), - returnValue: _FakeBalance_9( + returnValue: _FakeBalance_10( this, Invocation.getter(#balance), ), - ) as _i12.Balance); + ) as _i13.Balance); @override - _i23.Future get xpub => (super.noSuchMethod( + _i24.Future get xpub => (super.noSuchMethod( Invocation.getter(#xpub), - returnValue: _i23.Future.value(''), - ) as _i23.Future); + returnValue: _i24.Future.value(''), + ) as _i24.Future); @override set onIsActiveWalletChanged(void Function(bool)? _onIsActiveWalletChanged) => super.noSuchMethod( @@ -1027,42 +1054,42 @@ class MockBitcoinWallet extends _i1.Mock implements _i29.BitcoinWallet { returnValueForMissingStub: null, ); @override - _i7.MainDB get db => (super.noSuchMethod( + _i8.MainDB get db => (super.noSuchMethod( Invocation.getter(#db), - returnValue: _FakeMainDB_4( + returnValue: _FakeMainDB_5( this, Invocation.getter(#db), ), - ) as _i7.MainDB); + ) as _i8.MainDB); @override - _i13.NetworkType get networkType => (super.noSuchMethod( + _i14.NetworkType get networkType => (super.noSuchMethod( Invocation.getter(#networkType), - returnValue: _FakeNetworkType_10( + returnValue: _FakeNetworkType_11( this, Invocation.getter(#networkType), ), - ) as _i13.NetworkType); + ) as _i14.NetworkType); @override - _i23.Future exit() => (super.noSuchMethod( + _i24.Future exit() => (super.noSuchMethod( Invocation.method( #exit, [], ), - returnValue: _i23.Future.value(), - returnValueForMissingStub: _i23.Future.value(), - ) as _i23.Future); + returnValue: _i24.Future.value(), + returnValueForMissingStub: _i24.Future.value(), + ) as _i24.Future); @override - _i30.DerivePathType addressType({required String? address}) => + _i31.DerivePathType addressType({required String? address}) => (super.noSuchMethod( Invocation.method( #addressType, [], {#address: address}, ), - returnValue: _i30.DerivePathType.bip44, - ) as _i30.DerivePathType); + returnValue: _i31.DerivePathType.bip44, + ) as _i31.DerivePathType); @override - _i23.Future recoverFromMnemonic({ + _i24.Future recoverFromMnemonic({ required String? mnemonic, String? mnemonicPassphrase, required int? maxUnusedAddressGap, @@ -1081,49 +1108,49 @@ class MockBitcoinWallet extends _i1.Mock implements _i29.BitcoinWallet { #height: height, }, ), - returnValue: _i23.Future.value(), - returnValueForMissingStub: _i23.Future.value(), - ) as _i23.Future); + returnValue: _i24.Future.value(), + returnValueForMissingStub: _i24.Future.value(), + ) as _i24.Future); @override - _i23.Future getTransactionCacheEarly(List? allAddresses) => + _i24.Future getTransactionCacheEarly(List? allAddresses) => (super.noSuchMethod( Invocation.method( #getTransactionCacheEarly, [allAddresses], ), - returnValue: _i23.Future.value(), - returnValueForMissingStub: _i23.Future.value(), - ) as _i23.Future); + returnValue: _i24.Future.value(), + returnValueForMissingStub: _i24.Future.value(), + ) as _i24.Future); @override - _i23.Future refreshIfThereIsNewData() => (super.noSuchMethod( + _i24.Future refreshIfThereIsNewData() => (super.noSuchMethod( Invocation.method( #refreshIfThereIsNewData, [], ), - returnValue: _i23.Future.value(false), - ) as _i23.Future); + returnValue: _i24.Future.value(false), + ) as _i24.Future); @override - _i23.Future getAllTxsToWatch() => (super.noSuchMethod( + _i24.Future getAllTxsToWatch() => (super.noSuchMethod( Invocation.method( #getAllTxsToWatch, [], ), - returnValue: _i23.Future.value(), - returnValueForMissingStub: _i23.Future.value(), - ) as _i23.Future); + returnValue: _i24.Future.value(), + returnValueForMissingStub: _i24.Future.value(), + ) as _i24.Future); @override - _i23.Future refresh() => (super.noSuchMethod( + _i24.Future refresh() => (super.noSuchMethod( Invocation.method( #refresh, [], ), - returnValue: _i23.Future.value(), - returnValueForMissingStub: _i23.Future.value(), - ) as _i23.Future); + returnValue: _i24.Future.value(), + returnValueForMissingStub: _i24.Future.value(), + ) as _i24.Future); @override - _i23.Future> prepareSend({ + _i24.Future> prepareSend({ required String? address, - required _i14.Amount? amount, + required _i15.Amount? amount, Map? args, }) => (super.noSuchMethod( @@ -1137,26 +1164,26 @@ class MockBitcoinWallet extends _i1.Mock implements _i29.BitcoinWallet { }, ), returnValue: - _i23.Future>.value({}), - ) as _i23.Future>); + _i24.Future>.value({}), + ) as _i24.Future>); @override - _i23.Future confirmSend({required Map? txData}) => + _i24.Future confirmSend({required Map? txData}) => (super.noSuchMethod( Invocation.method( #confirmSend, [], {#txData: txData}, ), - returnValue: _i23.Future.value(''), - ) as _i23.Future); + returnValue: _i24.Future.value(''), + ) as _i24.Future); @override - _i23.Future testNetworkConnection() => (super.noSuchMethod( + _i24.Future testNetworkConnection() => (super.noSuchMethod( Invocation.method( #testNetworkConnection, [], ), - returnValue: _i23.Future.value(false), - ) as _i23.Future); + returnValue: _i24.Future.value(false), + ) as _i24.Future); @override void startNetworkAlivePinging() => super.noSuchMethod( Invocation.method( @@ -1174,33 +1201,35 @@ class MockBitcoinWallet extends _i1.Mock implements _i29.BitcoinWallet { returnValueForMissingStub: null, ); @override - _i23.Future initializeNew() => (super.noSuchMethod( + _i24.Future initializeNew( + ({String mnemonicPassphrase, int wordCount})? data) => + (super.noSuchMethod( Invocation.method( #initializeNew, - [], + [data], ), - returnValue: _i23.Future.value(), - returnValueForMissingStub: _i23.Future.value(), - ) as _i23.Future); + returnValue: _i24.Future.value(), + returnValueForMissingStub: _i24.Future.value(), + ) as _i24.Future); @override - _i23.Future initializeExisting() => (super.noSuchMethod( + _i24.Future initializeExisting() => (super.noSuchMethod( Invocation.method( #initializeExisting, [], ), - returnValue: _i23.Future.value(), - returnValueForMissingStub: _i23.Future.value(), - ) as _i23.Future); + returnValue: _i24.Future.value(), + returnValueForMissingStub: _i24.Future.value(), + ) as _i24.Future); @override - _i23.Future updateSentCachedTxData(Map? txData) => + _i24.Future updateSentCachedTxData(Map? txData) => (super.noSuchMethod( Invocation.method( #updateSentCachedTxData, [txData], ), - returnValue: _i23.Future.value(), - returnValueForMissingStub: _i23.Future.value(), - ) as _i23.Future); + returnValue: _i24.Future.value(), + returnValueForMissingStub: _i24.Future.value(), + ) as _i24.Future); @override bool validateAddress(String? address) => (super.noSuchMethod( Invocation.method( @@ -1210,70 +1239,70 @@ class MockBitcoinWallet extends _i1.Mock implements _i29.BitcoinWallet { returnValue: false, ) as bool); @override - _i23.Future updateNode(bool? shouldRefresh) => (super.noSuchMethod( + _i24.Future updateNode(bool? shouldRefresh) => (super.noSuchMethod( Invocation.method( #updateNode, [shouldRefresh], ), - returnValue: _i23.Future.value(), - returnValueForMissingStub: _i23.Future.value(), - ) as _i23.Future); + returnValue: _i24.Future.value(), + returnValueForMissingStub: _i24.Future.value(), + ) as _i24.Future); @override - _i23.Future<_i10.ElectrumXNode> getCurrentNode() => (super.noSuchMethod( + _i24.Future<_i11.ElectrumXNode> getCurrentNode() => (super.noSuchMethod( Invocation.method( #getCurrentNode, [], ), returnValue: - _i23.Future<_i10.ElectrumXNode>.value(_FakeElectrumXNode_11( + _i24.Future<_i11.ElectrumXNode>.value(_FakeElectrumXNode_12( this, Invocation.method( #getCurrentNode, [], ), )), - ) as _i23.Future<_i10.ElectrumXNode>); + ) as _i24.Future<_i11.ElectrumXNode>); @override - _i23.Future>> fastFetch( + _i24.Future>> fastFetch( List? allTxHashes) => (super.noSuchMethod( Invocation.method( #fastFetch, [allTxHashes], ), - returnValue: _i23.Future>>.value( + returnValue: _i24.Future>>.value( >[]), - ) as _i23.Future>>); + ) as _i24.Future>>); @override - _i23.Future getTxCount({required String? address}) => + _i24.Future getTxCount({required String? address}) => (super.noSuchMethod( Invocation.method( #getTxCount, [], {#address: address}, ), - returnValue: _i23.Future.value(0), - ) as _i23.Future); + returnValue: _i24.Future.value(0), + ) as _i24.Future); @override - _i23.Future checkCurrentReceivingAddressesForTransactions() => + _i24.Future checkCurrentReceivingAddressesForTransactions() => (super.noSuchMethod( Invocation.method( #checkCurrentReceivingAddressesForTransactions, [], ), - returnValue: _i23.Future.value(), - returnValueForMissingStub: _i23.Future.value(), - ) as _i23.Future); + returnValue: _i24.Future.value(), + returnValueForMissingStub: _i24.Future.value(), + ) as _i24.Future); @override - _i23.Future checkCurrentChangeAddressesForTransactions() => + _i24.Future checkCurrentChangeAddressesForTransactions() => (super.noSuchMethod( Invocation.method( #checkCurrentChangeAddressesForTransactions, [], ), - returnValue: _i23.Future.value(), - returnValueForMissingStub: _i23.Future.value(), - ) as _i23.Future); + returnValue: _i24.Future.value(), + returnValueForMissingStub: _i24.Future.value(), + ) as _i24.Future); @override int estimateTxFee({ required int? vSize, @@ -1299,7 +1328,7 @@ class MockBitcoinWallet extends _i1.Mock implements _i29.BitcoinWallet { required bool? isSendAll, int? satsPerVByte, int? additionalOutputs = 0, - List<_i17.UTXO>? utxos, + List<_i18.UTXO>? utxos, }) => super.noSuchMethod(Invocation.method( #coinSelection, @@ -1316,19 +1345,19 @@ class MockBitcoinWallet extends _i1.Mock implements _i29.BitcoinWallet { }, )); @override - _i23.Future> fetchBuildTxData( - List<_i17.UTXO>? utxosToUse) => + _i24.Future> fetchBuildTxData( + List<_i18.UTXO>? utxosToUse) => (super.noSuchMethod( Invocation.method( #fetchBuildTxData, [utxosToUse], ), returnValue: - _i23.Future>.value(<_i31.SigningData>[]), - ) as _i23.Future>); + _i24.Future>.value(<_i32.SigningData>[]), + ) as _i24.Future>); @override - _i23.Future> buildTransaction({ - required List<_i31.SigningData>? utxoSigningData, + _i24.Future> buildTransaction({ + required List<_i32.SigningData>? utxoSigningData, required List? recipients, required List? satoshiAmounts, }) => @@ -1343,10 +1372,10 @@ class MockBitcoinWallet extends _i1.Mock implements _i29.BitcoinWallet { }, ), returnValue: - _i23.Future>.value({}), - ) as _i23.Future>); + _i24.Future>.value({}), + ) as _i24.Future>); @override - _i23.Future fullRescan( + _i24.Future fullRescan( int? maxUnusedAddressGap, int? maxNumberOfIndexesToCheck, ) => @@ -1358,12 +1387,12 @@ class MockBitcoinWallet extends _i1.Mock implements _i29.BitcoinWallet { maxNumberOfIndexesToCheck, ], ), - returnValue: _i23.Future.value(), - returnValueForMissingStub: _i23.Future.value(), - ) as _i23.Future); + returnValue: _i24.Future.value(), + returnValueForMissingStub: _i24.Future.value(), + ) as _i24.Future); @override - _i23.Future<_i14.Amount> estimateFeeFor( - _i14.Amount? amount, + _i24.Future<_i15.Amount> estimateFeeFor( + _i15.Amount? amount, int? feeRate, ) => (super.noSuchMethod( @@ -1374,7 +1403,7 @@ class MockBitcoinWallet extends _i1.Mock implements _i29.BitcoinWallet { feeRate, ], ), - returnValue: _i23.Future<_i14.Amount>.value(_FakeAmount_12( + returnValue: _i24.Future<_i15.Amount>.value(_FakeAmount_13( this, Invocation.method( #estimateFeeFor, @@ -1384,9 +1413,9 @@ class MockBitcoinWallet extends _i1.Mock implements _i29.BitcoinWallet { ], ), )), - ) as _i23.Future<_i14.Amount>); + ) as _i24.Future<_i15.Amount>); @override - _i14.Amount roughFeeEstimate( + _i15.Amount roughFeeEstimate( int? inputCount, int? outputCount, int? feeRatePerKB, @@ -1400,7 +1429,7 @@ class MockBitcoinWallet extends _i1.Mock implements _i29.BitcoinWallet { feeRatePerKB, ], ), - returnValue: _FakeAmount_12( + returnValue: _FakeAmount_13( this, Invocation.method( #roughFeeEstimate, @@ -1411,34 +1440,34 @@ class MockBitcoinWallet extends _i1.Mock implements _i29.BitcoinWallet { ], ), ), - ) as _i14.Amount); + ) as _i15.Amount); @override - _i23.Future<_i14.Amount> sweepAllEstimate(int? feeRate) => + _i24.Future<_i15.Amount> sweepAllEstimate(int? feeRate) => (super.noSuchMethod( Invocation.method( #sweepAllEstimate, [feeRate], ), - returnValue: _i23.Future<_i14.Amount>.value(_FakeAmount_12( + returnValue: _i24.Future<_i15.Amount>.value(_FakeAmount_13( this, Invocation.method( #sweepAllEstimate, [feeRate], ), )), - ) as _i23.Future<_i14.Amount>); + ) as _i24.Future<_i15.Amount>); @override - _i23.Future generateNewAddress() => (super.noSuchMethod( + _i24.Future generateNewAddress() => (super.noSuchMethod( Invocation.method( #generateNewAddress, [], ), - returnValue: _i23.Future.value(false), - ) as _i23.Future); + returnValue: _i24.Future.value(false), + ) as _i24.Future); @override void initCache( String? walletId, - _i22.Coin? coin, + _i23.Coin? coin, ) => super.noSuchMethod( Invocation.method( @@ -1451,14 +1480,14 @@ class MockBitcoinWallet extends _i1.Mock implements _i29.BitcoinWallet { returnValueForMissingStub: null, ); @override - _i23.Future updateCachedId(String? id) => (super.noSuchMethod( + _i24.Future updateCachedId(String? id) => (super.noSuchMethod( Invocation.method( #updateCachedId, [id], ), - returnValue: _i23.Future.value(), - returnValueForMissingStub: _i23.Future.value(), - ) as _i23.Future); + returnValue: _i24.Future.value(), + returnValueForMissingStub: _i24.Future.value(), + ) as _i24.Future); @override int getCachedChainHeight() => (super.noSuchMethod( Invocation.method( @@ -1468,14 +1497,14 @@ class MockBitcoinWallet extends _i1.Mock implements _i29.BitcoinWallet { returnValue: 0, ) as int); @override - _i23.Future updateCachedChainHeight(int? height) => (super.noSuchMethod( + _i24.Future updateCachedChainHeight(int? height) => (super.noSuchMethod( Invocation.method( #updateCachedChainHeight, [height], ), - returnValue: _i23.Future.value(), - returnValueForMissingStub: _i23.Future.value(), - ) as _i23.Future); + returnValue: _i24.Future.value(), + returnValueForMissingStub: _i24.Future.value(), + ) as _i24.Future); @override bool getCachedIsFavorite() => (super.noSuchMethod( Invocation.method( @@ -1485,63 +1514,63 @@ class MockBitcoinWallet extends _i1.Mock implements _i29.BitcoinWallet { returnValue: false, ) as bool); @override - _i23.Future updateCachedIsFavorite(bool? isFavorite) => + _i24.Future updateCachedIsFavorite(bool? isFavorite) => (super.noSuchMethod( Invocation.method( #updateCachedIsFavorite, [isFavorite], ), - returnValue: _i23.Future.value(), - returnValueForMissingStub: _i23.Future.value(), - ) as _i23.Future); + returnValue: _i24.Future.value(), + returnValueForMissingStub: _i24.Future.value(), + ) as _i24.Future); @override - _i12.Balance getCachedBalance() => (super.noSuchMethod( + _i13.Balance getCachedBalance() => (super.noSuchMethod( Invocation.method( #getCachedBalance, [], ), - returnValue: _FakeBalance_9( + returnValue: _FakeBalance_10( this, Invocation.method( #getCachedBalance, [], ), ), - ) as _i12.Balance); + ) as _i13.Balance); @override - _i23.Future updateCachedBalance(_i12.Balance? balance) => + _i24.Future updateCachedBalance(_i13.Balance? balance) => (super.noSuchMethod( Invocation.method( #updateCachedBalance, [balance], ), - returnValue: _i23.Future.value(), - returnValueForMissingStub: _i23.Future.value(), - ) as _i23.Future); + returnValue: _i24.Future.value(), + returnValueForMissingStub: _i24.Future.value(), + ) as _i24.Future); @override - _i12.Balance getCachedBalanceSecondary() => (super.noSuchMethod( + _i13.Balance getCachedBalanceSecondary() => (super.noSuchMethod( Invocation.method( #getCachedBalanceSecondary, [], ), - returnValue: _FakeBalance_9( + returnValue: _FakeBalance_10( this, Invocation.method( #getCachedBalanceSecondary, [], ), ), - ) as _i12.Balance); + ) as _i13.Balance); @override - _i23.Future updateCachedBalanceSecondary(_i12.Balance? balance) => + _i24.Future updateCachedBalanceSecondary(_i13.Balance? balance) => (super.noSuchMethod( Invocation.method( #updateCachedBalanceSecondary, [balance], ), - returnValue: _i23.Future.value(), - returnValueForMissingStub: _i23.Future.value(), - ) as _i23.Future); + returnValue: _i24.Future.value(), + returnValueForMissingStub: _i24.Future.value(), + ) as _i24.Future); @override List getWalletTokenContractAddresses() => (super.noSuchMethod( Invocation.method( @@ -1551,18 +1580,18 @@ class MockBitcoinWallet extends _i1.Mock implements _i29.BitcoinWallet { returnValue: [], ) as List); @override - _i23.Future updateWalletTokenContractAddresses( + _i24.Future updateWalletTokenContractAddresses( List? contractAddresses) => (super.noSuchMethod( Invocation.method( #updateWalletTokenContractAddresses, [contractAddresses], ), - returnValue: _i23.Future.value(), - returnValueForMissingStub: _i23.Future.value(), - ) as _i23.Future); + returnValue: _i24.Future.value(), + returnValueForMissingStub: _i24.Future.value(), + ) as _i24.Future); @override - void initWalletDB({_i7.MainDB? mockableOverride}) => super.noSuchMethod( + void initWalletDB({_i8.MainDB? mockableOverride}) => super.noSuchMethod( Invocation.method( #initWalletDB, [], @@ -1571,11 +1600,11 @@ class MockBitcoinWallet extends _i1.Mock implements _i29.BitcoinWallet { returnValueForMissingStub: null, ); @override - _i23.Future<_i15.Tuple2<_i17.Transaction, _i17.Address>> parseTransaction( + _i24.Future<_i16.Tuple2<_i18.Transaction, _i18.Address>> parseTransaction( Map? txData, dynamic electrumxClient, - List<_i17.Address>? myAddresses, - _i22.Coin? coin, + List<_i18.Address>? myAddresses, + _i23.Coin? coin, int? minConfirms, String? walletId, ) => @@ -1592,8 +1621,8 @@ class MockBitcoinWallet extends _i1.Mock implements _i29.BitcoinWallet { ], ), returnValue: - _i23.Future<_i15.Tuple2<_i17.Transaction, _i17.Address>>.value( - _FakeTuple2_13<_i17.Transaction, _i17.Address>( + _i24.Future<_i16.Tuple2<_i18.Transaction, _i18.Address>>.value( + _FakeTuple2_14<_i18.Transaction, _i18.Address>( this, Invocation.method( #parseTransaction, @@ -1607,37 +1636,37 @@ class MockBitcoinWallet extends _i1.Mock implements _i29.BitcoinWallet { ], ), )), - ) as _i23.Future<_i15.Tuple2<_i17.Transaction, _i17.Address>>); + ) as _i24.Future<_i16.Tuple2<_i18.Transaction, _i18.Address>>); @override void initPaynymWalletInterface({ required String? walletId, required String? walletName, - required _i13.NetworkType? network, - required _i22.Coin? coin, - required _i7.MainDB? db, - required _i10.ElectrumX? electrumXClient, - required _i19.SecureStorageInterface? secureStorage, + required _i14.NetworkType? network, + required _i23.Coin? coin, + required _i8.MainDB? db, + required _i11.ElectrumX? electrumXClient, + required _i20.SecureStorageInterface? secureStorage, required int? dustLimit, required int? dustLimitP2PKH, required int? minConfirms, - required _i23.Future Function()? getMnemonicString, - required _i23.Future Function()? getMnemonicPassphrase, - required _i23.Future Function()? getChainHeight, - required _i23.Future Function()? getCurrentChangeAddress, + required _i24.Future Function()? getMnemonicString, + required _i24.Future Function()? getMnemonicPassphrase, + required _i24.Future Function()? getChainHeight, + required _i24.Future Function()? getCurrentChangeAddress, required int Function({ required int feeRatePerKB, required int vSize, })? estimateTxFee, - required _i23.Future> Function({ + required _i24.Future> Function({ required String address, - required _i14.Amount amount, + required _i15.Amount amount, Map? args, })? prepareSend, - required _i23.Future Function({required String address})? getTxCount, - required _i23.Future> Function(List<_i17.UTXO>)? + required _i24.Future Function({required String address})? getTxCount, + required _i24.Future> Function(List<_i18.UTXO>)? fetchBuildTxData, - required _i23.Future Function()? refresh, - required _i23.Future Function()? checkChangeAddressForTransactions, + required _i24.Future Function()? refresh, + required _i24.Future Function()? checkChangeAddressForTransactions, }) => super.noSuchMethod( Invocation.method( @@ -1670,21 +1699,21 @@ class MockBitcoinWallet extends _i1.Mock implements _i29.BitcoinWallet { returnValueForMissingStub: null, ); @override - _i23.Future<_i16.BIP32> getBip47BaseNode() => (super.noSuchMethod( + _i24.Future<_i17.BIP32> getBip47BaseNode() => (super.noSuchMethod( Invocation.method( #getBip47BaseNode, [], ), - returnValue: _i23.Future<_i16.BIP32>.value(_FakeBIP32_14( + returnValue: _i24.Future<_i17.BIP32>.value(_FakeBIP32_15( this, Invocation.method( #getBip47BaseNode, [], ), )), - ) as _i23.Future<_i16.BIP32>); + ) as _i24.Future<_i17.BIP32>); @override - _i23.Future<_i28.Uint8List> getPrivateKeyForPaynymReceivingAddress({ + _i24.Future<_i29.Uint8List> getPrivateKeyForPaynymReceivingAddress({ required String? paymentCodeString, required int? index, }) => @@ -1697,11 +1726,11 @@ class MockBitcoinWallet extends _i1.Mock implements _i29.BitcoinWallet { #index: index, }, ), - returnValue: _i23.Future<_i28.Uint8List>.value(_i28.Uint8List(0)), - ) as _i23.Future<_i28.Uint8List>); + returnValue: _i24.Future<_i29.Uint8List>.value(_i29.Uint8List(0)), + ) as _i24.Future<_i29.Uint8List>); @override - _i23.Future<_i17.Address> currentReceivingPaynymAddress({ - required _i18.PaymentCode? sender, + _i24.Future<_i18.Address> currentReceivingPaynymAddress({ + required _i19.PaymentCode? sender, required bool? isSegwit, }) => (super.noSuchMethod( @@ -1713,7 +1742,7 @@ class MockBitcoinWallet extends _i1.Mock implements _i29.BitcoinWallet { #isSegwit: isSegwit, }, ), - returnValue: _i23.Future<_i17.Address>.value(_FakeAddress_15( + returnValue: _i24.Future<_i18.Address>.value(_FakeAddress_16( this, Invocation.method( #currentReceivingPaynymAddress, @@ -1724,10 +1753,10 @@ class MockBitcoinWallet extends _i1.Mock implements _i29.BitcoinWallet { }, ), )), - ) as _i23.Future<_i17.Address>); + ) as _i24.Future<_i18.Address>); @override - _i23.Future checkCurrentPaynymReceivingAddressForTransactions({ - required _i18.PaymentCode? sender, + _i24.Future checkCurrentPaynymReceivingAddressForTransactions({ + required _i19.PaymentCode? sender, required bool? isSegwit, }) => (super.noSuchMethod( @@ -1739,42 +1768,42 @@ class MockBitcoinWallet extends _i1.Mock implements _i29.BitcoinWallet { #isSegwit: isSegwit, }, ), - returnValue: _i23.Future.value(), - returnValueForMissingStub: _i23.Future.value(), - ) as _i23.Future); + returnValue: _i24.Future.value(), + returnValueForMissingStub: _i24.Future.value(), + ) as _i24.Future); @override - _i23.Future checkAllCurrentReceivingPaynymAddressesForTransactions() => + _i24.Future checkAllCurrentReceivingPaynymAddressesForTransactions() => (super.noSuchMethod( Invocation.method( #checkAllCurrentReceivingPaynymAddressesForTransactions, [], ), - returnValue: _i23.Future.value(), - returnValueForMissingStub: _i23.Future.value(), - ) as _i23.Future); + returnValue: _i24.Future.value(), + returnValueForMissingStub: _i24.Future.value(), + ) as _i24.Future); @override - _i23.Future<_i16.BIP32> deriveNotificationBip32Node() => (super.noSuchMethod( + _i24.Future<_i17.BIP32> deriveNotificationBip32Node() => (super.noSuchMethod( Invocation.method( #deriveNotificationBip32Node, [], ), - returnValue: _i23.Future<_i16.BIP32>.value(_FakeBIP32_14( + returnValue: _i24.Future<_i17.BIP32>.value(_FakeBIP32_15( this, Invocation.method( #deriveNotificationBip32Node, [], ), )), - ) as _i23.Future<_i16.BIP32>); + ) as _i24.Future<_i17.BIP32>); @override - _i23.Future<_i18.PaymentCode> getPaymentCode({required bool? isSegwit}) => + _i24.Future<_i19.PaymentCode> getPaymentCode({required bool? isSegwit}) => (super.noSuchMethod( Invocation.method( #getPaymentCode, [], {#isSegwit: isSegwit}, ), - returnValue: _i23.Future<_i18.PaymentCode>.value(_FakePaymentCode_16( + returnValue: _i24.Future<_i19.PaymentCode>.value(_FakePaymentCode_17( this, Invocation.method( #getPaymentCode, @@ -1782,30 +1811,30 @@ class MockBitcoinWallet extends _i1.Mock implements _i29.BitcoinWallet { {#isSegwit: isSegwit}, ), )), - ) as _i23.Future<_i18.PaymentCode>); + ) as _i24.Future<_i19.PaymentCode>); @override - _i23.Future<_i28.Uint8List> signWithNotificationKey(_i28.Uint8List? data) => + _i24.Future<_i29.Uint8List> signWithNotificationKey(_i29.Uint8List? data) => (super.noSuchMethod( Invocation.method( #signWithNotificationKey, [data], ), - returnValue: _i23.Future<_i28.Uint8List>.value(_i28.Uint8List(0)), - ) as _i23.Future<_i28.Uint8List>); + returnValue: _i24.Future<_i29.Uint8List>.value(_i29.Uint8List(0)), + ) as _i24.Future<_i29.Uint8List>); @override - _i23.Future signStringWithNotificationKey(String? data) => + _i24.Future signStringWithNotificationKey(String? data) => (super.noSuchMethod( Invocation.method( #signStringWithNotificationKey, [data], ), - returnValue: _i23.Future.value(''), - ) as _i23.Future); + returnValue: _i24.Future.value(''), + ) as _i24.Future); @override - _i23.Future> preparePaymentCodeSend({ - required _i18.PaymentCode? paymentCode, + _i24.Future> preparePaymentCodeSend({ + required _i19.PaymentCode? paymentCode, required bool? isSegwit, - required _i14.Amount? amount, + required _i15.Amount? amount, Map? args, }) => (super.noSuchMethod( @@ -1820,13 +1849,13 @@ class MockBitcoinWallet extends _i1.Mock implements _i29.BitcoinWallet { }, ), returnValue: - _i23.Future>.value({}), - ) as _i23.Future>); + _i24.Future>.value({}), + ) as _i24.Future>); @override - _i23.Future<_i17.Address> nextUnusedSendAddressFrom({ - required _i18.PaymentCode? pCode, + _i24.Future<_i18.Address> nextUnusedSendAddressFrom({ + required _i19.PaymentCode? pCode, required bool? isSegwit, - required _i16.BIP32? privateKeyNode, + required _i17.BIP32? privateKeyNode, int? startIndex = 0, }) => (super.noSuchMethod( @@ -1840,7 +1869,7 @@ class MockBitcoinWallet extends _i1.Mock implements _i29.BitcoinWallet { #startIndex: startIndex, }, ), - returnValue: _i23.Future<_i17.Address>.value(_FakeAddress_15( + returnValue: _i24.Future<_i18.Address>.value(_FakeAddress_16( this, Invocation.method( #nextUnusedSendAddressFrom, @@ -1853,13 +1882,13 @@ class MockBitcoinWallet extends _i1.Mock implements _i29.BitcoinWallet { }, ), )), - ) as _i23.Future<_i17.Address>); + ) as _i24.Future<_i18.Address>); @override - _i23.Future> prepareNotificationTx({ + _i24.Future> prepareNotificationTx({ required int? selectedTxFeeRate, required String? targetPaymentCodeString, int? additionalOutputs = 0, - List<_i17.UTXO>? utxos, + List<_i18.UTXO>? utxos, }) => (super.noSuchMethod( Invocation.method( @@ -1873,10 +1902,10 @@ class MockBitcoinWallet extends _i1.Mock implements _i29.BitcoinWallet { }, ), returnValue: - _i23.Future>.value({}), - ) as _i23.Future>); + _i24.Future>.value({}), + ) as _i24.Future>); @override - _i23.Future broadcastNotificationTx( + _i24.Future broadcastNotificationTx( {required Map? preparedTx}) => (super.noSuchMethod( Invocation.method( @@ -1884,62 +1913,62 @@ class MockBitcoinWallet extends _i1.Mock implements _i29.BitcoinWallet { [], {#preparedTx: preparedTx}, ), - returnValue: _i23.Future.value(''), - ) as _i23.Future); + returnValue: _i24.Future.value(''), + ) as _i24.Future); @override - _i23.Future hasConnected(String? paymentCodeString) => + _i24.Future hasConnected(String? paymentCodeString) => (super.noSuchMethod( Invocation.method( #hasConnected, [paymentCodeString], ), - returnValue: _i23.Future.value(false), - ) as _i23.Future); + returnValue: _i24.Future.value(false), + ) as _i24.Future); @override - _i23.Future<_i18.PaymentCode?> unBlindedPaymentCodeFromTransaction( - {required _i17.Transaction? transaction}) => + _i24.Future<_i19.PaymentCode?> unBlindedPaymentCodeFromTransaction( + {required _i18.Transaction? transaction}) => (super.noSuchMethod( Invocation.method( #unBlindedPaymentCodeFromTransaction, [], {#transaction: transaction}, ), - returnValue: _i23.Future<_i18.PaymentCode?>.value(), - ) as _i23.Future<_i18.PaymentCode?>); + returnValue: _i24.Future<_i19.PaymentCode?>.value(), + ) as _i24.Future<_i19.PaymentCode?>); @override - _i23.Future<_i18.PaymentCode?> unBlindedPaymentCodeFromTransactionBad( - {required _i17.Transaction? transaction}) => + _i24.Future<_i19.PaymentCode?> unBlindedPaymentCodeFromTransactionBad( + {required _i18.Transaction? transaction}) => (super.noSuchMethod( Invocation.method( #unBlindedPaymentCodeFromTransactionBad, [], {#transaction: transaction}, ), - returnValue: _i23.Future<_i18.PaymentCode?>.value(), - ) as _i23.Future<_i18.PaymentCode?>); + returnValue: _i24.Future<_i19.PaymentCode?>.value(), + ) as _i24.Future<_i19.PaymentCode?>); @override - _i23.Future> + _i24.Future> getAllPaymentCodesFromNotificationTransactions() => (super.noSuchMethod( Invocation.method( #getAllPaymentCodesFromNotificationTransactions, [], ), returnValue: - _i23.Future>.value(<_i18.PaymentCode>[]), - ) as _i23.Future>); + _i24.Future>.value(<_i19.PaymentCode>[]), + ) as _i24.Future>); @override - _i23.Future checkForNotificationTransactionsTo( + _i24.Future checkForNotificationTransactionsTo( Set? otherCodeStrings) => (super.noSuchMethod( Invocation.method( #checkForNotificationTransactionsTo, [otherCodeStrings], ), - returnValue: _i23.Future.value(), - returnValueForMissingStub: _i23.Future.value(), - ) as _i23.Future); + returnValue: _i24.Future.value(), + returnValueForMissingStub: _i24.Future.value(), + ) as _i24.Future); @override - _i23.Future restoreAllHistory({ + _i24.Future restoreAllHistory({ required int? maxUnusedAddressGap, required int? maxNumberOfIndexesToCheck, required Set? paymentCodeStrings, @@ -1954,12 +1983,12 @@ class MockBitcoinWallet extends _i1.Mock implements _i29.BitcoinWallet { #paymentCodeStrings: paymentCodeStrings, }, ), - returnValue: _i23.Future.value(), - returnValueForMissingStub: _i23.Future.value(), - ) as _i23.Future); + returnValue: _i24.Future.value(), + returnValueForMissingStub: _i24.Future.value(), + ) as _i24.Future); @override - _i23.Future restoreHistoryWith({ - required _i18.PaymentCode? other, + _i24.Future restoreHistoryWith({ + required _i19.PaymentCode? other, required bool? checkSegwitAsWell, required int? maxUnusedAddressGap, required int? maxNumberOfIndexesToCheck, @@ -1975,58 +2004,58 @@ class MockBitcoinWallet extends _i1.Mock implements _i29.BitcoinWallet { #maxNumberOfIndexesToCheck: maxNumberOfIndexesToCheck, }, ), - returnValue: _i23.Future.value(), - returnValueForMissingStub: _i23.Future.value(), - ) as _i23.Future); + returnValue: _i24.Future.value(), + returnValueForMissingStub: _i24.Future.value(), + ) as _i24.Future); @override - _i23.Future<_i17.Address> getMyNotificationAddress() => (super.noSuchMethod( + _i24.Future<_i18.Address> getMyNotificationAddress() => (super.noSuchMethod( Invocation.method( #getMyNotificationAddress, [], ), - returnValue: _i23.Future<_i17.Address>.value(_FakeAddress_15( + returnValue: _i24.Future<_i18.Address>.value(_FakeAddress_16( this, Invocation.method( #getMyNotificationAddress, [], ), )), - ) as _i23.Future<_i17.Address>); + ) as _i24.Future<_i18.Address>); @override - _i23.Future> lookupKey(String? paymentCodeString) => + _i24.Future> lookupKey(String? paymentCodeString) => (super.noSuchMethod( Invocation.method( #lookupKey, [paymentCodeString], ), - returnValue: _i23.Future>.value([]), - ) as _i23.Future>); + returnValue: _i24.Future>.value([]), + ) as _i24.Future>); @override - _i23.Future paymentCodeStringByKey(String? key) => + _i24.Future paymentCodeStringByKey(String? key) => (super.noSuchMethod( Invocation.method( #paymentCodeStringByKey, [key], ), - returnValue: _i23.Future.value(), - ) as _i23.Future); + returnValue: _i24.Future.value(), + ) as _i24.Future); @override - _i23.Future storeCode(String? paymentCodeString) => + _i24.Future storeCode(String? paymentCodeString) => (super.noSuchMethod( Invocation.method( #storeCode, [paymentCodeString], ), - returnValue: _i23.Future.value(''), - ) as _i23.Future); + returnValue: _i24.Future.value(''), + ) as _i24.Future); @override void initCoinControlInterface({ required String? walletId, required String? walletName, - required _i22.Coin? coin, - required _i7.MainDB? db, - required _i23.Future Function()? getChainHeight, - required _i23.Future Function(_i12.Balance)? refreshedBalanceCallback, + required _i23.Coin? coin, + required _i8.MainDB? db, + required _i24.Future Function()? getChainHeight, + required _i24.Future Function(_i13.Balance)? refreshedBalanceCallback, }) => super.noSuchMethod( Invocation.method( @@ -2044,16 +2073,16 @@ class MockBitcoinWallet extends _i1.Mock implements _i29.BitcoinWallet { returnValueForMissingStub: null, ); @override - _i23.Future refreshBalance({bool? notify = false}) => + _i24.Future refreshBalance({bool? notify = false}) => (super.noSuchMethod( Invocation.method( #refreshBalance, [], {#notify: notify}, ), - returnValue: _i23.Future.value(), - returnValueForMissingStub: _i23.Future.value(), - ) as _i23.Future); + returnValue: _i24.Future.value(), + returnValueForMissingStub: _i24.Future.value(), + ) as _i24.Future); } /// A class which mocks [NodeService]. @@ -2061,41 +2090,41 @@ class MockBitcoinWallet extends _i1.Mock implements _i29.BitcoinWallet { /// See the documentation for Mockito's code generation for more information. class MockNodeService extends _i1.Mock implements _i3.NodeService { @override - _i19.SecureStorageInterface get secureStorageInterface => (super.noSuchMethod( + _i20.SecureStorageInterface get secureStorageInterface => (super.noSuchMethod( Invocation.getter(#secureStorageInterface), - returnValue: _FakeSecureStorageInterface_17( + returnValue: _FakeSecureStorageInterface_18( this, Invocation.getter(#secureStorageInterface), ), - ) as _i19.SecureStorageInterface); + ) as _i20.SecureStorageInterface); @override - List<_i32.NodeModel> get primaryNodes => (super.noSuchMethod( + List<_i33.NodeModel> get primaryNodes => (super.noSuchMethod( Invocation.getter(#primaryNodes), - returnValue: <_i32.NodeModel>[], - ) as List<_i32.NodeModel>); + returnValue: <_i33.NodeModel>[], + ) as List<_i33.NodeModel>); @override - List<_i32.NodeModel> get nodes => (super.noSuchMethod( + List<_i33.NodeModel> get nodes => (super.noSuchMethod( Invocation.getter(#nodes), - returnValue: <_i32.NodeModel>[], - ) as List<_i32.NodeModel>); + returnValue: <_i33.NodeModel>[], + ) as List<_i33.NodeModel>); @override bool get hasListeners => (super.noSuchMethod( Invocation.getter(#hasListeners), returnValue: false, ) as bool); @override - _i23.Future updateDefaults() => (super.noSuchMethod( + _i24.Future updateDefaults() => (super.noSuchMethod( Invocation.method( #updateDefaults, [], ), - returnValue: _i23.Future.value(), - returnValueForMissingStub: _i23.Future.value(), - ) as _i23.Future); + returnValue: _i24.Future.value(), + returnValueForMissingStub: _i24.Future.value(), + ) as _i24.Future); @override - _i23.Future setPrimaryNodeFor({ - required _i22.Coin? coin, - required _i32.NodeModel? node, + _i24.Future setPrimaryNodeFor({ + required _i23.Coin? coin, + required _i33.NodeModel? node, bool? shouldNotifyListeners = false, }) => (super.noSuchMethod( @@ -2108,44 +2137,44 @@ class MockNodeService extends _i1.Mock implements _i3.NodeService { #shouldNotifyListeners: shouldNotifyListeners, }, ), - returnValue: _i23.Future.value(), - returnValueForMissingStub: _i23.Future.value(), - ) as _i23.Future); + returnValue: _i24.Future.value(), + returnValueForMissingStub: _i24.Future.value(), + ) as _i24.Future); @override - _i32.NodeModel? getPrimaryNodeFor({required _i22.Coin? coin}) => + _i33.NodeModel? getPrimaryNodeFor({required _i23.Coin? coin}) => (super.noSuchMethod(Invocation.method( #getPrimaryNodeFor, [], {#coin: coin}, - )) as _i32.NodeModel?); + )) as _i33.NodeModel?); @override - List<_i32.NodeModel> getNodesFor(_i22.Coin? coin) => (super.noSuchMethod( + List<_i33.NodeModel> getNodesFor(_i23.Coin? coin) => (super.noSuchMethod( Invocation.method( #getNodesFor, [coin], ), - returnValue: <_i32.NodeModel>[], - ) as List<_i32.NodeModel>); + returnValue: <_i33.NodeModel>[], + ) as List<_i33.NodeModel>); @override - _i32.NodeModel? getNodeById({required String? id}) => + _i33.NodeModel? getNodeById({required String? id}) => (super.noSuchMethod(Invocation.method( #getNodeById, [], {#id: id}, - )) as _i32.NodeModel?); + )) as _i33.NodeModel?); @override - List<_i32.NodeModel> failoverNodesFor({required _i22.Coin? coin}) => + List<_i33.NodeModel> failoverNodesFor({required _i23.Coin? coin}) => (super.noSuchMethod( Invocation.method( #failoverNodesFor, [], {#coin: coin}, ), - returnValue: <_i32.NodeModel>[], - ) as List<_i32.NodeModel>); + returnValue: <_i33.NodeModel>[], + ) as List<_i33.NodeModel>); @override - _i23.Future add( - _i32.NodeModel? node, + _i24.Future add( + _i33.NodeModel? node, String? password, bool? shouldNotifyListeners, ) => @@ -2158,11 +2187,11 @@ class MockNodeService extends _i1.Mock implements _i3.NodeService { shouldNotifyListeners, ], ), - returnValue: _i23.Future.value(), - returnValueForMissingStub: _i23.Future.value(), - ) as _i23.Future); + returnValue: _i24.Future.value(), + returnValueForMissingStub: _i24.Future.value(), + ) as _i24.Future); @override - _i23.Future delete( + _i24.Future delete( String? id, bool? shouldNotifyListeners, ) => @@ -2174,11 +2203,11 @@ class MockNodeService extends _i1.Mock implements _i3.NodeService { shouldNotifyListeners, ], ), - returnValue: _i23.Future.value(), - returnValueForMissingStub: _i23.Future.value(), - ) as _i23.Future); + returnValue: _i24.Future.value(), + returnValueForMissingStub: _i24.Future.value(), + ) as _i24.Future); @override - _i23.Future setEnabledState( + _i24.Future setEnabledState( String? id, bool? enabled, bool? shouldNotifyListeners, @@ -2192,12 +2221,12 @@ class MockNodeService extends _i1.Mock implements _i3.NodeService { shouldNotifyListeners, ], ), - returnValue: _i23.Future.value(), - returnValueForMissingStub: _i23.Future.value(), - ) as _i23.Future); + returnValue: _i24.Future.value(), + returnValueForMissingStub: _i24.Future.value(), + ) as _i24.Future); @override - _i23.Future edit( - _i32.NodeModel? editedNode, + _i24.Future edit( + _i33.NodeModel? editedNode, String? password, bool? shouldNotifyListeners, ) => @@ -2210,20 +2239,20 @@ class MockNodeService extends _i1.Mock implements _i3.NodeService { shouldNotifyListeners, ], ), - returnValue: _i23.Future.value(), - returnValueForMissingStub: _i23.Future.value(), - ) as _i23.Future); + returnValue: _i24.Future.value(), + returnValueForMissingStub: _i24.Future.value(), + ) as _i24.Future); @override - _i23.Future updateCommunityNodes() => (super.noSuchMethod( + _i24.Future updateCommunityNodes() => (super.noSuchMethod( Invocation.method( #updateCommunityNodes, [], ), - returnValue: _i23.Future.value(), - returnValueForMissingStub: _i23.Future.value(), - ) as _i23.Future); + returnValue: _i24.Future.value(), + returnValueForMissingStub: _i24.Future.value(), + ) as _i24.Future); @override - void addListener(_i25.VoidCallback? listener) => super.noSuchMethod( + void addListener(_i26.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #addListener, [listener], @@ -2231,7 +2260,7 @@ class MockNodeService extends _i1.Mock implements _i3.NodeService { returnValueForMissingStub: null, ); @override - void removeListener(_i25.VoidCallback? listener) => super.noSuchMethod( + void removeListener(_i26.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #removeListener, [listener], @@ -2274,23 +2303,23 @@ class MockManager extends _i1.Mock implements _i6.Manager { returnValueForMissingStub: null, ); @override - _i20.CoinServiceAPI get wallet => (super.noSuchMethod( + _i21.CoinServiceAPI get wallet => (super.noSuchMethod( Invocation.getter(#wallet), - returnValue: _FakeCoinServiceAPI_18( + returnValue: _FakeCoinServiceAPI_19( this, Invocation.getter(#wallet), ), - ) as _i20.CoinServiceAPI); + ) as _i21.CoinServiceAPI); @override bool get hasBackgroundRefreshListener => (super.noSuchMethod( Invocation.getter(#hasBackgroundRefreshListener), returnValue: false, ) as bool); @override - _i22.Coin get coin => (super.noSuchMethod( + _i23.Coin get coin => (super.noSuchMethod( Invocation.getter(#coin), - returnValue: _i22.Coin.bitcoin, - ) as _i22.Coin); + returnValue: _i23.Coin.bitcoin, + ) as _i23.Coin); @override bool get isRefreshing => (super.noSuchMethod( Invocation.getter(#isRefreshing), @@ -2323,42 +2352,42 @@ class MockManager extends _i1.Mock implements _i6.Manager { returnValueForMissingStub: null, ); @override - _i23.Future<_i9.FeeObject> get fees => (super.noSuchMethod( + _i24.Future<_i10.FeeObject> get fees => (super.noSuchMethod( Invocation.getter(#fees), - returnValue: _i23.Future<_i9.FeeObject>.value(_FakeFeeObject_6( + returnValue: _i24.Future<_i10.FeeObject>.value(_FakeFeeObject_7( this, Invocation.getter(#fees), )), - ) as _i23.Future<_i9.FeeObject>); + ) as _i24.Future<_i10.FeeObject>); @override - _i23.Future get maxFee => (super.noSuchMethod( + _i24.Future get maxFee => (super.noSuchMethod( Invocation.getter(#maxFee), - returnValue: _i23.Future.value(0), - ) as _i23.Future); + returnValue: _i24.Future.value(0), + ) as _i24.Future); @override - _i23.Future get currentReceivingAddress => (super.noSuchMethod( + _i24.Future get currentReceivingAddress => (super.noSuchMethod( Invocation.getter(#currentReceivingAddress), - returnValue: _i23.Future.value(''), - ) as _i23.Future); + returnValue: _i24.Future.value(''), + ) as _i24.Future); @override - _i12.Balance get balance => (super.noSuchMethod( + _i13.Balance get balance => (super.noSuchMethod( Invocation.getter(#balance), - returnValue: _FakeBalance_9( + returnValue: _FakeBalance_10( this, Invocation.getter(#balance), ), - ) as _i12.Balance); + ) as _i13.Balance); @override - _i23.Future> get transactions => (super.noSuchMethod( + _i24.Future> get transactions => (super.noSuchMethod( Invocation.getter(#transactions), returnValue: - _i23.Future>.value(<_i17.Transaction>[]), - ) as _i23.Future>); + _i24.Future>.value(<_i18.Transaction>[]), + ) as _i24.Future>); @override - _i23.Future> get utxos => (super.noSuchMethod( + _i24.Future> get utxos => (super.noSuchMethod( Invocation.getter(#utxos), - returnValue: _i23.Future>.value(<_i17.UTXO>[]), - ) as _i23.Future>); + returnValue: _i24.Future>.value(<_i18.UTXO>[]), + ) as _i24.Future>); @override set walletName(String? newName) => super.noSuchMethod( Invocation.setter( @@ -2378,15 +2407,15 @@ class MockManager extends _i1.Mock implements _i6.Manager { returnValue: '', ) as String); @override - _i23.Future> get mnemonic => (super.noSuchMethod( + _i24.Future> get mnemonic => (super.noSuchMethod( Invocation.getter(#mnemonic), - returnValue: _i23.Future>.value([]), - ) as _i23.Future>); + returnValue: _i24.Future>.value([]), + ) as _i24.Future>); @override - _i23.Future get mnemonicPassphrase => (super.noSuchMethod( + _i24.Future get mnemonicPassphrase => (super.noSuchMethod( Invocation.getter(#mnemonicPassphrase), - returnValue: _i23.Future.value(), - ) as _i23.Future); + returnValue: _i24.Future.value(), + ) as _i24.Future); @override bool get isConnected => (super.noSuchMethod( Invocation.getter(#isConnected), @@ -2433,24 +2462,24 @@ class MockManager extends _i1.Mock implements _i6.Manager { returnValue: false, ) as bool); @override - _i23.Future get xpub => (super.noSuchMethod( + _i24.Future get xpub => (super.noSuchMethod( Invocation.getter(#xpub), - returnValue: _i23.Future.value(''), - ) as _i23.Future); + returnValue: _i24.Future.value(''), + ) as _i24.Future); @override bool get hasListeners => (super.noSuchMethod( Invocation.getter(#hasListeners), returnValue: false, ) as bool); @override - _i23.Future updateNode(bool? shouldRefresh) => (super.noSuchMethod( + _i24.Future updateNode(bool? shouldRefresh) => (super.noSuchMethod( Invocation.method( #updateNode, [shouldRefresh], ), - returnValue: _i23.Future.value(), - returnValueForMissingStub: _i23.Future.value(), - ) as _i23.Future); + returnValue: _i24.Future.value(), + returnValueForMissingStub: _i24.Future.value(), + ) as _i24.Future); @override void dispose() => super.noSuchMethod( Invocation.method( @@ -2460,9 +2489,9 @@ class MockManager extends _i1.Mock implements _i6.Manager { returnValueForMissingStub: null, ); @override - _i23.Future> prepareSend({ + _i24.Future> prepareSend({ required String? address, - required _i14.Amount? amount, + required _i15.Amount? amount, Map? args, }) => (super.noSuchMethod( @@ -2476,27 +2505,27 @@ class MockManager extends _i1.Mock implements _i6.Manager { }, ), returnValue: - _i23.Future>.value({}), - ) as _i23.Future>); + _i24.Future>.value({}), + ) as _i24.Future>); @override - _i23.Future confirmSend({required Map? txData}) => + _i24.Future confirmSend({required Map? txData}) => (super.noSuchMethod( Invocation.method( #confirmSend, [], {#txData: txData}, ), - returnValue: _i23.Future.value(''), - ) as _i23.Future); + returnValue: _i24.Future.value(''), + ) as _i24.Future); @override - _i23.Future refresh() => (super.noSuchMethod( + _i24.Future refresh() => (super.noSuchMethod( Invocation.method( #refresh, [], ), - returnValue: _i23.Future.value(), - returnValueForMissingStub: _i23.Future.value(), - ) as _i23.Future); + returnValue: _i24.Future.value(), + returnValueForMissingStub: _i24.Future.value(), + ) as _i24.Future); @override bool validateAddress(String? address) => (super.noSuchMethod( Invocation.method( @@ -2506,33 +2535,35 @@ class MockManager extends _i1.Mock implements _i6.Manager { returnValue: false, ) as bool); @override - _i23.Future testNetworkConnection() => (super.noSuchMethod( + _i24.Future testNetworkConnection() => (super.noSuchMethod( Invocation.method( #testNetworkConnection, [], ), - returnValue: _i23.Future.value(false), - ) as _i23.Future); + returnValue: _i24.Future.value(false), + ) as _i24.Future); @override - _i23.Future initializeNew() => (super.noSuchMethod( + _i24.Future initializeNew( + ({String mnemonicPassphrase, int wordCount})? data) => + (super.noSuchMethod( Invocation.method( #initializeNew, - [], + [data], ), - returnValue: _i23.Future.value(), - returnValueForMissingStub: _i23.Future.value(), - ) as _i23.Future); + returnValue: _i24.Future.value(), + returnValueForMissingStub: _i24.Future.value(), + ) as _i24.Future); @override - _i23.Future initializeExisting() => (super.noSuchMethod( + _i24.Future initializeExisting() => (super.noSuchMethod( Invocation.method( #initializeExisting, [], ), - returnValue: _i23.Future.value(), - returnValueForMissingStub: _i23.Future.value(), - ) as _i23.Future); + returnValue: _i24.Future.value(), + returnValueForMissingStub: _i24.Future.value(), + ) as _i24.Future); @override - _i23.Future recoverFromMnemonic({ + _i24.Future recoverFromMnemonic({ required String? mnemonic, String? mnemonicPassphrase, required int? maxUnusedAddressGap, @@ -2551,20 +2582,20 @@ class MockManager extends _i1.Mock implements _i6.Manager { #height: height, }, ), - returnValue: _i23.Future.value(), - returnValueForMissingStub: _i23.Future.value(), - ) as _i23.Future); + returnValue: _i24.Future.value(), + returnValueForMissingStub: _i24.Future.value(), + ) as _i24.Future); @override - _i23.Future exitCurrentWallet() => (super.noSuchMethod( + _i24.Future exitCurrentWallet() => (super.noSuchMethod( Invocation.method( #exitCurrentWallet, [], ), - returnValue: _i23.Future.value(), - returnValueForMissingStub: _i23.Future.value(), - ) as _i23.Future); + returnValue: _i24.Future.value(), + returnValueForMissingStub: _i24.Future.value(), + ) as _i24.Future); @override - _i23.Future fullRescan( + _i24.Future fullRescan( int? maxUnusedAddressGap, int? maxNumberOfIndexesToCheck, ) => @@ -2576,12 +2607,12 @@ class MockManager extends _i1.Mock implements _i6.Manager { maxNumberOfIndexesToCheck, ], ), - returnValue: _i23.Future.value(), - returnValueForMissingStub: _i23.Future.value(), - ) as _i23.Future); + returnValue: _i24.Future.value(), + returnValueForMissingStub: _i24.Future.value(), + ) as _i24.Future); @override - _i23.Future<_i14.Amount> estimateFeeFor( - _i14.Amount? amount, + _i24.Future<_i15.Amount> estimateFeeFor( + _i15.Amount? amount, int? feeRate, ) => (super.noSuchMethod( @@ -2592,7 +2623,7 @@ class MockManager extends _i1.Mock implements _i6.Manager { feeRate, ], ), - returnValue: _i23.Future<_i14.Amount>.value(_FakeAmount_12( + returnValue: _i24.Future<_i15.Amount>.value(_FakeAmount_13( this, Invocation.method( #estimateFeeFor, @@ -2602,26 +2633,26 @@ class MockManager extends _i1.Mock implements _i6.Manager { ], ), )), - ) as _i23.Future<_i14.Amount>); + ) as _i24.Future<_i15.Amount>); @override - _i23.Future generateNewAddress() => (super.noSuchMethod( + _i24.Future generateNewAddress() => (super.noSuchMethod( Invocation.method( #generateNewAddress, [], ), - returnValue: _i23.Future.value(false), - ) as _i23.Future); + returnValue: _i24.Future.value(false), + ) as _i24.Future); @override - _i23.Future resetRescanOnOpen() => (super.noSuchMethod( + _i24.Future resetRescanOnOpen() => (super.noSuchMethod( Invocation.method( #resetRescanOnOpen, [], ), - returnValue: _i23.Future.value(), - returnValueForMissingStub: _i23.Future.value(), - ) as _i23.Future); + returnValue: _i24.Future.value(), + returnValueForMissingStub: _i24.Future.value(), + ) as _i24.Future); @override - void addListener(_i25.VoidCallback? listener) => super.noSuchMethod( + void addListener(_i26.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #addListener, [listener], @@ -2629,7 +2660,7 @@ class MockManager extends _i1.Mock implements _i6.Manager { returnValueForMissingStub: null, ); @override - void removeListener(_i25.VoidCallback? listener) => super.noSuchMethod( + void removeListener(_i26.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #removeListener, [listener], @@ -2649,7 +2680,7 @@ class MockManager extends _i1.Mock implements _i6.Manager { /// A class which mocks [CoinServiceAPI]. /// /// See the documentation for Mockito's code generation for more information. -class MockCoinServiceAPI extends _i1.Mock implements _i20.CoinServiceAPI { +class MockCoinServiceAPI extends _i1.Mock implements _i21.CoinServiceAPI { @override set onIsActiveWalletChanged(void Function(bool)? _onIsActiveWalletChanged) => super.noSuchMethod( @@ -2660,10 +2691,10 @@ class MockCoinServiceAPI extends _i1.Mock implements _i20.CoinServiceAPI { returnValueForMissingStub: null, ); @override - _i22.Coin get coin => (super.noSuchMethod( + _i23.Coin get coin => (super.noSuchMethod( Invocation.getter(#coin), - returnValue: _i22.Coin.bitcoin, - ) as _i22.Coin); + returnValue: _i23.Coin.bitcoin, + ) as _i23.Coin); @override bool get isRefreshing => (super.noSuchMethod( Invocation.getter(#isRefreshing), @@ -2696,42 +2727,42 @@ class MockCoinServiceAPI extends _i1.Mock implements _i20.CoinServiceAPI { returnValueForMissingStub: null, ); @override - _i23.Future<_i9.FeeObject> get fees => (super.noSuchMethod( + _i24.Future<_i10.FeeObject> get fees => (super.noSuchMethod( Invocation.getter(#fees), - returnValue: _i23.Future<_i9.FeeObject>.value(_FakeFeeObject_6( + returnValue: _i24.Future<_i10.FeeObject>.value(_FakeFeeObject_7( this, Invocation.getter(#fees), )), - ) as _i23.Future<_i9.FeeObject>); + ) as _i24.Future<_i10.FeeObject>); @override - _i23.Future get maxFee => (super.noSuchMethod( + _i24.Future get maxFee => (super.noSuchMethod( Invocation.getter(#maxFee), - returnValue: _i23.Future.value(0), - ) as _i23.Future); + returnValue: _i24.Future.value(0), + ) as _i24.Future); @override - _i23.Future get currentReceivingAddress => (super.noSuchMethod( + _i24.Future get currentReceivingAddress => (super.noSuchMethod( Invocation.getter(#currentReceivingAddress), - returnValue: _i23.Future.value(''), - ) as _i23.Future); + returnValue: _i24.Future.value(''), + ) as _i24.Future); @override - _i12.Balance get balance => (super.noSuchMethod( + _i13.Balance get balance => (super.noSuchMethod( Invocation.getter(#balance), - returnValue: _FakeBalance_9( + returnValue: _FakeBalance_10( this, Invocation.getter(#balance), ), - ) as _i12.Balance); + ) as _i13.Balance); @override - _i23.Future> get transactions => (super.noSuchMethod( + _i24.Future> get transactions => (super.noSuchMethod( Invocation.getter(#transactions), returnValue: - _i23.Future>.value(<_i17.Transaction>[]), - ) as _i23.Future>); + _i24.Future>.value(<_i18.Transaction>[]), + ) as _i24.Future>); @override - _i23.Future> get utxos => (super.noSuchMethod( + _i24.Future> get utxos => (super.noSuchMethod( Invocation.getter(#utxos), - returnValue: _i23.Future>.value(<_i17.UTXO>[]), - ) as _i23.Future>); + returnValue: _i24.Future>.value(<_i18.UTXO>[]), + ) as _i24.Future>); @override set walletName(String? newName) => super.noSuchMethod( Invocation.setter( @@ -2751,20 +2782,20 @@ class MockCoinServiceAPI extends _i1.Mock implements _i20.CoinServiceAPI { returnValue: '', ) as String); @override - _i23.Future> get mnemonic => (super.noSuchMethod( + _i24.Future> get mnemonic => (super.noSuchMethod( Invocation.getter(#mnemonic), - returnValue: _i23.Future>.value([]), - ) as _i23.Future>); + returnValue: _i24.Future>.value([]), + ) as _i24.Future>); @override - _i23.Future get mnemonicString => (super.noSuchMethod( + _i24.Future get mnemonicString => (super.noSuchMethod( Invocation.getter(#mnemonicString), - returnValue: _i23.Future.value(), - ) as _i23.Future); + returnValue: _i24.Future.value(), + ) as _i24.Future); @override - _i23.Future get mnemonicPassphrase => (super.noSuchMethod( + _i24.Future get mnemonicPassphrase => (super.noSuchMethod( Invocation.getter(#mnemonicPassphrase), - returnValue: _i23.Future.value(), - ) as _i23.Future); + returnValue: _i24.Future.value(), + ) as _i24.Future); @override bool get hasCalledExit => (super.noSuchMethod( Invocation.getter(#hasCalledExit), @@ -2781,9 +2812,9 @@ class MockCoinServiceAPI extends _i1.Mock implements _i20.CoinServiceAPI { returnValue: 0, ) as int); @override - _i23.Future> prepareSend({ + _i24.Future> prepareSend({ required String? address, - required _i14.Amount? amount, + required _i15.Amount? amount, Map? args, }) => (super.noSuchMethod( @@ -2797,36 +2828,36 @@ class MockCoinServiceAPI extends _i1.Mock implements _i20.CoinServiceAPI { }, ), returnValue: - _i23.Future>.value({}), - ) as _i23.Future>); + _i24.Future>.value({}), + ) as _i24.Future>); @override - _i23.Future confirmSend({required Map? txData}) => + _i24.Future confirmSend({required Map? txData}) => (super.noSuchMethod( Invocation.method( #confirmSend, [], {#txData: txData}, ), - returnValue: _i23.Future.value(''), - ) as _i23.Future); + returnValue: _i24.Future.value(''), + ) as _i24.Future); @override - _i23.Future refresh() => (super.noSuchMethod( + _i24.Future refresh() => (super.noSuchMethod( Invocation.method( #refresh, [], ), - returnValue: _i23.Future.value(), - returnValueForMissingStub: _i23.Future.value(), - ) as _i23.Future); + returnValue: _i24.Future.value(), + returnValueForMissingStub: _i24.Future.value(), + ) as _i24.Future); @override - _i23.Future updateNode(bool? shouldRefresh) => (super.noSuchMethod( + _i24.Future updateNode(bool? shouldRefresh) => (super.noSuchMethod( Invocation.method( #updateNode, [shouldRefresh], ), - returnValue: _i23.Future.value(), - returnValueForMissingStub: _i23.Future.value(), - ) as _i23.Future); + returnValue: _i24.Future.value(), + returnValueForMissingStub: _i24.Future.value(), + ) as _i24.Future); @override bool validateAddress(String? address) => (super.noSuchMethod( Invocation.method( @@ -2836,15 +2867,15 @@ class MockCoinServiceAPI extends _i1.Mock implements _i20.CoinServiceAPI { returnValue: false, ) as bool); @override - _i23.Future testNetworkConnection() => (super.noSuchMethod( + _i24.Future testNetworkConnection() => (super.noSuchMethod( Invocation.method( #testNetworkConnection, [], ), - returnValue: _i23.Future.value(false), - ) as _i23.Future); + returnValue: _i24.Future.value(false), + ) as _i24.Future); @override - _i23.Future recoverFromMnemonic({ + _i24.Future recoverFromMnemonic({ required String? mnemonic, String? mnemonicPassphrase, required int? maxUnusedAddressGap, @@ -2863,38 +2894,40 @@ class MockCoinServiceAPI extends _i1.Mock implements _i20.CoinServiceAPI { #height: height, }, ), - returnValue: _i23.Future.value(), - returnValueForMissingStub: _i23.Future.value(), - ) as _i23.Future); + returnValue: _i24.Future.value(), + returnValueForMissingStub: _i24.Future.value(), + ) as _i24.Future); @override - _i23.Future initializeNew() => (super.noSuchMethod( + _i24.Future initializeNew( + ({String mnemonicPassphrase, int wordCount})? data) => + (super.noSuchMethod( Invocation.method( #initializeNew, - [], + [data], ), - returnValue: _i23.Future.value(), - returnValueForMissingStub: _i23.Future.value(), - ) as _i23.Future); + returnValue: _i24.Future.value(), + returnValueForMissingStub: _i24.Future.value(), + ) as _i24.Future); @override - _i23.Future initializeExisting() => (super.noSuchMethod( + _i24.Future initializeExisting() => (super.noSuchMethod( Invocation.method( #initializeExisting, [], ), - returnValue: _i23.Future.value(), - returnValueForMissingStub: _i23.Future.value(), - ) as _i23.Future); + returnValue: _i24.Future.value(), + returnValueForMissingStub: _i24.Future.value(), + ) as _i24.Future); @override - _i23.Future exit() => (super.noSuchMethod( + _i24.Future exit() => (super.noSuchMethod( Invocation.method( #exit, [], ), - returnValue: _i23.Future.value(), - returnValueForMissingStub: _i23.Future.value(), - ) as _i23.Future); + returnValue: _i24.Future.value(), + returnValueForMissingStub: _i24.Future.value(), + ) as _i24.Future); @override - _i23.Future fullRescan( + _i24.Future fullRescan( int? maxUnusedAddressGap, int? maxNumberOfIndexesToCheck, ) => @@ -2906,12 +2939,12 @@ class MockCoinServiceAPI extends _i1.Mock implements _i20.CoinServiceAPI { maxNumberOfIndexesToCheck, ], ), - returnValue: _i23.Future.value(), - returnValueForMissingStub: _i23.Future.value(), - ) as _i23.Future); + returnValue: _i24.Future.value(), + returnValueForMissingStub: _i24.Future.value(), + ) as _i24.Future); @override - _i23.Future<_i14.Amount> estimateFeeFor( - _i14.Amount? amount, + _i24.Future<_i15.Amount> estimateFeeFor( + _i15.Amount? amount, int? feeRate, ) => (super.noSuchMethod( @@ -2922,7 +2955,7 @@ class MockCoinServiceAPI extends _i1.Mock implements _i20.CoinServiceAPI { feeRate, ], ), - returnValue: _i23.Future<_i14.Amount>.value(_FakeAmount_12( + returnValue: _i24.Future<_i15.Amount>.value(_FakeAmount_13( this, Invocation.method( #estimateFeeFor, @@ -2932,23 +2965,23 @@ class MockCoinServiceAPI extends _i1.Mock implements _i20.CoinServiceAPI { ], ), )), - ) as _i23.Future<_i14.Amount>); + ) as _i24.Future<_i15.Amount>); @override - _i23.Future generateNewAddress() => (super.noSuchMethod( + _i24.Future generateNewAddress() => (super.noSuchMethod( Invocation.method( #generateNewAddress, [], ), - returnValue: _i23.Future.value(false), - ) as _i23.Future); + returnValue: _i24.Future.value(false), + ) as _i24.Future); @override - _i23.Future updateSentCachedTxData(Map? txData) => + _i24.Future updateSentCachedTxData(Map? txData) => (super.noSuchMethod( Invocation.method( #updateSentCachedTxData, [txData], ), - returnValue: _i23.Future.value(), - returnValueForMissingStub: _i23.Future.value(), - ) as _i23.Future); + returnValue: _i24.Future.value(), + returnValueForMissingStub: _i24.Future.value(), + ) as _i24.Future); } diff --git a/windows/flutter/generated_plugins.cmake b/windows/flutter/generated_plugins.cmake index 324c950be..701de9701 100644 --- a/windows/flutter/generated_plugins.cmake +++ b/windows/flutter/generated_plugins.cmake @@ -16,6 +16,7 @@ list(APPEND FLUTTER_PLUGIN_LIST ) list(APPEND FLUTTER_FFI_PLUGIN_LIST + tor_ffi_plugin ) set(PLUGIN_BUNDLED_LIBRARIES)